I am using PHP 5.2.10 and I am trying to consume a webservice which returns complex data types using the standard SOAP extension.
The problem is that SoapClient does not populate objects which are nested into other objects / array of objects. A simplified example of what I get when I call the getUtente method, specifying "my_unique_id" as a parameter is:
stdClass Object
(
[getUtenteReturn] => stdClass Object
(
[userName] => my_unique_id
[fieldOne] => ...
[fieldTwo] => ...
[utilizzatore] => stdClass Object
( // This is EMPTY instead of containing a series of userName's
)
)
)
The relevant part of the WDSL description is:
<element name="getUtenteResponse">
<complexType>
<sequence>
<element name="getUtenteReturn" type="tns1:Cliente"/>
</sequence>
</complexType>
</element>
...
<complexType name="Utilizzatore">
<sequence>
<element name="userName" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
...
<complexType name="Cliente">
<complexContent>
<extension base="tns1:Utilizzatore">
<sequence>
<element name="fieldOne" nillable="true" type="xsd:string"/>
<element name="fieldTwo" nillable="true" type="xsd:string"/>
<element name="utilizzatore" nillable="true" type="impl:ArrayOf_tns1_Utilizzatore"/>
</sequence>
</extension>
</complexContent>
</complexType>
What I found I am not the only one experiencing this problem. In particular I found this comment in the PHP official documentation and this other forum entry to give two different ideas on how to approach the problem, but I have not been able to turn any of those two ideas into a working solution: I seem not to completely understand the logic behind the examples given.
I would be grateful if anybody could guide me in this: some working code on another webservice would be welcome, but what I am primarily after is really understanding the problem and the logic of the solutions proposed (the fish lane, not the fish!). :)
Thank you in advance for your time.