SOAP PHP 5: passing big integers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    SOAP PHP 5: passing big integers

    Hello,

    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:l ong">20000</personID>


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

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

    Thanks,
    Paul
  • Martin H. Kristiansen

    #2
    Re: SOAP PHP 5: passing big integers

    "Paul" <paulhmonkYOURP ANTS@hotmail.co m> wrote in message news:<i_x_c.305 410$M95.33925@p d7tw1no>...[color=blue]
    > Hello,
    >
    > 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:l ong">20000</personID>
    >
    >
    > But this doesn't:
    > $this->personID = new SoapVar("276012 7000", XSD_LONG);
    > <personID xsi:type="xsd:l ong">-1534840296</personID>
    >
    > Any ideas how I could fix this (other than building the SOAP envelope
    > manually)?[/color]

    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.

    Cheers
    Martin

    Comment

    Working...