We have a customer that is trying to call our web service written in C# from PHP code. The web service call takes a long as parameter.
This call works fine for other customers calling from C# or Java but this customer is getting an error back from the call. I haven't debugged their specific call but I am guessing that the 64bit integer is getting truncated somehow from PHP. The customer says they are just making the web service call with a string but is there a wrapper in PHP that does type conversion. Could this be losing the number information?
Thanks for any info.
Most PHP installations won't support 64 bit integers - 32 is the max. You can check this by reading the PHP_INT_SIZE constant (4 = 32bit, 8 = 64bit) or read the PHP_INT_MAX value.
<?php
echo PHP_INT_SIZE, "\n", PHP_INT_MAX;
?>
If the web service class he is using is trying to type-convert a string representation of a 64 bit integer, then yes, it's mostly likely being truncated or converted into a float. You can sort of see this behavior with this simple test
<?php
echo intval( "12345678901234567890" );
// prints 2147483647, the max value for a 32 bit signed int.
Without knowing the details of his implementation, it's difficult to postulate on what a good solution/workaround might be.
I wrote an article regarding PHP using nuSoap to call a C# web service... Haven't yet encountered the issue with long int conversions, but I will definately be running some tests to see if I should add it into my article. Thanks, Sean http://seanmcilvenna.com/blog/7-general/24-windows-php-development
If you absolutely must take a big number like that, make it a string, and convert it to long in your web service.
This will bother your other users a little bit, but would make it more friendly to your PHP-using costumers.
PHP brutally murdered its integer support, to the point where you have no predictable way of knowing it a specific install will handle 32-bit or 64-bit integers.
The easiest way to handle this would be to expose a new endpoint that takes a string, and just cast it on your end.
For reference on PHP's epic fail:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.