Search code examples
wcfwcf-binding

Custom WCF Binding Suppresses Fault


I have a WCF Service which I am calling asychronously.

If I call a method that throws a normal .Net Exception (i.e., not a FaultException) using wsHttpBinding, my WCF Channel is left in a faulted state - this is the expected behavior.

However, if I call the same method using a custom binding:

<customBinding>
   <binding name="httpCompressed" sendTimeout="00:10:00" receiveTimeout="00:10:00">
      <httpTransport maxBufferSize="2147483647"
            maxBufferPoolSize="524288"
            maxReceivedMessageSize="2147483647" />
   </binding>
</customBinding>

Then, while I do receive an exception back, the channel is left in an Open state. This is not an expected behavior - at least, not as far as I can tell.

Is this indicative of a bug in the customBinding for WCF? Is this actually an expected behavior (if so, a pointer documentation would be excellent).

Thanks in advance for any assistance.

David Mullin IMA Technologies


Solution

  • This is expexted. WsHttpBinding in default setting (with security session) uses PerSession instancing. It means that single service instance handles all requests from proxy opening the channel. If unhandled exception occures the service instance is destroyed and channel is faulted. Proxy can't open more than one channel and can't start another session so the only thing you can do with faulted proxy is to abort it.

    Your custom binding uses pure http transport without any session. Due to that PerCall instancing is used. It means that each request from proxy is handled by new service instance. Service instance is released after each call and faults don't affect the channel because next call will be handled by a new service instance.