title: Handling Exceptions from an Async WCF Web Service call
body: <p>I have a third-party web-service reference which has a web method <em>AddDocument</em>.
  Our application called this method synchronously before but I need to implement asynchronous call to this method now.</p>
  
  <p>I have reconfigured web-service reference in my project by checking "Generate Asynchronous Operations" checkbox.
  Now I have a <em>BeginAddDocument</em> method available, which I am calling as:</p>
  
  <pre><code>AsyncCallback callback = ProcessAsyncResult;
  object asyncState = "TestAsyncState";
  srv.BeginAddDocument(Credentials, document, callback, asyncState);
  </code></pre>
  
  <p>And I have prepared a stab for a callback method:</p>
  
  <pre><code>public void ProcessAsyncResult(IAsyncResult result)
  {
  }
  </code></pre>
  
  <p>Sometimes the web-service returns errors.
  They can be easily catched and handled while calling method synchronously.</p>
  
  <p>But unfortunately I cannot find any clear answers how to catch exceptions using asynchronous approach, keeping in mind that I cannot modify the web-service itself.</p>
  
  <p>IAsyncResult in the callback method seems to be the same regardless of the operation result - be it a success or an exception.</p>
  
  <p>Is it possible at all to catch exceptions from a web service using asynchronous approach, and if it is, what is the best way to make it possible?</p>