PHP SoapClient - 带有长整数的 SOAP 请求

标签 php soap long-integer soap-client

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

这是我需要调用的 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 代码,但转换为 float 似乎可行。

$soapVar = (float)'3599569593';

或者当您将其作为参数发送时。

关于PHP SoapClient - 带有长整数的 SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19228213/

相关文章:

php - 是否可以访问同一数组中的键 - PHP?

php - 使用 regex/php 读取引号内的文本

javascript - 通过 HTTPS 发出 SOAP 请求 - Javascript, Phonegap

algorithm - 在精度损失后从 int 中恢复 long

Java:指定long时L和l(小写L)有区别吗?

Django:用于 MongoDB 的长字段 (BigIntegerField)

php - 从sql中获取信息并将其放入表单中

php - 为什么我的变量会发生这种情况?

ios - SOAP 和 iOS : Any guidance?

java - SoapUI 执行涉及 XSD 的 WSDL 时出现问题,其中包括 (<xsd :include/>) another XSD