php - 使用 PHP 调用特定服务的 SOAP 方法

标签 php soap

很抱歉不得不这样做,但我没有得到运行这个特定网络服务的人的喜爱。我以前从未使用过 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 技巧从某处获取该信息?

最佳答案

尝试

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

您必须根据 XML 序列化 DateFromDateTo 中的日期时间值以及 PromotionalRates 中的 bool 值架构规范:

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

关于php - 使用 PHP 调用特定服务的 SOAP 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/777346/

相关文章:

php - 在 PHP 中读取 PDF 元数据

php - 从 php 访问 python 脚本中的函数

c# - PayPal SOAP API 响应需要手动解析

java - 在具有 Web 安全性的 HTTPS 上调用 SOAP 服务时出现异常

web-services - Apache CXF + SpringBoot : Can I publish multiple endpoints for one SOAP web-service?

javascript - 如何使用一个删除按钮而不是每行中的删除按钮删除特定行?

php - 如何在编辑页面显示记录?

php - wpdb SQL 'username' 错误中的未知列 'where clause'

php - 从偏态正态分布生成随机数

wcf - 从soapUI到WCF的WS-Security - 绑定(bind)和配置