title: How to deal with "Request denied by Throttle server" SOAP responses in Laravel 5
body: <p>I have made a web application that uses SOAP exchanges to get data from a Web API.  This was initially done in a procedural way and I'm now trying to move it into a Laravel framework.  I have a <code>view</code> set up to display to the user if the SOAP Response is "Request denied by Throttle server" but I don't know how to check for that particular error.  Here is the Class:</p>
  
  <pre><code>&lt;?php namespace App\Models;
  
  use SoapClient;
  use Illuminate\Http\RedirectResponse;
  
  class SoapWrapper {
  
  public function soapExchange() {
  
      // set WSDL for authentication and create new SOAP client
      $auth_url  = "http://search.webofknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
  
      // set WSDL for search and create new SOAP client
      $search_url = "http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl";
  
      // array options are temporary and used to track request &amp; response data
      $auth_client = @new SoapClient($auth_url);
  
      // array options are temporary and used to track request &amp; response data
      $search_client = @new SoapClient($search_url);
  
      // run 'authenticate' method and store as variable
      $auth_response = $auth_client-&gt;authenticate();
  
      // call 'setCookie' method on '$search_client' storing SID (Session ID) as the response (value) given from the 'authenticate' method
      // check if an SID has been set, if not it means Throttle server has stopped the query, therefore display error message
      if (isset($auth_response-&gt;return)) {
          $search_client-&gt;__setCookie('SID',$auth_response-&gt;return);
      } else {
          return Redirect::route('throttle');
      }
  }
  }
  </code></pre>
  
  <p>The problem is that it throws the "Request denied by Throttle server" default Laravel error at <code>$auth_response = $auth_client-&gt;authenticate();</code> before it gets to the <code>if</code> statement that checks if a value (SessionID) has been returned by the SOAP Request.  It didn't do this when it was set up in a procedural way for some reason.</p>
  
  <p>The <code>if</code> statement checks if a value has been returned from the <code>authenticate()</code> method and if it has, assigns it (SessionID) to the cookie of the search client to authorise searches.  Otherwise it displays a custom error message.</p>
  
  <p>I have tried using <code>is_soap_fault</code> but that doesn't catch it because it isn't technically a soap fault.  I've also tried removing the line causing the problem and changing the <code>if</code> statement to:</p>
  
  <pre><code>if (isset($auth_client-&gt;authenticate()-&gt;return) {...
  </code></pre>
  
  <p>But that just causes the default Laravel SoapFault page too.  The <code>return Redirect::route('throttle')</code> displays a custom error page to the user, saved as <code>throttle.blade.php</code>.</p>
  
  <p>Anyone know how I can test for the throttle error?</p>