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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么