|  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
Avg. Score:3.9 ± 1.0
Reproduced:8 of 10 (80.0%)
Same Version:4 (50.0%)
Same OS:2 (25.0%)
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-06-20 23:24 UTC] webmaster at guestwho dot com
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));

echo $soap->__getLastRequest();

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="NAMESPACE"
<paramName xsi:nil="true"/>

Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="NAMESPACE">


Add a Patch

Pull Requests

Add a Pull Request


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]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-11-04 14:01 UTC]
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] <>
 [2018-11-18 22:43 UTC]
-Status: Feedback +Status: No Feedback
 [2018-11-18 22:43 UTC]
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:
 [2018-12-14 11:21 UTC]
-Status: No Feedback +Status: Open
 [2018-12-14 15:43 UTC]
-Status: Assigned +Status: Open
 [2018-12-14 15:43 UTC]
cmb@ENTERPRISE:/mnt/c/Users/cmb/php-dev/php-src$ wget -O ../62378.wsdl https://w
--2018-12-14 16:40:58--
Resolving (
Connecting to (||: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

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

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 '' 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]
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2024-06-01 16:58 UTC]
The sample wsdl provided in the comments (accessible using uses use="literal". If I were to put use="encoded" then I get the type attribute.
Reading tells me

> If use is literal, then each part references a concrete schema definition using either the element or type attribute.

So that means we should indeed add the type attribute in this case, but my knowledge here is limited. I'm mainly writing this down for future me.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 23:01:29 2024 UTC