title: Throwing a SoapException does not return a valid SOAP response
body: <p>I'm working on an old web site. It is calling an ASP.Net web service (old .asmx files). Whenever an exception happens in the web service, it will throw a SoapException. The client catches this exception but is not able to pars it.</p>
  
  <p>I'm viewing the SOAP request and response using both <strong>Fiddler</strong> and <strong>SOAP UI</strong> and reading this article <a href="http://msdn.microsoft.com/en-us/library/aa480514.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa480514.aspx</a> I expect to get the response in the following format: </p>
  
  <pre><code>&lt;soap:Fault&gt;
  &lt;faultcode&gt;soap:Server&lt;/faultcode&gt;    
  &lt;faultstring&gt;Server was unable to process request. Something bad happened&lt;/faultstring&gt;
  &lt;detail /&gt;
  </code></pre>
  
  <p></p>
  
  <p>However, I'm just getting the following response:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Server: ASP.NET Development Server/10.0.0.0
  Date: Thu, 12 Jun 2014 05:27:14 GMT
  X-AspNet-Version: 2.0.50727
  Cache-Control: private
  Content-Type: text/plain; charset=utf-8
  Content-Length: 164
  Connection: Close
  
  System.Web.Services.Protocols.SoapException: Something bad happened
     at WebService1.Service1.HelloWorld() in ...
  </code></pre>
  
  <p>Which I believe is the reason the client can't process the exception.</p>
  
  <p>This happens even in a sample Hello World web service.</p>
  
  <p>What can be wrong?</p>
  
  <p>UPDATE: When I call my web service method that does NOT throw exception, I will get response in the following format:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ords="http://mydomain.com/"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        ...
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>This is how I throw the SoapException:</p>
  
  <pre><code>[WebMethod]
  public string HelloWorld()
  {
       throw new SoapException("Something bad happened", SoapException.ClientFaultCode);
       //return "Hello World";
  }
  </code></pre>