php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62378 PHP incorrectly encodes null values in SOAP
Submitted: 2012-06-20 23:24 UTC Modified: 2018-12-14 15:43 UTC
Votes:10
Avg. Score:4.1 ± 0.9
Reproduced:7 of 8 (87.5%)
Same Version:4 (57.1%)
Same OS:2 (28.6%)
From: webmaster at guestwho dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.3.14 OS: FreeBSD 8.3-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at guestwho dot com
New email:
PHP Version: OS:

 

 [2012-06-20 23:24 UTC] webmaster at guestwho dot com
Description:
------------
This is a duplicate of #41745 but that's been stuck on "No Feedback" since 2007, so I thought I'd re-post.

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.

Test script:
---------------
---------------
$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>

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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-21 18:28 UTC] seth at sethmatics dot com
Not sure what version of PHP your using, but my version of PHP is properly setting 
the xsi:nil on NULL values. I found this bug while searching for issue with 
"disappearing nodes when value is null".
 [2013-06-18 14:47 UTC] koblavino at gmail dot com
Please, can somebody tell me in which PHP version we dont get this problem?
 [2017-07-25 03:33 UTC] peter_liang at vtech dot com
Please see if the solution in #74984 addresses this issue.
 [2018-11-04 14:01 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-11-04 14:01 UTC] cmb@php.net
I cannot reproduce the reported behavior.  If anybody still can
with any of the actively supported PHP versions[1], please provide
the used WSDL document.

[1] <http://php.net/supported-versions.php>
 [2018-11-18 22:43 UTC] cmb@php.net
-Status: Feedback +Status: No Feedback
 [2018-11-18 22:43 UTC] cmb@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2018-12-14 10:06 UTC] pedro dot fernandez at editeformacion dot com
I'm experiencing the same issue. Null values are not encoded as xsi:nil="true".
My PHP version is 5.6.31 and the wsdl is placed here:
https://www.sepe.es/contenidos/personas/formacion/centros_formacion/pdf/ProveedorCentroTFWS_20140619.wsdl
 [2018-12-14 11:21 UTC] cmb@php.net
-Status: No Feedback +Status: Open
 [2018-12-14 15:43 UTC] cmb@php.net
-Status: Assigned +Status: Open
 [2018-12-14 15:43 UTC] cmb@php.net
cmb@ENTERPRISE:/mnt/c/Users/cmb/php-dev/php-src$ wget -O ../62378.wsdl https://w
ww.sepe.es/contenidos/personas/formacion/centros_formacion/pdf/ProveedorCentroTF
WS_20140619.wsdl
--2018-12-14 16:40:58--  https://www.sepe.es/contenidos/personas/formacion/centros_formacion/pdf/ProveedorCentroTFWS_20140619.wsdl
Resolving www.sepe.es (www.sepe.es)... 195.57.139.164
Connecting to www.sepe.es (www.sepe.es)|195.57.139.164|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42232 (41K) [text/plain]
Saving to: ‘../62378.wsdl’

../62378.wsdl       100%[===================>]  41.24K  --.-KB/s    in 0.03s

2018-12-14 16:40:58 (1.21 MB/s) - ‘../62378.wsdl’ saved [42232/42232]

cmb@ENTERPRISE:/mnt/c/Users/cmb/php-dev/php-src$ cat ../62378.php
<?php

$soap = new SoapClient(__DIR__ . '/62378.wsdl', array('trace' => true));
$soap->operation(null);

echo $soap->__getLastRequest();
cmb@ENTERPRISE:/mnt/c/Users/cmb/php-dev/php-src$ sapi/cli/php ../62378.php

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://schemas.xmlsoap.org/ws/2004/09/policy' in /mnt/c/Users/cmb/php-dev/62378.php:3
Stack trace:
#0 /mnt/c/Users/cmb/php-dev/62378.php(3): SoapClient->SoapClient('/mnt/c/Users/cm...', Array)
#1 {main}
  thrown in /mnt/c/Users/cmb/php-dev/62378.php on line 3

Also note that 5.6 is no longer supported.
 [2018-12-14 15:43 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon May 20 10:01:27 2019 UTC