Handling Soap timeouts in PHP

前端 未结 8 1778
囚心锁ツ
囚心锁ツ 2021-01-30 09:05

I\'m working on a project where I am verifying information from a user with a SOAP web service. I currently am taking care of errors assuming that I\'m receiving responses from

8条回答
  •  孤城傲影
    2021-01-30 09:41

    just use the "stream_context" to set the timeout setting also for WSDL loading (you need to set the SoapClient $options['connection_timeout'] before):

    class SoapClient2 extends SoapClient
    {
      public function __construct($wsdl, $options=null)
      {
        if(isset($options['connection_timeout']))
        {
          $s_options = array(
              'http' => array(
                  'timeout' => $options['connection_timeout']
                  )
              );
          $options['stream_context'] = stream_context_create($s_options);
        }
        parent::__construct($wsdl, $options);
      }
    }
    

提交回复
热议问题