douwei7203 2018-07-10 15:32
浏览 63

PHP Soap客户端调用

I am desperate. I am trying to call soap request from php like this xml

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:hot="http://hotelconcepts.com/">   <soapenv:Header>
  <hot:Authentication>
     <!--Optional:-->
     <hot:User>?</hot:User>
     <!--Optional:-->
     <hot:Password>?</hot:Password>
     <!--Optional:-->
     <hot:CrsProperty>?</hot:CrsProperty>
     <!--Optional:-->
     <hot:VendorId>?</hot:VendorId>
     <!--Optional:-->
     <hot:Version>?</hot:Version>
  </hot:Authentication>   
</soapenv:Header>   
<soapenv:Body>
  <hot:CwiPackageAvailabilityDetails>
     <!--Optional:-->
     <hot:PropertyCode>?</hot:PropertyCode>
     <!--Optional:-->
     <hot:Packages>
        <!--Zero or more repetitions:-->
        <hot:string>?</hot:string>
     </hot:Packages>
     <hot:StartDate>?</hot:StartDate>
     <hot:EndDate>?</hot:EndDate>
     <!--Optional:-->
     <hot:Adults>0</hot:Adults>
     <!--Optional:-->
     <hot:Children>0</hot:Children>
     <!--Optional:-->
     <hot:Infants>0</hot:Infants>
     <!--Optional:-->
     <hot:Nights>0</hot:Nights>
  </hot:CwiPackageAvailabilityDetails>

I am trying something like this, but i don´t know how to imitate this xml request by php soap client.

    $client = new SoapClient($this->wsdl);

    $headers = array(
        "Authentication" => array(
            "User" => $this->user,
            "Password" => $this->pass,
            "CrsProperty" => $this->crsProperty
        )
    );

    $client->__setSoapHeaders($headers);

    /* Set your parameters for the request */
    $params = array(
        "User" => $this->user,
        "Password" => $this->pass,
        "CrsProperty" => $this->crsProperty,
        "PropertyCode" => $this->propertyCode,
        "StartDate" => $startDate,
        "EndDate" => $endDate,
        "Adults" => $adults,
        "Children" => $children,

    );
    try {
        /* Invoke webservice method with your parameters, in this case: Function1 */
        $response = $client->__soapCall("CwiPackageAvailabilityDetails", array($params, $headers));
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
        echo "REQUEST:
" . $client->__getLastRequest() . "
";
    /* Print webservice response */
    var_dump($response);
}

But i get only this message: Server was unable to process request. ---> Not authenticated for property

Thank you for any help

  • 写回答

1条回答 默认 最新

  • doufei3152 2018-07-12 14:13
    关注

    I would strongly advise you to use the PackageGenerator as if the header is well declared in the WSDL, then you'll have the appropriate method to set it before sending the request. Every parameter is represented by a generated class such as every operation within a proper ServiceType class.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记