首页 > 解决方案 > 使用 php 将数组传递给 wsdl 文件无法正常工作

问题描述

我在 client.php 中定义了一个数组:

$array = array(13,"Maria","Mueller");

我将它传递$result1 = $client->__soapCall("function", array($array));给 wsdl 文件。

在我的wsdl中是这样写的:

            <xsd:complexType name='function'>
                <xsd:sequence>
                    <xsd:element name='item' type='xsd:string' maxOccurs='unbounded'/>
                </xsd:sequence>
            </xsd:complexType>

我认为我的 wsdl 工作不正常。我不明白它为什么起作用,即使数组中的值之一是整数值。我也使用简单类型,当我将一个整数值传递给定义为字符串的元素时,它不起作用。现在我想要,当我定义一切都应该是一个字符串时,它也不适用于数组中的整数 13。因为我也有只允许包含整数的数组,并且当该数组中出现字符串值时,我的 wsdl 不应传递该数组。

问候

标签: phparrayssoapwsdlcomplextype

解决方案


我使它与:

xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"

在类型中:

        <xsd:complexType name="function1">
            <xsd:complexContent>
                <xsd:restriction base="soapenc:Array">
                    <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:integer"/>
                </xsd:restriction>
            </xsd:complexContent>
        </xsd:complexType>

对于字符串:

        <xsd:complexType name="function1">
            <xsd:complexContent>
                <xsd:restriction base="soapenc:Array">
                    <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string"/>
                </xsd:restriction>
            </xsd:complexContent>
        </xsd:complexType>

并在消息中:

<wsdl:message name="createRequest1">
    <wsdl:part name="array" type='tns:function1'/>
</wsdl:message>

来源:https ://www.w3.org/TR/2001/NOTE-wsdl-20010315


推荐阅读