Synergic Posted October 16, 2007 Share Posted October 16, 2007 I have a web service which i want to consume via PHP. Whenever i attempt to communicate with it it comes up with: "Server was unable to process request. --> Object reference not set to an instance of an object." Googled it and got the following: http://php.net/soap_soapclient_soapcall Apparently this code should work to fix the above problem: <?php class Test { public $account; public $password; } $parameters = new Test; $parameters -> account = $username; $parameters -> password = $password; try { $client = new SoapClient ("https://www.somewebsite.com/Serv ice.asmx?wsdl", array('classmap' => array('CheckUser' => 'Test'))); $client -> CheckUser ($parameters); echo "Valid Credentials!"; } catch (Exception $e) { echo "Error!<br />"; echo $e -> getMessage (); } ?> I modified it and my version as follows: <? class Book { public $author = "1"; public $title = "2"; public $publisher= "3"; public $loc= "4"; } $bookC = new Book; $sc = new SoapClient("URLTOWEBSERVICE?wsdl", array('classmap' => array('bookC ' => "Book"))); try { print_r($sc->getBook($bookC)); } catch (Exception $e) { echo $e->getMessage(); } WSDL as follows: - <s:complexType name="Book"> - <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="author" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="title" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="publisher" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="loc" type="s:string" /> </s:sequence> </s:complexType> Been stuck on it for a while, any ideas? I've also tried using nuSoap with the same result. :| Link to comment https://forums.phpfreaks.com/topic/73445-phpsoap-soapclient/ Share on other sites More sharing options...
Synergic Posted October 16, 2007 Author Share Posted October 16, 2007 anyone? been stuck on it for days.... Link to comment https://forums.phpfreaks.com/topic/73445-phpsoap-soapclient/#findComment-370644 Share on other sites More sharing options...
Synergic Posted October 16, 2007 Author Share Posted October 16, 2007 btw if i change getBook to getBookX i get invalid method, so i know i can connect to the web service. Link to comment https://forums.phpfreaks.com/topic/73445-phpsoap-soapclient/#findComment-371090 Share on other sites More sharing options...
sonofsam Posted November 5, 2007 Share Posted November 5, 2007 This is how it work for me $iqware = new soapclient("http://your Address?WSDL"); $guid = 2; $intGUID = array('intGUID' => $guid); #the Paramameters that need to goes on the web service $isGUIDValid = $iqware->__call("isGUIDValid", array("parameters" => $intGUID)); print $isGUIDValid->isGUIDValidResult; print '<br />'; Link to comment https://forums.phpfreaks.com/topic/73445-phpsoap-soapclient/#findComment-385189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.