Reputation: 2214
Using SoapClient, is it possible to map an element name (as opposed to a type) to a php class?
In the php manual:
http://www.php.net/manual/en/soapclient.soapclient.php
classmap is defined thus:
The classmap option can be used to map some WSDL types to PHP classes. This option must be an array with WSDL types as keys and names of PHP classes as values.
Is it possible to map an element if it does not have a type?
eg.
<xsd:element name="M1Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="N1Response" type="bons0:R1Out"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
ie. I want to map the element M1Response
to a php class
I can map N1Response
to a php class, but the response is like so:
stdClass Object
(
[N1Response] => MyPHPClassResponse Object
(
...
)
)
which almost defeats the purpose of the classmap functionality.
Any help would be appreciated.
Thanks
Upvotes: 3
Views: 4377
Reputation: 2214
So I misunderstood the definition of types
type
is not R1Out
in the following example:
<xsd:element name="N1Response" type="bons0:R1Out"/>
it is in fact this type
:
$options['classmap'] = array('M1Response' => 'MyPHPClassResponse');
$client = new SoapClient('test.wsdl', $options);
$client->__getTypes();
Examining the output of __getTypes()
reveals that there is indeed a type associated with the M1Response element:
struct M1Response {
R1Out N1Response;
}
And so the answer is (as mentioned above):
$options['classmap'] = array('M1Response' => 'MyPHPClassResponse');
Upvotes: 5