|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47021 SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked"
Submitted: 2009-01-06 16:28 UTC Modified: 2009-04-16 10:56 UTC
Avg. Score:4.5 ± 0.8
Reproduced:46 of 46 (100.0%)
Same Version:28 (60.9%)
Same OS:29 (63.0%)
From: daniel dot gorski at develnet dot org Assigned:
Status: Open Package: SOAP related
PHP Version: 5.3CVS-2009-01-06 (CVS) OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-01-06 16:28 UTC] daniel dot gorski at develnet dot org
The \SoapClient (and probably the \SoapServer) stumble over WSDL files that are delivered via HTTP in chunks, carrying the HTTP response header "Transfer-Encoding: chunked".

Reproduce code:
$sc = \SoapClient('http://any.wsdl/that/is/delivered/in/chunks');

Expected result:
No error, intantiation and initialization of the \SoapClient object.

Actual result:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from [URL]: Start tag expected, '<' not found in [FILE]


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-22 15:35 UTC] ml at x-net dot be
I can confirm this bug. I tried avoiding the chunking in Apache by using mod_deflate, but the PHP SOAP client probably doesn't send an Accept-Encoding header with gzip in it.
 [2009-01-26 10:54 UTC] giovanni at giacobbi dot net
Please see related discussion:

See also bug report #43069 which actually caused this bug.
 [2009-04-16 10:34 UTC]
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
Thank you for the report, and for helping us make PHP better.

 [2009-04-16 10:56 UTC]
This was fixed by introducing an 'dechunk' stream filter, see

 [2009-05-17 05:18 UTC] shadda at gmail dot com
I ran into this bug today myself, and after having compiled the latest snapshot as of 8:00pm CST 2009-05-16 I am still experiencing this error.
 [2010-03-03 12:26 UTC] pcdinh at gmail dot com
Have you tried to recompile PHP with --without-curlwrapper? I solved my case.
 [2010-08-17 19:14 UTC] n dot engyozov at taxundo dot com
I can confirm the problem is still present in my PHP version 5.3.3 even after recompiling with changes made by Dmitry and with disabled curlwrapper. The problem breaks wsdls from yahoo i google APIs.
 [2012-05-16 15:45 UTC] gbaudoin at gmail dot com
Workaround : Use a stream context specifying the protocol 1.0 of HTTP :

$opts = array('http' => array('protocol_version' => '1.0'));
$context = stream_context_create($opts);
$this->client = new SoapClient($wsdl, array('stream_context' => $context));
 [2016-03-10 17:07 UTC] rowan dot collins at gmail dot com
After much head-scratching, I found the bug in the auto-decoding, which is actually independent of the SOAP wrapping, and occurs here:

The check looks for the exact line "Transfer-Encoding: chunked", but the number of spaces after the colon is arbitrary; thus any implementation that returns "Transfer-Encoding:  chunked" will not activate the "dechunk" filter.

You can reproduce this by pointing at an offending server with any stream wrapped function and enabling HTTP/1.1 (which is the default for SOAPClient, but not elsewhere):

$http_1_1_ctx = stream_context_create(["http" => ["protocol_version" => "1.1", "header" => "Connection: Close"]]);
file_get_contents($url, false, $http_1_1_ctx);
 [2016-03-10 17:17 UTC] rowan dot collins at gmail dot com
To test using the built-in web server:

# create file header-test.php
$spaces = str_repeat(' ', $_GET['s']);
echo "5\nHello\n0\n";

# Run server
php -S localhost:8080 header-test.php &

# Compare output with 1 vs 2 spaces

$http_1_1_ctx = stream_context_create(["http" => ["protocol_version" => "1.1", "header" => "Connection: Close"]]);
// Reports 'Hello', hides Transfer-Encoding header:
file_get_contents('http://localhost:8080/?s=1', false, $http_1_1_ctx);
// Reports raw chunk data, shows Transfer-Encoding header:
file_get_contents('http://localhost:8080/?s=2', false, $http_1_1_ctx);
 [2016-05-09 21:06 UTC] rowan dot collins at gmail dot com
I have submitted a Pull Request to make this detection handle any number of spaces in the HTTP header:

Hopefully this will fix remaining instances of this bug.
PHP Copyright © 2001-2016 The PHP Group
All rights reserved.
Last updated: Tue Oct 25 06:01:41 2016 UTC