note 108641 modified in soapclient.soapcall by danbrown

From: 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 &#34;Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---&#62; Object reference not set to an instance of an object. in xyz.php&#34; using WSDL. &#13;&#10;&#13;&#10;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. &#13;&#10;&#13;&#10;example below&#13;&#10;&#9;&#60;?php&#13;&#10;&#9;ini_set(&#39;display_errors&#39;, true);&#13;&#10;&#9;ini_set(&#34;soap.wsdl_cache_enabled&#34;, &#34;0&#34;);&#13;&#10;&#9;error_reporting(E_ALL);&#13;&#10;&#9;$client = new SoapClient(&#39;http://example.com/searchhsd.asmx?WSDL&#39;, array(&#9;&#39;trace&#39; =&#62; true, &#39;exceptions&#39; =&#62; true,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;connection_timeout&#39;=&#62;9999, &#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;features&#39; =&#62; SOAP_SINGLE_ELEMENT_ARRAYS,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;soap_version&#39; =&#62; SOAP_1_1, &#39;encoding&#39; =&#62; &#39;ISO-8859-1&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;));&#13;&#10;&#9;//var_dump($client-&#62;__getFunctions());&#13;&#10;&#9;//var_dump($client-&#62;__getTypes()); &#13;&#10;&#13;&#10;&#9;$search_results_xml = $client-&#62;HSDSiteSearch ( array(&#9;&#39;startPos&#39; =&#62; 1,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;maxResults&#39; =&#62; 100,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;resultOrderVal&#39; =&#62; &#39;Site&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;searchSimilarNames&#39; =&#62; true,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;name&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;includePracName&#39; =&#62; true,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;suburbsAndPostcodes&#39; =&#62; &#39;Melbourne&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;searchSurroundingSuburbs&#39; =&#62; true,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pcpDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;cityOrShireDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;siteGPDivDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;serviceCategoryDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;serviceTypeDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;keywords&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;targetGroup&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;freeServicesOnly&#39; =&#62; false,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;afterHoursOnly&#39; =&#62; false,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;startTimeDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;endTimeDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;openOnDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracFamilyName&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracGivenName&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9 ;&#9;&#9;&#9;&#9;&#9;&#39;pracNoAppointmentRequired&#39; =&#62; false,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracSpecialInterests&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracSexDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracLanguageSpokenDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracSpecialityDesc&#39; =&#62; &#39;&#39;,&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#39;pracEthnicityDesc&#39; =&#62; &#39;&#39; &#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;) );&#13;&#10;&#13;&#10;&#9;print_r($search_results_xml);&#13;&#10;&#13;&#10;&#9;/*print &#34;Request: \\n&#34;.&#13;&#10;&#9;$client-&#62;__getLastRequestHeaders() .&#34;\\n&#34;;&#13;&#10;&#9;print &#34;Request: \\n&#34;.&#13;&#10;&#9;$client-&#62;__getLastRequest() .&#34;\\n&#34;;&#13;&#10;&#9;print &#34;Response: \\n&#34;.&#13;&#10;&#9;$client-&#62;__getLastResponseHeaders().&#34;\\n&#34;;&#13;&#10;&#9;print &#34;Response: \\n&#34;.&#13;&#10;&#9;$client-&#62;__getLastResponse().&#34;\\n&#34;;&#9;*/&#13;&#10;&#13;&#10; ?&#62; --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

« previous php.notes (#187970) next »