php.net |  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
 [2006-04-12 12:51 UTC] gijs at d1 dot nl
Description:
------------
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! (http://www.soapclient.com/soapclient?template=%2Fclientform.html&fn=soapform&SoapTemplate=%2FSoapResult.html&SoapWSDL=http://www.zoekned.nl/test/test.wsdl)

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 \
	--with-mime-magic  


Reproduce code:
---------------
These are the locations of the files and the source code:

http://www.zoekned.nl/test/client.php (SoapClient)

CODE
<?
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("http://www.zoekned.nl/test/test.wsdl");
print_r($client->searchCompanies("iets"));
?>

server.php -> http://www.zoekned.nl/test/server.php (WebService)

CODE
<?
ini_set("soap.wsdl_cache_enabled", "0");

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

$server = new SoapServer("test.wsdl");
$server->addFunction("searchCompanies");
$server->handle();
exit();
?>

The WSDL file is found here: http://www.zoekned.nl/test/test.wsdl


Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><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/zoekned.nl/public_html/test/client.php:4 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/zoekned.nl/public_html/test/client.php(4): SoapClient->searchCompanies('iets') #3 {main} thrown in /home/zoekned/domains/zoekned.nl/public_html/test/client.php on line 4


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-12 12:59 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-04-12 15:00 UTC] gijs at d1 dot nl
Latest CVS snapshot compiled and running!!
http://www.zoekned.nl/phpinfo.php <-- temp file!
 [2006-04-12 15:02 UTC] sniper@php.net
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
http://www.zoekned.nl/test/client.php

- Client Source:
http://www.zoekned.nl/test/client.phps


- Server
http://www.zoekned.nl/test/server.php

- Server Source:
http://www.zoekned.nl/test/server.phps
 [2006-04-12 17:01 UTC] sniper@php.net
Assigned to the SOAP maintainer.
 [2006-04-13 08:21 UTC] dmitry@php.net
At first you have typo in WSDL.
"http://www.zoekned.nl/test/server.php:80" 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://www.sukkel.nl".

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/5.0.2.2510
Location: http://www.sukkel.nl
Keep-Alive: timeout=5, max=499
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="http://www.sukkel.nl">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.34 Server at www.zoekned.nl Port 80</ADDRESS>
</BODY></HTML>

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.

Cheers! 

Gijs van de Nieuwegiessen 

ps.I'll keep the .php files in the zoekned.nl/test directory up for historical reasons. Thanks a lot for your help!
 [2010-12-20 12:01 UTC] jani@php.net
-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: Thu Nov 21 08:01:29 2024 UTC