Ever find yourself needing to make a quick call to some WSDL service out there? Do it with PHP next time, and find out how easy it is!
Just download the latest copy of NuSOAP, and type up a PHP file something like:
// include the SOAP classes
require_once(’nusoap.php’);
$client = new soapclient(’http://example.com/url/to/some/valid.wsdl’, True);
$err = $client->getError();
if ($err) {
// Display the error
echo ‘client construction error: ‘ . $err ;
} else {
$answer = $client->call(’someSOAPMethod’,
array(
‘param1′=>’foo’
,’param2′=>’bar’));
$err = $client->getError();
if ($err) {
// Display the error
echo ‘Call error: ‘ . $err;
print_r($client->response);
print_r($client->getDebug());
} else {
print_r($answer);
}
}
?>
It couldn’t be easier. NuSOAP reads and parses the WSDL, configures your method call and params with the correct schema types, and makes the call. The response comes back as an associative array. This is how WS-* should be
Popularity: 32%