LoOpy Posted May 8, 2008 Share Posted May 8, 2008 Error: Server was unable to process request. ---> Object reference not set to an instance of an object. What am i doing wrong, im trying to edit the request, the output of the __dorequest() looks perfect but the __getLastRequest() still looks like the original format am i missing a step am I calling things worng im kinda fumbling in the dark here i need some direction. Any help is much aprieciated Thanks running php 5.2.3 on IIS trying to connect to a asp.net soap service. <?php $wsdl = "http://locationcheck.netstaronline.net/LocationChecker.asmx?WSDL"; $param = array( "vbuNumber" => "771323", "systemID" => "Vigil", "username" => "locationchecker", "password" => "L0c@ti0nCh3ck3r", "errorCode" => "" ); class MSSoapClient extends SoapClient { function __construct($wsdl, $options = null) { parent::__construct($wsdl, $options); } function __doRequest($request, $location, $action, $version) { $namespace = "http://tempuri.com/"; $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1); $request = preg_replace('/<ns1:(\w+)/', '<$1', $request); $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request); $request = str_replace('<SOAP-ENV','<soap',$request); $request = str_replace('</SOAP-ENV','</soap',$request); $request = str_replace('xmlns:ns1="http://tempuri.org/"','',$request); $request = str_replace('xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"', 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"',$request); //echo "Request:".htmlspecialchars($request)." \n \n"; // parent call return parent::__doRequest($request, $location, $action, $version); } } $client = new MSSoapClient($wsdl,array("location"=>'http://locationcheck.netstaronline.net/LocationChecker.asmx', "trace" => 1, "exceptions" => 0)); try { echo "<pre>\n"; print($client->GetVehicleLatestPos($param)); print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n"; print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n"; echo "\n</pre>\n"; } catch (SoapFault $exception){ echo $exception; } ?> What the request should look like <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetVehicleLatestPos xmlns="http://tempuri.org/"> <vbuNumber>string</vbuNumber> <systemID>string</systemID> <username>string</username> <password>string</password> <errorCode>string</errorCode> </GetVehicleLatestPos> </soap:Body> </soap:Envelope> Link to comment https://forums.phpfreaks.com/topic/104682-soap-problems/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.