Hello,
I'm having trouble understanding how to pass user-defined types in PHP SOAP calls. Could someone give me a hint (or a link to a manual) please?
Example: In my WSDL file, I define the type:
<types>
<schema targetNamespace="http://example.com/CustData"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="personalInformation">
<complexType>
<all>
<element name="name" type="xsd:string"/>
<element name="title" type="xsd:string"/>
<element name="lang" type="xsd:string"/>
</all>
</complexType>
</element>
</schema>
I define the service response message like this:
<message name='getCustDataResponse'>
<part name='Result' type='xsd:personalInformation'/>
<part name='Result1' type='xsd:string'/>
</message>
The missing part is - how do I initialize the answer on the SOAP server side?
I tried writing:
$arrRes['Result']['name'] = 'xxx';
$arrRes['Result']['title'] = 'yyy';
$arrRes['Result']['lang'] = 'zzz';
$arrRes['Result']['hehehehe1'] = 'test1';
$arrRes['Result']['hehehehe2'] = 'test2';
$arrRes['Result']['hehehehe3'] = 'test3';
$arrRes['Result']['hehehehe4'] = 'test4';
$arrRes['Result1'] = 'result1';
$arrRes['blablabla'] = 'hahaha';
return $arrRes;
The client gets the response back and when I var_dump it, it shows the arrRes:
array(2) { ["Result"]=> array(7) { ["name"]=> string(3) "xxx" ["title"]=> string(3) "yyy" ["lang"]=> string(3) "zzz" ["hehehehe1"]=> string(5) "test1" ["hehehehe2"]=> string(5) "test2" ["hehehehe3"]=> string(5) "test3" ["hehehehe4"]=> string(5) "test4" } ["Result1"]=> string(7) "result1" }
I expected to get an error because the array I initialized doesn't match the response message I have defined.
So I guess the type I have defined in the wsdl isn't used at all - so it must be an error either in the wsdl or in the client or server code.
Thanks in advance for your advice!!
Nikola