I am having trouble understanding how to pass custom types in PHP SOAP calls. Can someone give me a hint (or a link to a guide), 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 as follows:
<message name='getCustDataResponse'> <part name='Result' type='xsd:personalInformation'/> <part name='Result1' type='xsd:string'/> </message>
Invalid part - how to initialize the response on the SOAP server side?
I tried to write:
$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 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 initialized array does not match the response message that I defined.
So, I assume that the type that I defined in wsdl is not used at all, so it should be an error either in wsdl or in the client or server code.
Thanks in advance for your advice!
Nikola
source share