编程语言
首页 > 编程语言> > PHP SoapClient-具有长整数的SOAP请求

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

作者:互联网

我在使用大整数值和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代码,但强制转换为float似乎可行.

$soapVar = (float)'3599569593';

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

标签:long-integer,soap-client,php,soap
来源: https://codeday.me/bug/20191122/2061583.html