I use the SoapClient
class for SOAP interactions. When a SOAP response contains long integer, PHP converts it to the scientific notation. How can I get such value and use it later in a SOAP request?
I can't use gmp, the value is cast to float before I can access it. gmp_init(): Unable to convert variable to GMP - wrong type
also see: http://arstechnica.com/civis/viewtopic.php?t=100615
$wsld = 'http://example.com?wsdl';
$soap = new \SoapClient($wsld);
$result=$soap->foo();
echo $result->return->id; // echo 1.1122233344456E+14 instead of 111222333444555;
Perhaps you can make a local copy of the WSDL and change the datatype of the field you are having trouble with to a string.
That has the disadvantage that you will have to track changes to the XML but it's the path of least resistance that will provide you a more immediate solution.
As an alternative, more robust in a way, looking at the SoapClient documentation there is the typemap option that you can use.
The typemap option is an array of type mappings. Type mapping is an array with keys type_name, type_ns (namespace URI), from_xml (callback accepting one string parameter) and to_xml (callback accepting one object parameter).
Perhaps this other answer might help you with using the typemap. Without knowing your schema it's hard to help you with source code but the example may be applicable to you.
Here is a verbatim copy of the source code posted in the answer above:
function to_long_xml($longVal) {
return '<long>' . $longVal . '</long>';
}
function from_long_xml($xmlFragmentString) {
return (string)strip_tags($xmlFragmentString);
}
$client = new SoapClient('http://acme.com/products.wsdl', array(
'typemap' => array(
array(
'type_ns' => 'http://www.w3.org/2001/XMLSchema',
'type_name' => 'long',
'to_xml' => 'to_long_xml',
'from_xml' => 'from_long_xml',
),
),
));