|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37054 SoapClient Error Fetching http headers
Submitted: 2006-04-12 12:51 UTC Modified: 2010-12-20 12:01 UTC
From: gijs at d1 dot nl Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5.1.3RC3 OS: Debian 3.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
17 - 7 = ?
Subscribe to this entry?

 [2006-04-12 12:51 UTC] gijs at d1 dot nl
I'm pretty experienced with PHP but this really bites me. I've created a SoapServer with PHP5's builtin SOAP extension. Unfortunatley I cannot seem to talk with it using PHP's SoapClient. I keep getting a "Error Fetching http headers" error (indicating the WebService does not respond).

On my development environment (laptop running PHP 5.1.2 on windows/ apache 2.0) I have no problems when running and connecting with the webservice (locally).

But when I put the WebService online (on a webserver) it fails.

However, only when I use PHP (SoapClient). When I'm connecting to the remote WebService using ASP.NET it does work! (

I've also tried to connect with a PHP SoapClient running on my laptop to the remote SoapServer running on the webserver (also error).

During the test sessions I've turned on logging to see if the Remote WebService receives a hit . The log file is blank when I use the PHP SoapClient (explaining the error fetching HTTP Headers).

It must be something with the SoapClient since ASP.NET can connect with it.....

-- SERVER ----
Debian 3.1 Apache 1.3 PHP 5.1.2

---- PHP Build options -----
./configure \
	--with-apxs \
	--with-curl \
	--with-curl-dir=/usr/local/lib \
	--with-java \
	--with-gd \
	--with-gd-dir=/usr/local \
	--enable-gd-native-ttf \
	--with-ttf \
	--with-freetype-dir=/usr/local/lib \
	--with-gettext \
	--with-jpeg-dir=/usr/local/lib \
	--with-kerberos \
	--with-mcrypt \
	--with-mhash \
	--with-mysql=/usr/local/mysql \
	--with-pear \
	--with-png-dir=/usr/local/lib \
	--with-libxml-dir=/usr/local/libxml \
	--with-xml2-config=/usr/local/bin/xml2-config \
	--with-xml \
	--with-zlib \
	--with-zlib-dir=/usr/local/lib \
	--with-zip \
	--with-openssl \
	--enable-bcmath \
	--enable-calendar \
	--enable-ftp \
	--enable-magic-quotes \
	--enable-sockets \
	--enable-track-vars \
	--enable-mbstring \
    	--enable-memory-limit \
	--enable-soap \
        --with-tidy \
        --with-xsl \
	--with-iconv \

Reproduce code:
These are the locations of the files and the source code: (SoapClient)

ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("");

server.php -> (WebService)

ini_set("soap.wsdl_cache_enabled", "0");

* @param string $what
* @return string 
function searchCompanies($what){
    $result = "Results!!!";
    return $result;

$server = new SoapServer("test.wsdl");

The WSDL file is found here:

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=""><SOAP-ENV:Body><searchCompaniesReturn>Results!!!</searchCompaniesReturn></SOAP-ENV:Body></SOAP-ENV:Envelope>

Actual result:
Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in /home/zoekned/domains/ Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://www.zoek...', 'urn:ServiceActi...', 1) #1 [internal function]: SoapClient->__call('searchCompanies', Array) #2 /home/zoekned/domains/ SoapClient->searchCompanies('iets') #3 {main} thrown in /home/zoekned/domains/ on line 4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-12 12:59 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-04-12 15:00 UTC] gijs at d1 dot nl
Latest CVS snapshot compiled and running!! <-- temp file!
 [2006-04-12 15:02 UTC]
Nice, but does the SOAP thing work now?
 [2006-04-12 15:06 UTC] gijs at d1 dot nl
Sorry, no, it does not run on the latest snapshot.

- Client

- Client Source:

- Server

- Server Source:
 [2006-04-12 17:01 UTC]
Assigned to the SOAP maintainer.
 [2006-04-13 08:21 UTC]
At first you have typo in WSDL.
"" is not a valid URL. But this is not important.

The bug occurs because of your HTTP server configuration.
For some reason it respond with the following response and SoapClient redirects to "".

HTTP/1.1 302 Found
Date: Thu, 13 Apr 2006 06:54:04 GMT
Server: Apache/1.3.34 (Unix) PHP/5.1.3RC3 mod_ssl/2.8.25 OpenSSL/0.9.7e FrontPage/
Keep-Alive: timeout=5, max=499
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

<TITLE>302 Found</TITLE>
The document has moved <A HREF="">here</A>.<P>
<ADDRESS>Apache/1.3.34 Server at Port 80</ADDRESS>

Seems this answer occurs because of "User-Agent" reqest header. I changed default header "PHP-SOAP/php-version" to conform HTTP RFC, but this didn't help. (BTW SOAP/php-version works fine). Probably your web server configured to respond with this magic answer to requests from PHP. :)

To make workaround for such servers, I added ability to change "User-Agent" HTTP header in HTTP response.
You can do it in SoapClinet constructor:

new SoapClient($wsdl, array("user_agent"=>"some_string"));

empty string ("") will prevent sending of User-Agent server at all.

Fixed in CVS HEAD and PHP_5_0.
 [2006-04-13 08:55 UTC] gijs at d1 dot nl
Thank you for your quick response! Changing the "user agent" worked like you said! Server settings should be changed about now. Problem apears to be a Apache setting that prevents Web Crawlers, E-mail harvesters etc. Somehow PHP got filterd out as well.


Gijs van de Nieuwegiessen 

ps.I'll keep the .php files in the directory up for historical reasons. Thanks a lot for your help!
 [2010-12-20 12:01 UTC]
-Package: Tidy +Package: SOAP related
 [2013-01-12 20:19 UTC] dgl dot marimuthu at gmail dot com
Fatal error: Uncaught SoapFault exception: [Client] DTD are not supported by SOAP 
in C:\xampp\htdocs\web services\soap_client.php:4 Stack trace: #0 
C:\xampp\htdocs\web services\soap_client.php(4): SoapClient-
>__call('getCatalogEntry', Array) #1 C:\xampp\htdocs\web 
services\soap_client.php(4): SoapClient->getCatalogEntry('catalog2') #2 {main} 
thrown in C:\xampp\htdocs\web services\soap_client.php on line 4
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 04:01:30 2024 UTC