tags:

views:

49

answers:

2

Hello,

I have a PHP script that sends a request to a web service via soap. I expect to get a response back in just a few seconds, but if I do not receive a response within 30 seconds I need to send another request voiding my first request.

Any suggestions on the best way to handle this timer feature? Should I be looking at PHP's set_time_limit setting? Looking for any insight or general ideas.

Thanks.

A: 

If we only had multi threading....
My approach (although you can do async calls with CURL) would be to write a script that manages this process. This script would do:

  1. Using shell/cron/async javascript (from the client side)/async call using CURL to activate the calling script.
  2. Check every few seconds if the calling script returned an answer (answer is saved to memory/disk by the calling script, which also serves as a flag->I finished)
  3. 30 seconds passed - kill the current instance of the calling script, instantiate another calling script.

This is a very crude description, and the finer details should be defined better.

Itay Moav
Very productive to vote down without an explanation...
Itay Moav
+1  A: 

Found this on the web and seems like a step in the right direction...

a feature -> setting a connection timeout

$client = new SoapClient($wsdl, array("connection_timeout"=>5));The connection_timeout option defines a timeout in seconds for the connection to the SOAP service. This option does not define a timeout for services with slow responses. To limit the time to wait for calls to finish the default_socket_timeout setting is available.

Kevin
Did it work? If so - post the full code for future reference
Itay Moav