PHP SoapClient Timeout

后端 未结 6 1374
误落风尘
误落风尘 2020-12-05 00:12

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, i

6条回答
  •  误落风尘
    2020-12-05 00:42

    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.

提交回复
热议问题