[英]NuSoap Complex type when count + array of results
我需要一些帮助来实现php nusoap响应。
这是我的函数返回的内容
Array
(
[total] => 8177
[results] => Array
(
[0] => Array
(
[id] => 340
[name] => Hamburg
)
[1] => Array
(
[id] => 344
[name] => Fos
)
)
)
现在,我需要将此返回为xml。 无论我尝试了什么(基本上是猜测),我都会明白
<total xsi:type="xsd:int">8177</total>
<results xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[1000]">
<item xsi:type="xsd:">
<id xsi:type="xsd:string">340</id>
<name xsi:type="xsd:string">Hamburg</name>
</item>
如您所见, SOAP-ENC:arrayType=":[1000]">
(在:之前为空)也是<item xsi:type="xsd:">
,我所有的项目都是string / string类型。
到目前为止,我将在这里发布我的代码,希望有人可以发现问题。
$server->register(
"tankerPortsSearch",
[
'name' => 'xsd:string',
'step' => 'xsd:int',
'page' => 'xsd:int',
],
[
'total' => 'xsd:int',
'results' => 'tns:responceArray'
],
'urn:tankerPortsSearch',
'urn:tankerZonesTraffic#tankerPortsSearch',
'rpc',
'encoded',
'Tanker Ports Search'
);
$server->wsdl->addComplexType('responceArrayData', 'complexType', 'struct', '', 'SOAP-ENC:Array', [
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'name' => array('name' => 'name', 'type' => 'xsd:string')
]);
// *************************************************************************
// Complex Array ++++++++++++++++++++++++++++++++++++++++++
$server->wsdl->addComplexType('responceArray', 'complexType', 'array', 'squence', '', [], [
[
'ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:responceArrayData[]'
]
]);
好了,经过数小时的来回测试,我设法猜出了正确的答案,如果有人卡住了nusoap复杂类型,我会在这里发布它
$server->register("tankerPortsSearch", [
'name' => 'xsd:string',
'step' => 'xsd:int',
'page' => 'xsd:int',
], [
'total' => 'xsd:int',
'results' => 'tns:responceArray'
], 'urn:tankerPortsSearch', 'urn:tankerZonesTraffic#tankerPortsSearch', 'rpc', 'encoded', 'Tanker Ports Search');
$server->wsdl->addComplexType('responceArrayData', 'complexType', 'struct', '', '', [
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'name' => array('name' => 'name', 'type' => 'xsd:string')
]);
// *************************************************************************
// Complex Array ++++++++++++++++++++++++++++++++++++++++++
$server->wsdl->addComplexType('responceArray', 'complexType', 'array', '', '', [], [
[
'ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:responceArrayData[]',
]
], 'tns:responceArrayData');
希望我能帮助别人。
干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.