douhan1860 2013-10-09 11:19
浏览 70

PHP SOAP Errormessage - System.NullReferenceException:未将对象引用设置为对象的实例

I have this problem, currently I am learning soap and developing online booking system with wsdl of in PHP

their required headers are soapaction, and charset. which I have included, soapaction changes for desired request. for example, currently trying to do checklogin() function.

I tried print_r($client->__getFunctions()) to see if functions are attached, they are!

I tried print_r($client) to see if headers are attached and they are

the problem is that I can not figure out why I get this errormessage.

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

Tried everything! I am very new with soap and any help would be appreciated. maybe I am not using correctly data "request"?

thank you!


    $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('','SOAPAction');
    $header[] = new SoapHeader('text/xml; charset=utf-8','ContentType');


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

this is how to connect from their documentation, if I can use other method, would appreciate too.

CheckLogin function checks the user credentials is valid or not. SOAPAction value is

3.1.2 Request

 <s:Envelope xmlns:s=""> 

<CheckLogin xmlns=""> 
<loginHeader xmlns:a="" 
 <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> 
  • 写回答

1条回答 默认 最新

  • doulai8405 2013-10-09 11:45

    The structure of $data is not right. It should be:

    $data = array(
        "loginHeader" => array(
             "AgentId" => blabla,
             "Language" => "En",
             "Password" => "blabla",
             "Username" => "blabla"
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 Evil-droid生成的APK手机已经下载但无法建立任务
    • ¥25 c语言韩信点兵的变式
    • ¥15 怎么根据书上的例子完成这个问题呢?
    • ¥15 ECharts 增加Zoom,整行包括右边的Text一起滑动
    • ¥15 关于网上一个easyx制作的见缝插针小游戏(c++)
    • ¥15 开地址法双散列函数处理碰撞
    • ¥15 想问一下这个是什么情况 虚拟机Linux打不开了
    • ¥15 联通光猫掉注册了怎么重新注册上去
    • ¥15 关于unity开发steamvr程序遇到的问题
    • ¥60 求tc downloader的下载方式