Error: "The reference to the object is not installed on the instance of the object" when calling SOAP cilent in PHP

Here are the data from wsdl

<s:element name="CreateDraftLead"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="formId" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Gender" nillable="true" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="AgeGroup" nillable="true" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="MobilePhone" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Birthday" nillable="true" type="s:dateTime"/> <s:element minOccurs="0" maxOccurs="1" name="District" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="email" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Region" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="LocationId" nillable="true" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="LeadSourceId" nillable="true" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="CompanyId" nillable="true" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="SourceCampaignId" nillable="true" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="AllowEmail" nillable="true" type="s:boolean"/> <s:element minOccurs="0" maxOccurs="1" name="Questions" type="tns:ArrayOfQuestion"/> </s:sequence> </s:complexType> </s:element> <s:complexType name="ArrayOfQuestion"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="Question" nillable="true" type="tns:Question"/> </s:sequence> </s:complexType> <s:complexType name="Question"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="Key" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Value" type="s:string"/> </s:sequence> </s:complexType> 

And here is my error code

 $client = new SoapClient("http://demo/demo.asmx?wsdl", array('trace' => 1, "exception" => 0)); $data = array( 'formId' => 1, 'LocationId' => 1, 'FirstName' => 'test', 'LastName' => 'test', 'MobilePhone' => 11111111, 'email' => ' test@test.com ', 'AllowEmail' => 0, 'Region' => 'HK', 'LeadSourceId' => 11, 'Questions' => array( "Question" => array("AgeGroup" => 10), "Question" => array("Gender" => 1), "Question" => array("Remarks" => 'test'), "Question" => array("Are you currently a member of any yoga or fitness centre? " => 'Yes'), ) ); $result = $client->CreateDraftLead(array('parameters' => $data)); var_dump($result); 

This is caused by the input data structure, how to fix it? Thanks for the help.

Error message:

 Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\xampp\htdocs\test_soap.php:60 Stack trace: #0 C:\xampp\htdocs\test_soap.php(60): SoapClient->__call('CreateDraftLead', Array) #1 C:\xampp\htdocs\test_soap.php(60): SoapClient->CreateDraftLead(Array) #2 {main} thrown in C:\xampp\htdocs\test_soap.php on line 60 

Updated:

Thanks for the help. right now you can send to the server

 <?php $client = new SoapClient("http://demo/demo.asmx?wsdl"); $data = array( 'formId' => '1', 'FirstName' => 'test', 'LastName' => 'test', //'Gender' => 1, //'AgeGroup' => 10, 'MobilePhone' => '11111111', 'Birthday' => null, 'District' => 'HK', 'email' => ' test@test.com ', 'Region' => 'HK', 'LocationId' => 1, 'LeadSourceId' => 11, 'CompanyId' => null, 'SourceCampaignId' => null, 'AllowEmail' => false, 'Questions' => array( "Question" => array("AgeGroup" => 10), "Question" => array("Gender" => 1), "Question" => array("Remarks" => 'test'), "Question" => array("Are you currently a member of any yoga or fitness centre? " => 'Yes'), ) ); $result = $client->__soapCall("CreateDraftLead", array($data)); var_dump($result); ?> 

The problems remain:

1) AllowEmail takes the value boolean, but either 0.1, true, false return error: Invalid column name "false" / Invalid column name "true" from the server, but this is not an exception

2) means minOccurs = '1' means should provide? as verified, can ignore the field, and the server still returns success

Thank you for your great efforts.

+6
source share
3 answers

Please try the following (not verified):

 <?php $client = new SoapClient("http://demo/demo.asmx?wsdl", array('trace' => 1, "exception" => 0)); $data = array( 'formId' => 1, 'LocationId' => 1, 'FirstName' => 'test', 'LastName' => 'test', 'MobilePhone' => 11111111, 'email' => ' test@test.com ', 'AllowEmail' => 0, 'Region' => 'HK', 'LeadSourceId' => 11, 'Questions' => array( "Question" => array("AgeGroup" => 10), "Question" => array("Gender" => 1), "Question" => array("Remarks" => 'test'), "Question" => array("Are you currently a member of any yoga or fitness centre? " => 'Yes'), ) ); $result = $client->__soapCall("CreateDraftLead", array($data)); var_dump($result); 

It also seems that you are not providing all the necessary information, such as Gender , etc., you should also check this out.

+6
source

You can use "0" or intval (false)

 <?php $client = new SoapClient("http://demo/demo.asmx?wsdl", array('trace' => 1, "exception" => 0)); $data = array( 'formId' => 1, 'LocationId' => 1, 'FirstName' => 'test', 'LastName' => 'test', 'MobilePhone' => 11111111, 'email' => ' test@test.com ', 'AllowEmail' => "0", 'Region' => 'HK', 'LeadSourceId' => 11, 'Questions' => array( "Question" => array("AgeGroup" => 10), "Question" => array("Gender" => 1), "Question" => array("Remarks" => 'test'), "Question" => array("Are you currently a member of any yoga or fitness centre? " => 'Yes'), ) ); $result = $client->__soapCall("CreateDraftLead", array($data)); var_dump($result); 

OR

 <?php $client = new SoapClient("http://demo/demo.asmx?wsdl", array('trace' => 1, "exception" => 0)); $data = array( 'formId' => 1, 'LocationId' => 1, 'FirstName' => 'test', 'LastName' => 'test', 'MobilePhone' => 11111111, 'email' => ' test@test.com ', 'AllowEmail' => intval(false), 'Region' => 'HK', 'LeadSourceId' => 11, 'Questions' => array( "Question" => array("AgeGroup" => 10), "Question" => array("Gender" => 1), "Question" => array("Remarks" => 'test'), "Question" => array("Are you currently a member of any yoga or fitness centre? " => 'Yes'), ) ); $result = $client->__soapCall("CreateDraftLead", array($data)); var_dump($result); 
+3
source

I would try another trick to send logical data to your service:

 // most probably a solution 'AllowEmail' => new \SoapVar('true', XSD_STRING, 's:boolean') // or less probably solution, but still possible I guess 'AllowEmail' => new \SoapVar('true', XSD_BOOLEAN, 's:boolean') 

I assume this is a way to do this, since when you try to send 0|1|true|false , it returns a wierd error without such COLUMN.

2) means minOccurs = '1' means should provide? as verified, can ignore the field, and the server still returns success

I think so. But he still remains on the implementation side. I integrated the API once with the WSDL border away from what you could do with it.

+3
source

All Articles