繁体   English   中英

PHP SOAP错误消息-System.NullReferenceException:对象引用未设置为对象的实例

[英]PHP SOAP Errormessage - System.NullReferenceException: Object reference not set to an instance of an object

我有这个问题,目前我正在学习肥皂,并使用PHP中http://vanillatours.com的 wsdl开发在线预订系统

它们需要的标头是soapactioncharset 我已经包括了,根据需要更改肥皂性。 例如,当前正在尝试执行checklogin()函数。

我试过print_r($client->__getFunctions())看看是否附加了函数!

我尝试了print_r($client)来查看标头是否已附加

问题是我不知道为什么会收到此错误消息。

System.NullReferenceException: Object reference not set to an instance of an object.
at WcfService.Wcf.CheckLogin(LoginHeaderWcfRequest loginHeader)

尝试了一切! 我对肥皂非常陌生,任何帮助将不胜感激。 也许我没有正确使用数据“请求”?

谢谢!

<?php 

    $wsdl = "http://xmltest.vanillatours.com/Wcf.svc?wsdl";
    $client = new SoapClient($wsdl);

    $data = array(
     "request" => array(
      "a:AgentId" => blabla,
      "a:Language" => "En",
      "a:Password" => "blabla",
      "a:Username" => "blabla"
     )
    );

    $header = array();

    $header[] = new SoapHeader('http://tempuri.org/IWcf/CheckLogin','SOAPAction');
    $header[] = new SoapHeader('text/xml; charset=utf-8','ContentType');

    $client->__setSoapHeaders($header);


    $response = $client->__soapCall('CheckLogin', $data);

    echo '<pre>';


    print_r($client->__getFunctions()); // functions seem to show pretty well

    echo '<br>------------------------------------------------------<br><br>';

    print_r($client); // headers are attached 

    echo '<br>------------------------------------------------------<br><br>';

    print_r($response); // errormessage, can not figure out what is the problem.

    echo '</pre>';
?>

这是如何从他们的文档中进行连接,如果可以使用其他方法,也将不胜感激。

CheckLogin函数检查用户凭据是否有效。 SOAPAction值为http://tempuri.org/IWcf/CheckLogin

3.1.2请求

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
 <s:Body> 

<CheckLogin xmlns="http://tempuri.org/"> 
<loginHeader xmlns:a="http://schemas.datacontract.org/2004/07/WcfService" 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
 <a:AgentId>Your Agent Id</a:AgentId> 
 <a:Language>Your preferred language</a:Language> 
 <a:Password>Your Password</a:Password> 
 <a:Username>Your username</a:Username> 
 </loginHeader> 
 </CheckLogin> 
 </s:Body> 
 </s:Envelope>

$data的结构不正确。 它应该是:

$data = array(
    "loginHeader" => array(
         "AgentId" => blabla,
         "Language" => "En",
         "Password" => "blabla",
         "Username" => "blabla"
    )
);

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM