So I’m new to using SoapClient.
It’s… not very well documented, really.
But still, here’s what i’ve managed to do.
I have a WSDL that defines available requests; For simplicity’s sake, lets assume there are two: Login and Get.
Instantiate a SoapClient…check.
$client = new SoapClient($wsdlurl);
(I’m not particularly focussed on Options atm.)
Create a request for Login. Now, I know that my Request eventually needs to look like: (Roughly)
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Body xmlns:ns1="http://www.example.org/a_valid_endpoint">
<ns1:username>Quack</ns1:username>
<ns1:pwd>Moo</ns1:pwd>
</soap:Body>
</soap:Envelope>
So, I do:
$res = $client->Login(array('username' => 'Quack', 'pwd' => 'Moo'));
And all works fine.
When it comes to my Get, however, the result needs to look like: (Simplified)
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Body xmlns:ns1="http://www.example.org/a_valid_schema" xmlns:ns2="http://a.different/schema">
<ns1:objectType>Quacker</ns1:objectType>
<ns1:object>
<ns2:id>10</ns2:id>
<ns2:name>A Thing</ns2:name>
</ns1:object>
</soap:Body>
I tried:
$res = $client->Get(array('objectType' => 'Quacker', 'object' => array('id' => 10, 'name' => 'Moo')));
but Wireshark shows that the POST in this case sent:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Body xmlns:ns1="http://www.example.org/a_valid_schema">
<ns1:objectType>Quacker</ns1:objectType>
<ns1:object />
</soap:Body>
So i’m a little confused.