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>';
?>

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

检查登录功能检查用户凭据是否有效。 肥皂值为 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"
    )
);