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 protected]', '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. Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/ 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. Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/#findComment-1426196 Share on other sites More sharing options...
DHood Posted April 23, 2013 Author Share Posted April 23, 2013 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. Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/#findComment-1426198 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? Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/#findComment-1426296 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())); Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/#findComment-1426371 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 Link to comment https://forums.phpfreaks.com/topic/277226-soap-help/#findComment-1426409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.