Why am I getting this error "falseObject link not set to object instance". when i invoke an operation in my web service

I have a web service and I call one of my operations using the SOAP client in PHP, but all I get is ["any"]=> string(120) "falseObject reference not set to an instance of an object.

I want to know that something is wrong in my code because I believe that my connection to the web service is% 100.

Is there something wrong with the xml line I'm creating?

Operation:

 <wsdl:operation name="XmlIslet"> <wsdl:input message="tns:XmlIsletSoapIn"/> <wsdl:output message="tns:XmlIsletSoapOut"/> </wsdl:operation> 

and a description of its parameters in WSDL:

 <wsdl:types> <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> <s:element name="XmlIslet"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="xmlIslem"> <s:complexType> <s:sequence> <s:any/> </s:sequence> </s:complexType> </s:element> <s:element minOccurs="0" maxOccurs="1" name="xmlYetki"> <s:complexType> <s:sequence> <s:any/> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element> <s:element name="XmlIsletResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="XmlIsletResult"> <s:complexType mixed="true"> <s:sequence> <s:any/> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element> </s:schema> </wsdl:types> 

My soap and PHP code:

 <?php $username = "username"; $password = "password"; $xmlString = "<Firmalar></Firmalar>"; function strtoXmldocument($str) { $dom = new DOMDocument(); $str1 = $str; return $dom->loadXML($str1); } function stringToDataset($xmlString, $username, $password) { $client = new SoapClient('http://1.1.1.1/WSTEST/Service.asmx?WSDL'); $response = $client->XmlIslet(strtoXmldocument($xmlString)->documentElement, strtoXmldocument("<Kullanici><Adi>" .$username. "</Adi><Sifre>" .$password. "</Sifre></Kullanici>")->documentElement); var_dump($response); } stringToDataset($xmlString, $username, $password); ?> 

The SOAP request is as follows:

 POST /WSTEST/Service.asmx HTTP/1.1 Host: 1.1.1.1 Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <XmlIslet xmlns="http://tempuri.org/"> <xmlIslem>xml</xmlIslem> <xmlYetki>xml</xmlYetki> </XmlIslet> </soap12:Body> </soap12:Envelope> 

SOAP answer:

 HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <XmlIsletResponse xmlns="http://tempuri.org/"> <XmlIsletResult>xml</XmlIsletResult> </XmlIsletResponse> </soap12:Body> </soap12:Envelope> 

vardump output:

 usernamepasswordobject(stdClass)#2 (1) { ["XmlIsletResult"]=> object(stdClass)#3 (1) { ["any"]=> string(120) "falseObject reference not set to an instance of an object." } } 

EDIT: I tried to get the xml request using htmlentities($client->__getLastRequest()) , which shows me the empty body of my request:

 ========= REQUEST ========== string(292) "<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"> <SOAP-ENV:Body> <ns1:XmlIslet> <ns1:xmlIslem/> <ns1:xmlYetki/> </ns1:XmlIslet> </SOAP-ENV:Body> </SOAP-ENV:Envelope> " 
+5
source share
1 answer

Most likely you are talking to a .NET service. This error message is basically a "variable undefined" message.

The WSDL file says that the request must contain two objects: xmlIslem and xmlYetki. But their internal structure is not properly defined, it can be "any." This, however, does not mean that the removal of the web service does not expect you to provide some data. It looks like you need to pass some data that is not there, hence the error.

I would contact a web service provider and request documentation or specific sample requests.

0
source

Source: https://habr.com/ru/post/1266589/


All Articles