title: Catching a SoapException thrown by a WebService
body: <p>I wrote the following service : </p>
  
  <pre><code>namespace WebService1
  {
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      public class Service1 : System.Web.Services.WebService
      {
          [WebMethod]
          public string Test(string str)
          {
              if (string.IsNullOrEmpty(str))
                  throw new SoapException("message", SoapException.ClientFaultCode);
              else
                  return str;
          }
      }
  }
  </code></pre>
  
  <p>And a basic application to test it (one button calling the <code>Test</code> method on click event): </p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      ServiceReference1.Service1SoapClient ws = new WindowsFormsApplication1.ServiceReference1.Service1SoapClient();
  
      try
      {
          ws.Test("");
      }
      catch (SoapException ex)
      {
           //I never go here
      }
      catch (FaultException ex)
      {
          //always go there
      }
      catch (Exception ex)
      {
  
      }
  }
  </code></pre>
  
  <p>I'd like to catch the <code>SoapException</code> thrown by my WebService, but I always go to the <code>FaultException</code> catch block a get that as message:</p>
  
  <blockquote>
    <p>System.Web.Services.Protocols.SoapException: message
       at WebService1.Service1.Test(String str) in [...]WebService1\WebService1\Service1.asmx.cs:line 25</p>
  </blockquote>
  
  <p>How could I catch a real <code>SoapException</code>, and not a <code>FaultException</code>? Is there something I miss in the WebService?</p>