note 100292 modified in soapclient.soapclient by danbrown
| From: | danbrown@php.net | Date: | Wed, 06 Oct 2010 14:43:06 +0000 |
| Subject: | note 100292 modified in soapclient.soapclient by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173007@lists.php.net to get a copy of this message | ||
It should be noted that if you receive a return error : 'Object reference not set to an
instance of an object.'. This could be due to something as simple as passing the incorrect
parameters. When you look at this XML:
<Get xmlns="http://example.com">
<request>
<CustomerId>string</CustomerId>
<From>dateTime</From>
<To>dateTime</To>
</request>
</Get>
Your code should look something like this:
<?php
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient('http://example.com/doc.asmx?WSDL',
$options);
// Note where 'Get' and 'request' tags are in the XML
$results =
$client->Get(array('request'=>array('CustomerId'=>'1234')));
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
$results =
$client->Get(array('request'=>array('CustomerId'=>'842115')));
?>
--was--
It should be noted that if you receive a return error : 'Object reference not set to an
instance of an object.'. This could be due to something as simple as passing the incorrect
parameters. When you look at this XML:
<Get xmlns="http://example.com">
<request>
<CustomerId>string</CustomerId>
<From>dateTime</From>
<To>dateTime</To>
</request>
</Get>
Your code should look something like this:
<?php
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient('http://yoururl/doc.asmx?WSDL', $options);
// Note where 'Get' and 'request' tags are in the XML
$results =
$client->Get(array('request'=>array('CustomerId'=>'1234')));
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
$results =
$client->Get(array('request'=>array('CustomerId'=>'842115')));
?>
http://php.net/manual/en/soapclient.soapclient.php