Jump to content

SOAP Help


DHood

Recommended Posts

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

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.