Skip to content

Instantly share code, notes, and snippets.

@ishahid
Created January 15, 2014 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishahid/8429779 to your computer and use it in GitHub Desktop.
Save ishahid/8429779 to your computer and use it in GitHub Desktop.
SOAP service call in PHP.
<?php
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient('http://soap.service-provider.com/endpoint.asmx?WSDL', $options);
}
catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
try {
$parameters= array('username'=>'user', 'password'=>'password', 'another_param'=>'some_value');
$response = $client->getStatus($parameters); // Call the service function getStatus()
if (isset($response->getStatusResult))
{
echo $response->getStatusResult->Id;
} else {
echo 'NULL';
}
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment