我正在使用SoapServer类在PHP中构建Web服务,但我遇到了一个复杂类型转换的问题。PHP SoapServer和复杂类型
WSDL是完全有效的,PHP SoapClient完美地处理它,但似乎有一个复杂类型返回的问题没有被正确转换。这在使用.Net中的服务时变得明显,因为我收到的异常表明该类型不在给定的名称空间中。
我重复了我的函数,改变了元素上的命名空间,但.Net继续给我错误,无论我使用什么命名空间。
认为剧本以下简称:
function getCommands() {
$output = array();
// ...
foreach($result as $row) {
$output[] = new SoapVar($row, SOAP_ENC_OBJECT, 'ns1:command');
}
return $output;
}
缩写响应:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:MyWebService"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getCommandsResponse>
<return SOAP-ENC:arrayType="ns1:command[12]" xsi:type="ns1:ArrayOfCommand">
<item xsi:type="ns1:command">
<!-- ... -->
</item>
<!-- ... -->
</return>
</ns1:getCommandsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我已经注意到的是,xmlns:ns1
由WSDL的方式定义的,它确实匹配WSDL中的命名空间。但是.Net SOAP客户端似乎并不了解在那里定义了command
元素。但是,它确实知道这就是定义ArrayOfCommand
的地方。
所以我的问题是多:
- 这是一个已知的bug与SoapServer的?
- 如果没有,我是否在我的WSDL中丢失了某些令人悲伤的东西?
- 我是不是正确编码我的对象?
- 这是.Net的问题吗?如果是这样,那么解决方法是什么?