Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Timeout SOAP client (Zend Framework)

I'm requesting a webservice using SOAP for which I need to set a request timeout.

new Zend_Soap_Client(http://www.aaa.com/ws/Estimate.asmx?wsdl",
                       array('encoding' => 'UTF-8');

I have also tried passing 'connection_timeout'=>100 but it seems like "unknow SOAP client option". Please suggest a way I can set the set timeout.

Thanks

like image 906
ravs Avatar asked Jan 21 '23 08:01

ravs


1 Answers

I found a solution to set the timeout with Zend_Framework:

If you have your SoapClient-Object like this:

$client = new Zend_Soap_Client(http://www.aaa.com/ws/Estimate.asmx?wsdl", array('encoding' => 'UTF-8');

You can set the timeout for HTTP-Requests. The default timeout in PHP is 30 seconds. With the following code you can e.g. set it to 1 minute.

$context = stream_context_create(
    array(
        'http' => array(
            'timeout' => 1000
        )
    )
);
$client->setStreamContext($context);

Found on downlifesroad.com

like image 169
algorhythm Avatar answered Jan 31 '23 09:01

algorhythm