note 108641 modified in soapclient.soapcall by danbrown
| From: | danbrown@php.net | Date: | Mon, 14 May 2012 14:55:36 +0000 |
| Subject: | note 108641 modified in soapclient.soapcall by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187970@lists.php.net to get a copy of this message | ||
For all those poor souls getting the "Fatal error: Uncaught SoapFault exception:
[soap:Server] Server was unable to process request. ---> Object reference not set to an
instance of an object. in xyz.php" using WSDL.
Aparently all sorts of things cause this but for me the fix was
to passin all parameters (not only the requied onces). I just passed the rest as empty strings and
the problem was solved. example
below 	<?php 	ini_set('display_errors',
true); 	ini_set("soap.wsdl_cache_enabled",
"0"); 	error_reporting(E_ALL); 	$client
= new SoapClient('http://example.com/searchhsd.asmx?WSDL',
array(	'trace' => true, 'exceptions' =>
true, 																												'connection_timeout'=>9999,
																												'features'
=>
SOAP_SINGLE_ELEMENT_ARRAYS, 																												'soap_version'
=> SOAP_1_1, 'encoding' =>
'ISO-8859-1', 																											)); 	//var_dump($client->__getFunctions()); 	//var_dump($client->__getTypes());
	$search_results_xml = $client->HSDSiteSearch (
array(	'startPos' =>
1, 															'maxResults'
=>
100, 															'resultOrderVal'
=>
'Site', 															'searchSimilarNames'
=>
true, 															'name'
=>
'', 															'includePracName'
=>
true, 															'suburbsAndPostcodes'
=>
'Melbourne', 															'searchSurroundingSuburbs'
=>
true, 															'pcpDesc'
=>
'', 															'cityOrShireDesc'
=>
'', 															'siteGPDivDesc'
=>
'', 															'serviceCategoryDesc'
=>
'', 															'serviceTypeDesc'
=>
'', 															'keywords'
=>
'', 															'targetGroup'
=>
'', 															'freeServicesOnly'
=>
false, 															'afterHoursOnly'
=>
false, 															'startTimeDesc'
=>
'', 															'endTimeDesc'
=>
'', 															'openOnDesc'
=>
'', 															'pracFamilyName'
=>
'', 															'pracGivenName'
=>
'', 										
;					'pracNoAppointmentRequired' =>
false, 															'pracSpecialInterests'
=>
'', 															'pracSexDesc'
=>
'', 															'pracLanguageSpokenDesc'
=>
'', 															'pracSpecialityDesc'
=>
'', 															'pracEthnicityDesc'
=> ''
															)
); 	print_r($search_results_xml); 	/*print
"Request: \\n". 	$client->__getLastRequestHeaders()
."\\n"; 	print "Request:
\\n". 	$client->__getLastRequest()
."\\n"; 	print "Response:
\\n". 	$client->__getLastResponseHeaders()."\\n"; 	print
"Response:
\\n". 	$client->__getLastResponse()."\\n";	*/
?>
--was--
For all those poor souls getting the "Fatal error: Uncaught SoapFault exception: [soap:Server]
Server was unable to process request. ---> Object reference not set to an instance of an object.
in xyz.php" using WSDL.
Aparently all sorts of things cause this but for me the fix was to passin all parameters (not only
the requied onces). I just passed the rest as empty strings and the problem was solved.
working example below
<pre>
<?php
ini_set('display_errors', true);
ini_set("soap.wsdl_cache_enabled", "0");
error_reporting(E_ALL);
$client = new SoapClient('http://humanservicesdirectory.vic.gov.au/hsddataapi/searchhsd.asmx?WSDL',
array( 'trace' => true, 'exceptions' => true,
'connection_timeout'=>9999,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'soap_version' => SOAP_1_1, 'encoding' =>
'ISO-8859-1',
));
//var_dump($client->__getFunctions());
//var_dump($client->__getTypes());
$search_results_xml = $client->HSDSiteSearch ( array( 'startPos' => 1,
'maxResults' => 100,
'resultOrderVal' => 'Site',
'searchSimilarNames' => true,
'name' => '',
'includePracName' => true,
'suburbsAndPostcodes' => 'Melbourne',
'searchSurroundingSuburbs' => true,
'pcpDesc' => '',
'cityOrShireDesc' => '',
'siteGPDivDesc' => '',
'serviceCategoryDesc' => '',
'serviceTypeDesc' => '',
'keywords' => '',
'targetGroup' => '',
'freeServicesOnly' => false,
'afterHoursOnly' => false,
'startTimeDesc' => '',
'endTimeDesc' => '',
'openOnDesc' => '',
'pracFamilyName' => '',
'pracGivenName' => '',
'pracNoAppointmentRequired' => false,
'pracSpecialInterests' => '',
'pracSexDesc' => '',
'pracLanguageSpokenDesc' => '',
'pracSpecialityDesc' => '',
'pracEthnicityDesc' => ''
) );
print_r($search_results_xml);
/*print "Request: \n".
$client->__getLastRequestHeaders() ."\n";
print "Request: \n".
$client->__getLastRequest() ."\n";
print "Response: \n".
$client->__getLastResponseHeaders()."\n";
print "Response: \n".
$client->__getLastResponse()."\n"; */
?>
</pre>
http://php.net/manual/en/soapclient.soapcall.php