Aug 19 2008

SOAP in PHP is quite simple, and as it’s something I’m doing at work at the moment, I thought I’d copy a bit of code to remind myself how to do it. Also to remind myself about the idea Chris had for Private Passwords.

Creating the client:

// WSDL client
$client = new SoapClient($wsdl);
 
// Non-WSDL client
$client = new SoapClient(NULL, array(
					"location" => $endpoint_url . $script_name,
					"uri" => $endpoint_url);

It’s that easy to create the client, and just as easy to make the request itself:

// WSDL client
$result = $client->doSomething("argument");
 
// Non-WSDL client
$result = $client->__soapCall("doSomething", array("argument"));

As this is PHP, and PHP is lovely, the result is an object, and can be accessed as a normal object.

Leave a Reply