title: Handling Soap timeouts in PHP
body: <p>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 the web service, but also need to handle the edge cases of a service timeout or unavailability.</p>
  
  <p>In the case of a timeout or service unavailability, I need to pretend that the request was successful (that the web service approved the info), but I'm not clear on what exceptions are thrown.</p>
  
  <p>Some pseudo-code:</p>
  
  <pre><code>// $client is PHP's SoapClient class
  try {
    $response = $client-&gt;SomeSoapRequest();
  }
  catch(SoapFault $e){
    // handle issues returned by the web service
  }
  catch(Exception $e){
    // handle PHP issues with the request
  }
  </code></pre>
  
  <p>What I can't seem to find is:</p>
  
  <ol>
  <li>Are timeouts a <code>SoapFault</code>? If so, what is the best way to distinguish between a timeout error and web service issues (like a type error, etc.)? I found one page that mentioned an error where the message was something to the effect of "Error loading headers", but didn't mention if this was a Soap fault.</li>
  <li>How is a service unavailability potentially going to happen? A PHP exception seems like it would make sense (a SoapFault would be returned from the web service where unavailability would be a socket issue or similar)?</li>
  <li>Is there an existing service (e.g. example) that I can test a timeout against? Most timeout related discussions seem to be related to preventing timeouts by extending the default timeout setting, which isn't ideal in this situation.</li>
  </ol>