简体   繁体   English

当我在webservice中调用一个操作时,为什么会出现此错误“falseObject reference not set to a object of object。”

[英]Why do I get this error “falseObject reference not set to an instance of an object.” when I call an operation in my webservice

I have a web service and I am calling one of its operations using SOAP client in PHP but all I get is this ["any"]=> string(120) "falseObject reference not set to an instance of an object. 我有一个Web服务,我在PHP中使用SOAP客户端调用其中一个操作,但我得到的是这个["any"]=> string(120) "falseObject reference not set to an instance of an object.

I want to know is there anything wrong in my code because I belive that my connection to the web service is %100 working. 我想知道我的代码中有什么问题,因为我相信我与Web服务的连接是%100工作。

Is there anything wrong in the xml string that I am creating ? 我正在创建的xml字符串有什么问题吗?

The operation is : 操作是:

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

and the description of its parameters in the WSDL is : 并且它在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 is the following : 我的soap和PHP代码如下:

<?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 the following: SOAP请求如下:

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>

The SOAP response : SOAP响应:

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 is : vardump输出是:

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 request xml using htmlentities($client->__getLastRequest()) which shows me an empty body of my request : 编辑:我试图使用htmlentities($client->__getLastRequest())获取请求xml,它显示了我的请求的空体:

========= 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> "

You're most likely communicating with a .NET service. 您最有可能与.NET服务进行通信。 This error message is basically a "variable undefined" message. 此错误消息基本上是“变量未定义”消息。

The WSDL file says, you request must contain two entities: xmlIslem and xmlYetki. WSDL文件说,您请求必须包含两个实体:xmlIslem和xmlYetki。 But their internal structure is not properly defined, it can be "any"-thing. 但是它们的内部结构没有被恰当地定义,它可以是“任何”的东西。 This, however, doesn't mean, that the remove web service doesn't expect you to provide some data. 但是,这并不意味着删除Web服务不希望您提供某些数据。 It looks like you need to pass some data, which you don't, hence the error. 看起来你需要传递一些你不需要的数据,因此就是错误。

I would contact the web service provider and requested the documentation or specific request examples. 我会联系Web服务提供商并请求文档或特定请求示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你调用的对象是空的。 请检查我的代码 - Object reference not set to an instance of an object. please review my code 解决SoapClient错误:“对象引用未设置为对象的实例。” - Solve SoapClient error: “Object reference not set to an instance of an object.” 尝试SOAP调用时,对象引用未设置为对象错误的实例 - Object reference not set to an instance of an object error when trying SOAP call 当我在对象上调用函数时,为什么在非对象上出现此函数调用错误? - Why do I get this function call error on an non-object when I am calling a function on an object? 连接到.NET服务器时,PHP nuSoap问题:“对象引用未设置为对象的实例。” - PHP nuSoap issue when connecting to a .NET server: “Object reference not set to an instance of an object.” 为什么在尝试解析这个 json 对象时会出错? - Why do I get error when trying to parse this json object? 为什么会出现错误:“在不在对象上下文中时使用$ this ...” - Why do I get the error: “Using $this when not in object context in…” 使用nusoap调用网络服务时出现错误 - i got error when call webservice with nusoap 为什么会出现此错误-错误:在非对象上调用成员函数find()-Cake 2.0 - Why do I get this error - Error: Call to a member function find() on a non-object - Cake 2.0 为什么我会得到以下错误消息:断言响应对象(...)是“ RedirectResponse”类的实例? - Why do I get the error Failed asserting that Response Object (…) is an instance of class “RedirectResponse”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM