Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
870 views
in Technique[技术] by (71.8m points)

web services - PHP SoapClient Timeout

Is there anyway for a SoapClient Request to time out and throw an exception. As of now, I get PHP Server response timeout, in my case 60 seconds. Basically what I want is, if there isn't any reply from the Web Service within certain time, an exception would be thrown and I could catch it. The 60 seconds warning is not what I want.

See Question&Answers more detail:os

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

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

Invalid answer. Please see https://stackoverflow.com/a/12119215/441739 instead.


While Andrei linked to a decent solution, this one has less code yet arrives at a good solution:

* Handling Timeouts with PHP5 SoapClient Extension (by Antonio Ramirez; 02 Feb 2010)
Example code:
//
// setting a connection timeout (fifteen seconds on the example)
//
$client = new SoapClient($wsdl, array("connection_timeout" => 15));
And there is also the stream context, if you need more fine-grained HTTP control. See the stream_context option for new SoapClient()Docs. Under the surface SoapClient uses the HTTP and SSL transports.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...