3

i have a problem with SOAP, havent found a real answer.

try {
    $objResponse = $objSoapClient->$strMethod($objMethod->getSoapRequest());
}
catch (SoapFault $e) {  
    GlobalLogState::write("exception with code(".$e->getCode()."): \n".$e->getMessage());
}

This is my simple SOAP request in try catch block.

I'm getting a SoapFault Exception:

Error Fetching http headers

What is the reason of that?

2 Answers 2

2

The configuration that has worked for me was defining at my php script the following parameters:

    ini_set('default_socket_timeout', 5000);
    $client = new \SoapClient($url,array(
    'trace' =>true,
    'connection_timeout' => 5000,
    'cache_wsdl' => WSDL_CACHE_NONE,
    'keep_alive' => false,
));

Please, comment.

The most important parameter definition, as per my experience with this issue was ini_set('default_socket_timeout', 5000);

During my tests I have defined the default_socket_timeout to 5 seconds and the error 'Error Fetching http headers' was raised instantaneously.

I hope it helps you.

Sign up to request clarification or add additional context in comments.

Comments

0

To fix this error, we can increase the either increase the socket timeout default_socket_time in php.ini or add the connection_timeout parameter in the parameter array passed to the constructor of the SoapClient.

These parameters are in seconds.

  1. In php.ini

    default_socket_timeout = 120

Alternatively, you can change from code

ini_set('default_socket_timeout', 120);

Note: The default socket timeout in php is 60 seconds.

  1. connection_timeout parameter in SoapClient constructor

$client = new SoapClient($wsdl, array('connection_timeout' => 120));

1 Comment

The error comes after like 5 seconds - I seriously doubt it has anything to do with timeout. and the problem was not there a few weeks ago, with the old webservice setup. What ever I changed in my C# soap service setup, had an impact, but what? I changed the response type from strongly typed to a XMLDocument. I even tried returning string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.