DHood Posted April 23, 2013 Share Posted April 23, 2013 I'm attempting to work with an api that uses soap connections. I keep getting SoapFault Object ( [message:protected] => Server was unable to process request. --> Object reference not set to an instance of an object. This error. My code is $ns = "http://www.fastcash4homes.com/WS/LeadSubmission.asmx?WSDL"; $soapClient = new SoapClient("http://www.fastcash4homes.com/WS/LeadSubmission.asmx?WSDL"); $headers = array(); $headers[] = new SoapHeader('NAMESPACE', 'Content-Type', 'text/xml; charset=utf-8'); $headers[] = new SoapHeader('NAMESPACE', 'SOAPAction', 'http://www.fastcash4homes.com/WS/LeadSubmission.asmx/SubmitMinimalFullSellerLead'); // Prepare Soap Client $soapClient->__setSoapHeaders($headers); $array = array( 'FirstName' => 'firstname', 'LastName' => 'lastname', 'PrimaryPhone' => '9995554444', 'Email' => 'Email@ext.com', 'Address' => '123 Address St', 'Zip' => '12345', 'Bedrooms' => '2', 'Bathrooms' => '2', 'AskingPrice' => '50000', 'IsCurrentlyListed' => 'No' ); // Call RemoteFunction () $error = 0; try { print_r($soapClient); $info = $soapClient->__call("SubmitMinimalFullSellerLead", array('UserID' => 'UserID', 'Password' => 'Password', 'LeadData_Required' => $array, 'LeadData_Optional' => '')); } catch (SoapFault $fault) { print_r($fault); die; } I've tried a variety of different arrays in $soapClient->__call (which is the line erroring by the way). Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
requinix Posted April 23, 2013 Share Posted April 23, 2013 LeadData_Optional corresponds to an object in the WSDL, not a string. It needs to be an (empty) array. By the way that error message is coming from the service, not from PHP. Their code is triggering that error, but it's because of invalid input so they don't care. Quote Link to comment Share on other sites More sharing options...
DHood Posted April 23, 2013 Author Share Posted April 23, 2013 (edited) Thanks. If it's supposed to be an empty array, how am I suppose to populate the fields? [EDIT] Nevermind, I thought you were talking about the required field not the optional, Read it too quickly. Edited April 23, 2013 by DHood Quote Link to comment Share on other sites More sharing options...
DHood Posted April 24, 2013 Author Share Posted April 24, 2013 I tried it with an empty array and it's still erroring, do I need to maybe change it to an object instead of an array? Quote Link to comment Share on other sites More sharing options...
requinix Posted April 24, 2013 Share Posted April 24, 2013 Don't remember if it matters. Sure, try it. $info = $soapClient->__call("SubmitMinimalFullSellerLead", array('UserID' => 'UserID', 'Password' => 'Password', 'LeadData_Required' => (object)$array, 'LeadData_Optional' => new stdClass())); Quote Link to comment Share on other sites More sharing options...
ignace Posted April 24, 2013 Share Posted April 24, 2013 $soapClient = new SoapClient("http://www.fastcash4homes.com/WS/LeadSubmission.asmx?WSDL", array('trace' => true, 'exceptions' => true));When you pass trace=>true then extra features become available: SoapClient::__getLastRequest SoapClient::__getLastRequestHeaders SoapClient::__getLastResponse SoapClient::__getLastResponseHeaders Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.