I need some help implementing a php nusoap responce.
Here is what my function returns
Array
(
[total] => 8177
[results] => Array
(
[0] => Array
(
[id] => 340
[name] => Hamburg
)
[1] => Array
(
[id] => 344
[name] => Fos
)
)
)
Now i need to return this as an xml. No matter what I tried ( basically guess ) i get
<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>
as you can see SOAP-ENC:arrayType=":[1000]">
( empty before the : ) also <item xsi:type="xsd:">
and all my items are types string/string .
Here I will post my code so far hopefully someone can spot the problem.
$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[]'
]
]);
Ok so after hours of back and forward I manage to guess the right response, I will post it here in case someone else is stuck with nusoap complex types
Hopefully i managed to help someone.
Cheers