我们正在将 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,
));
相关的 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>
当我提交请求时,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>
当我在 PHP 中转储结果对象时,它看起来像这样:
stdClass Object
(
[messages] => stdClass Object
(
[item] => Array // <-- here
(
[0] => foo
[1] => bar
)
)
)
为什么结果树中有一个额外的元素“项目”?当我们还在使用 RPC/encoded 时,这还不存在。
有没有办法在处理响应时删除该元素?