This problem has been killing me for the entire day.
I have a client web service https://*.asmx?WSDL, with Basic HTTP Authentication..
If I use SoapUI to connect to the webservice, everything works perfectly with no errors whatsoever..
The problem is when I switch to PHP...
I managed to connect to it, and I can get the function list from the server using soapclient extension for php ( I'm using PHP 5.3.0 ).
When I try to call a function using the soapclient extension for PHP I get the following error:
Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in C:\www\xpto_Atestes\soapclient.php:26 Stack trace: #0 [internal function]: >SoapClient->__doRequest('***...', 'http://****...', 1, 0) #1 >C:\www\xpto_Atestes\soapclient.php(26): SoapClient->__soapCall('login', Array) #2 {main} >thrown in C:\www\xpto_Atestes\soapclient.php on line 26
More clear error ( when I do a print_r of the result of the call):
[faultstring] => Error Fetching http headers
[faultcode] => HTTP
With the following headers being sent:
POST /*.asmx HTTP/1.1 Host: *.pt Connection: Keep-Alive User-Agent: >PHP-SOAP/5.3.0 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://**/Login" >Content-Length: 264 Authorization: Basic AUTHSECRETPASS
I'm calling it like this:
$soapParams = array('login' => 'HTTP_LOGIN',
'password' => 'HTTP_PASS',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0
);
$client = new SoapClient("https://****.asmx?WSDL", $soapParams); echo "Connected
"; $params = array('account' => '', 'msisdn'=>'NUMBER', 'password'=>'PASSWORD'); $result = $client->__soapCall("login", $params);
After a while googling and trying to find out what the problem could be, I switched to nusoap.. which to my misery it gave an error also:
Error
HTTP Error: socket read of headers timed out
Request
POST /**.asmx HTTP/1.0 Host: *.pt User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "http://****/Login" Authorization: Basic AUTHSECRETPASS Content-Length: 481
NUMBERPASSWORD
Response
I'm calling it like this:
$client = new nusoap_client("https://**.asmx?WSDL", true);
$client->setCredentials('HTTPUSER','HTTPPASS','basic');
$params = array( 'account' => '', 'msisdn'=>'NUMBER', 'password'=>'PASSWORD' );
$result = $client->call('Login', $params);
With nusoap I also tried to enable enable curl extension to make the calls:
$client->setUseCurl(true);
But no such luck, it kept on giving an error:
HTTP Error: cURL ERROR: 56: Failure when receiving data from the peer url: http://*********.asmx
content_type:
http_code: 0
header_size: 0
request_size: 750
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 21.015
namelookup_time: 0
connect_time: 0
pretransfer_time: 0
size_upload: 462
size_download: 0
speed_download: 0
speed_upload: 21
download_content_length: -1
upload_content_length: -1
starttransfer_time: 0
redirect_time: 0
I'm 100% sure that nothing is wrong with the webservice, if I can call it from SoapUI without any problem I don't see why I can't call it from PHP.
I rally don't know what more I can do.. I think I tried everything...
Edit: I just tried another Soap Class for PHP, this time from Zend..
The result is:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://**.asmx?WSDL' : failed to load external entity "https://*.asmx?WSDL" in C:\www\xpto_Atestes\Zend\Soap\Client\Common.php:51 Stack trace:
#0 C:\www\xpto_Atestes\Zend\Soap\Client\Common.php(51): SoapClient->SoapClient('https://**...', Array)
#1 C:\www****_Atestes\Zend\Soap\Client.php(1032): Zend_Soap_Client_Common->__construct(Array, 'https://**...', Array)
#2 C:\www****_Atestes\Zend\Soap\Client.php(1188): Zend_Soap_Client->_initSoapClientObject()
#3 C:\www***_Atestes\Zend\Soap\Client.php(1112): Zend_Soap_Client->getSoapClient() #4 [internal function]: Zend_Soap_Client->__call('Login', Array)
#5 C:\www****_Atestes\zend.php(28): Zend_Soap_Client->Login(Array)
#6 {main} thrown in