SOAP PHP 5: passing big integers

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've been experimenting with PHP 5's SOAP extension and I've run into
this problem: methods that have XSD_LONG parameters fail if a big
integer is passed. Unsigned big integers are always converted to
(negative) signed integers when they are put in the SOAP message:

For example, this produces the correct result:

$this->personID = new SoapVar("20000", XSD_LONG);

SOAP result:
<personID xsi:type="xsd:long">20000</personID>

But this doesn't:
$this->personID = new SoapVar("2760127000", XSD_LONG);
<personID xsi:type="xsd:long">-1534840296</personID>

Any ideas how I could fix this (other than building the SOAP envelope


Re: SOAP PHP 5: passing big integers

Quoted text here. Click to load it

Chances are that XSD_LONG translates to a 32 bit integer. This means
that the largest positive number you can handle is 2147483647, above
which the number overflows, setting the sign bit as it does and hence
you end up with a negative number.

I'd recommend handling the IDs as strings instead.


Site Timeline