繁体   English   中英

PHP Soap客户端调用

[英]PHP Soap client call

我很绝望。 我正在尝试像这样的xml从php调用soap请求

<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>

我正在尝试类似的操作,但是我不知道如何通过php soap客户端模仿该xml请求。

    $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:\n" . $client->__getLastRequest() . "\n";
    /* Print webservice response */
    var_dump($response);
}

但是我仅收到此消息:服务器无法处理请求。 --->未经身份验证的属性

感谢您的任何帮助

我强烈建议您使用PackageGenerator,就像在WSDL中正确声明了标头一样,那么在发送请求之前,您将具有适当的方法对其进行设置。 每个参数都由生成的类表示,例如适当的ServiceType类中的每个操作。

暂无
暂无

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

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