小编mar*_*out的帖子

为什么在文档/文字样式中使用WSDL的SoapClient返回带有额外键元素的数组?

我们正在将RPC /编码的web服务转换为document/literal/wrapped.WSDL(使用nusoap)已经被重写以使用新格式.

我像这样使用PHP SoapClient:

new SoapClient($wsdlUrl, array(
    'cache_wsdl' => WSDL_CACHE_NONE,
    'trace' => true,
    'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
));
Run Code Online (Sandbox Code Playgroud)

相关的WSDL部分如下所示(应该遵循WS-I Basic Profile):

<xsd:complexType name="messages">
    <xsd:sequence>
        <xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="some_functionResponseType">
    <xsd:all>
        <xsd:element name="return" type="tns:messages" form="unqualified"/>
    </xsd:all>
</xsd:complexType>

<message name="some_functionResponse">
    <part name="parameters" element="tns:some_functionResponseType"/>
</message>

<operation name="some_function">
    <input message="tns:some_functionRequest"/>
    <output message="tns:some_functionResponse"/>
</operation>
Run Code Online (Sandbox Code Playgroud)

当我提交请求时,XML响应是这样的:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <some_functionResponse xmlns="urn:toets_nl_wsdl">
      <messages xmlns="">
        <item>foo</item>
        <item>bar</item>
      </messages>
    </some_functionResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

当我在PHP中转储结果对象时,它看起来像这样:

stdClass Object
(
    [messages] => stdClass Object
        ( …
Run Code Online (Sandbox Code Playgroud)

php soap wsdl

5
推荐指数
1
解决办法
5805
查看次数

标签 统计

php ×1

soap ×1

wsdl ×1