【问题标题】:Calling a SOAP method with PHP for a specific service使用 PHP 为特定服务调用 SOAP 方法
【发布时间】:2009-04-22 13:59:39
【问题描述】:

很抱歉不得不这样做,但我没有得到运行此特定网络服务的人的喜爱。我以前从未使用过 SOAP。

Here's the method I'm trying to call

这是我认为应该可以工作的代码

    public function soapTest(){

            echo "start <br />";
            use_soap_error_handler(true);
            $client = new SoapClient("https://cwi.rezexchange.com:9991/?wsdl");

                // here's the problem. What goes in the parenthesis?
            $result = $client->CwiRateDetails(????);

            echo($result);
            echo "<br /> end";

        }

现在我猜这告诉我括号应该包含什么。

POST /Service.asmx HTTP/1.1
Host: cwi.rezexchange.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://hotelconcepts.com/CwiRateDetails"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CwiRateDetails xmlns="http://hotelconcepts.com/">
      <PropertyCode>string</PropertyCode>
      <DateFrom>dateTime</DateFrom>
      <DateTo>dateTime</DateTo>
      <RatePlan>string</RatePlan>
      <RoomType>string</RoomType>
      <PromotionalRates>boolean</PromotionalRates>
    </CwiRateDetails>
  </soap:Body>
</soap:Envelope>

我猜是这样的

$result = $client->CwiRateDetails($PCode, $DateFrom, $DateTo, $RatePlan, $RoomType, false);

应该可以。但我不知道日期格式是什么,或者房间类型是什么,或者如何参考房价计划。

现在。在我和他们一起通过电子邮件发疯之前,我认为他们需要给我更多的信息是错误的吗?或者我可以使用某种 SOAP 技巧从某个地方获取该信息?

【问题讨论】:

    标签: php soap


    【解决方案1】:

    试试

    $result = $client->CwiRateDetails(array(
        'PropertyCode'     => ...,
        'DateFrom'         => ...,
        'DateTo'           => ...,
        'RatePlan'         => ...,
        'RoomType'         => ...,
        'PromotionalRates' => ...,
    ));
    

    您必须根据 XML Schema 规范序列化 DateFromDateTo 中的日期时间值以及 PromotionalRates 中的布尔值:

    • boolean: true = 'true'1false = 'false'0
    • dateTime: YYYY-MM-DDThh:mm:ssZ 表示 UTC 或 YYYY-MM-DDThh:mm:ss(+/-)hh:mm 表示当地时间,包括时区信息;时区信息是可选的

    【讨论】:

      【解决方案2】:

      日期格式实际上是 dateTime(它是一种 SOAP 格式类型)。我确信互联网上有一个将 time()(或其他)转换为 SOAP::dateTime 字段的示例。

      你需要连接的信息都在那里。也许你应该先阅读网络服务?

      【讨论】:

        【解决方案3】:

        通常它是关联数组,其中键是您在描述中找到的字段,即 CwiRateDetails 的 PropertyCode、DateFrom、DateTo 等

        应该是这样的

        $client->CwiRateDetails(array("PropertyCode"=>"sdsd","DateFrom"=>"",......))
        

        您可以在此页面上查看每个方法的详细信息:https://cwi.rezexchange.com:9991/ 只需单击程序名称,您就会看到它的参数和响应。

        【讨论】:

          【解决方案4】:

          你没有错,IMO。必须有其他 SOAP 调用来派生您需要的信息。你看过List Rate Types吗? here的方法列表呢?

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-11-13
            • 1970-01-01
            相关资源
            最近更新 更多