title: WCF - Error handling depends on the binding used?
body: <p>Is there some difference in the way how the exceptions are handled in regards of the binding used?</p>
  
  <p>I'm getting different results if I use WSHttpBinding or BasicHttpBanding. </p>
  
  <p>For example, this is my error handling routine in the client side:</p>
  
  <pre><code>//MyClient client = new MyClient("WSBinding");
  MyClient client = new MyClient("BasicBinding");
  try
  {
  
      Result = client.DoTheWork("test");
      Console.WriteLine(Result);
  }
  catch (FaultException e)
  {
      if (e.Code.SubCode.Name.Equals("BadParameters"))
          Console.WriteLine("Bad parameter entered");
  
      Console.WriteLine(e);
  }
  </code></pre>
  
  <p>I can catch the exception on the client when I use WSHttpBinding, however if I use basicHttpHandling I cann't, I get:</p>
  
  <pre><code>Unhandled Exception: System.NullReferenceException: Object reference not set to
  an instance of an object.
  </code></pre>
  
  <p>This is my web.config,</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;bindings&gt;
    &lt;basicHttpBinding&gt;
      &lt;binding name="basicBinding"&gt;
        &lt;security mode="TransportCredentialOnly"&gt;
          &lt;transport clientCredentialType="Windows" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/basicHttpBinding&gt;   
    &lt;wsHttpBinding&gt;
      &lt;binding name="wsBinding"&gt;
        &lt;security mode="None"&gt;
          &lt;transport clientCredentialType="None" /&gt;
          &lt;message establishSecurityContext="false" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;services&gt;
    &lt;service name="MailboxServiceLibrary.MailboxService" behaviorConfiguration="ServiceBehavior" &gt;
      &lt;!--endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsBinding" contract="ParServiceLibrary.IParService"&gt;
        &lt;identity&gt;
          &lt;dns value="MyServer.com" /&gt;
        &lt;/identity&gt;
      &lt;/endpoint--&gt;     
      &lt;endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="ParServiceLibrary.IParService"/&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="ServiceBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="True"/&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p></p>
  
  <p>Seems that BasicHttpBinding uses the Soap 1.1 format and for WSHttpBinding, it uses Soap 1.2 formats but not sure if this can be the cause. </p>
  
  <p>Thanks,</p>