【问题标题】:PHP SoapClient - SOAP request with long integerPHP SoapClient - 带有长整数的 SOAP 请求
【发布时间】:2013-10-07 15:02:02
【问题描述】:

我在处理大整数值和 PHP SoapClient 类时遇到了一些问题。似乎 SoapClient 无法处理大数值 - 即使 SOAP 参数类型是“xsd:long”,我也无法发送大于 PHP_INT_MAX (2147483647) 的数字。

这是我需要调用的 SOAP 方法的 WSDL 规范:

<message name="doFinishItemRequest">
  <part name="session-handle" type="xsd:string"/>
  <part name="finish-item-id" type="xsd:long"/>
  <part name="finish-cancel-all-bids" type="xsd:int"/>
  <part name="finish-cancel-reason" type="xsd:string"/>
</message>

finish-item-id 的值为"3599569593"(从 MySQL BIG INT 类型加载的字符串)。但似乎 SoapClient 将其转换为 32 位整数。

SOAP 信封如下所示:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:AllegroWebApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:doFinishItem>
      <session-handle xsi:type="xsd:string">8a5d261806a4b60a283dabdb092e061a2d46e5d80bcc68bb00_56</session-handle>
      <finish-item-id xsi:type="xsd:long">2147483647</finish-item-id>
      <finish-cancel-all-bids xsi:type="xsd:int">0</finish-cancel-all-bids>
      <finish-cancel-reason xsi:type="xsd:string"></finish-cancel-reason>
    </ns1:doFinishItem>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

它将 3599569593 更改为 2147483647,并且 SOAP 服务告诉我我传递了错误的 ID。

有解决方法吗? (我无法更改 WSDL。)

【问题讨论】:

    标签: php soap long-integer soap-client


    【解决方案1】:

    您没有显示任何 PHP 代码,但转换为 float 似乎可行。

    $soapVar = (float)'3599569593';
    

    或者当你作为参数发送时。

    【讨论】:

    • PHP Soap 扩展过去只支持 32 位整数,即使在 64 位系统上也是如此。情况可能仍然如此。
    • 在 Win7 + PHP5.5 上为我工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 2012-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多