php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43045 SOAP encoding violation on "INF" for type double/float
Submitted: 2007-10-19 21:04 UTC Modified: 2008-10-01 11:06 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:3 (60.0%)
From: nick at attask dot com Assigned: dmitry
Status: Closed Package: SOAP related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID:
 [2007-10-19 21:04 UTC] nick at attask dot com
Description:
------------
Bug 39815 (http://bugs.php.net/bug.php?id=39815) reported a locale-sensitive error in decoding SOAP double values.  The result was a fix which it seems has broken support for special double values represented by strings, such as:

INF
-INF
NAN

When a SOAP response sends one of these values (INF in the example below) with type "double" or "float" in versions 5.2.1 and later, the result is a SoapFault of "Violation of Encoding rules", when it should successfully parse the result as a PHP float of value "INF".

This change happened in 5.2.1 in file ext/soap/php_encoding.c.  Versions 5.2.0 and older correctly produce the "Expected Result" below. 

Reproduce code:
---------------
<?php
if (!$_REQUEST['soap-server']) {
	try {
		$client = new SoapClient(NULL, array(
			"location" => $_SERVER['SCRIPT_URI'] . "?soap-server=1",
			"uri"      => 'urn:TestSOAP',
			"style"    => SOAP_RPC,
			"use"      => SOAP_ENCODED
			));
		$response = $client->__soapCall('test', array());
		var_dump($response->doubleInfinity);
	}
	catch (SoapFault $e) {
		print_r($e);
	}
} else {
	header('Content-Type: text/xml; charset=utf-8');
	?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><testResponse xmlns="urn:TestSOAP"><s-gensym3><doubleInfinity xsi:type="xsd:double">INF</doubleInfinity></s-gensym3></testResponse></soap:Body></soap:Envelope><?php
}
?>

Expected result:
----------------
float(INF)

Actual result:
--------------
SoapFault Object
(
    [message:protected] => SOAP-ERROR: Encoding: Violation of encoding rules
...
    [faultstring] => SOAP-ERROR: Encoding: Violation of encoding rules
    [faultcode] => Client
    [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-30 19:00 UTC] jani@php.net
I get the same problem here, sample code available via email if requied. Basically: WSDL says data is double, return NaN / INF -> this annoying error about "violation". Yet the same stuff works with other languages..
 [2008-09-30 19:22 UTC] jani@php.net
Might be caused by the optimization patch for zend_operators.h is_numeric_string() func which seems to nuke the inf/nan handling totally out of the func..
 [2008-09-30 19:45 UTC] jani@php.net
workaround: get local copy of the wsdl file and change all double types to string. :)
 [2008-10-01 08:43 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2008-10-01 11:06 UTC] jani@php.net
Tested latest CVS of PHP_5_2 and it works now. Thanks Dmitry!
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 04:02:11 2014 UTC