Jump to content

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@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.

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

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

$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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.