Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to invoke a WS over https on a remote host:remote port and I get:

Error fetching http headers

using the PHP5 SoapClient; I can get the list of functions by doing $client->__getFunctions() but when I call $client->myFunction(...) I always get this error.

I've googled and found that increasing default_socket_timeout in php.ini should fix it, but it did not work.

Can anyone suggest me a solution?

EDIT: here is the code:

$wsdl="myWSDL";

$client = new SoapClient($wsdl,array('connection_timeout'=>5,'trace'=>true,'soap_version'=>SOAP_1_2));

var_dump($client->__getFunctions());

try {
    $response=$client->myFunction("1","2","3");
         } catch (SoapFault $fault) {
    var_dump($fault);
    }
}

always ends in the error.

How do I solve the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
546 views
Welcome To Ask or Share your Answers For Others

1 Answer

This error is often seen when the default_socket_timeout value is exceeded for the SOAP response. (See this link.)

Note from the SoapClient constructor: the connection_timeout option is used for defining a timeout value for connecting to the service, not for the timeout for its response.

You can increase it like so:

ini_set('default_socket_timeout', 600); // or whatever new value you want

This should tell you if the timeout is the issue, or whether you have a different problem. Bear in mind that you should not use this as a permanent solution, but rather to see if it gets rid of the error before moving on to investigate why the SOAP service is responding so slowly. If the service is consistently this slow, you may have to consider offline/batch processing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...