php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41745 PHP incorrectly encodes null values in SOAP
Submitted: 2007-06-20 02:40 UTC Modified: 2007-06-29 01:00 UTC
Votes:21
Avg. Score:4.9 ± 0.3
Reproduced:20 of 20 (100.0%)
Same Version:6 (30.0%)
Same OS:14 (70.0%)
From: jasper at digiweb dot co dot nz Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID: None
 [2007-06-20 02:40 UTC] jasper at digiweb dot co dot nz
Description:
------------
When null is provided for a SOAP parameter or the field of an object passed as a SOAP parameter, PHP incorrectly encodes the parameter as being empty (e.g. object with all null fields, or empty string) which is different from an actual null. This breaks access to real-world web services.

Reproduce code:
---------------
$soap = new SoapClient('/path/to/wsdl', array('trace' => true));
$soap->operation(null);

echo $soap->__getLastRequest();

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="NAMESPACE"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:operation>
<paramName xsi:nil="true"/>
</ns1:operation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

== OR ==

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="NAMESPACE">
<SOAP-ENV:Body>
<ns1:operation/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="NAMESPACE">
<SOAP-ENV:Body>
<ns1:operation>
<paramName/>
</ns1:operation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-09-25 11:00 UTC] fredrik at wangel dot net
Verified on PHP 5.2.4. Reported bug is still unsolved. In addition, NULL values in array responses are also handled incorrectly.

I have prepared a bug41745.phpt file (based on bug39815.phpt) that will test for the above cases and two other cases that are currently working in PHP 5.2.4 (included for regression testing).

Should I attach the code in a comment or send it directly to someone with CVS write access? In the meantime, get it from http://wangel.net/fredrik/php/bugs/bug41745.phpt
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 06:01:28 2024 UTC