WCF Exception handling and Policy injection

Mar 4, 2009 at 7:28 AM
Hi,

I am using the Exception handling application block to pass fault contracts back to the client in case of an exception in the service.
This all works fine.

However when I use Policy injection to instantiate the object that throw the exception the fault contract is not created and therefore the proper servicefault soap message is not returned to the client.

Tracing through the Entlib code this is what I have found:

Case 1 – No PI

Once the Exception has been processed by EHAB the final catch block is
triggered which catches a “FaultContractWrapperException” in ExceptionShieldingErrorHandling.cs.
This catch block then calls “HandleFault” which creates the SOAP XML message with the exception
details and returns it to the Client which gets the faultcontract correctly.


Case 2 – PI

In the case the “FaultContractWrapperException” is not handled in ExceptionShieldingErrorHandling.cs but
in “ExceptionCallHandler.cs” which just as standard catch block which receives the “FaultContractWrapper”
exception but simple set’s the exception and returns it to the caller (still in the service).
There is no call to “HandleFault” to generate the SOAP message.

When using the PIAB exceptions FaultContractWrapper exceptions are treated as any other exceptions,
rather than processed as SOAP exception messages.

Has anyone come accross this problem and is there a solution/workaround ?

Thanks.

Mar 4, 2009 at 10:29 AM
Would you mind sending a solution that could repro this?  I can't repro it.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Mar 4, 2009 at 12:14 PM
Edited Mar 4, 2009 at 12:58 PM
Hi Sarah,

Yes I have a solution that reproduces this.
How can I send you the solution ?

Regards
Rainer Wollgarten

<EDIT>
I have send a zip file with solution to entlib.support`avande.com
</EDIT>
Mar 4, 2009 at 1:02 PM
Thanks Rainer, I'll have a look at it. 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Mar 5, 2009 at 9:41 AM
Hi,

As i've read its different how PIAB works with Exception Handling in WCF service boundaries. please see this : 
http://blogs.msdn.com/tomholl/archive/2007/12/02/invoking-the-policy-injection-application-block-at-wcf-service-boundaries.aspx
http://blogs.msdn.com/tomholl/archive/2008/01/13/a-follow-up-on-piab-wcf-integration.aspx


Valiant Dudan
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Mar 5, 2009 at 11:35 AM
Hi Valiant,

I've read these articles as well.

I my view it doesn't explain why the Fault SOAP message is not created when PIAB is used when handling exceptions.
Without PIAB, by just using Exception Handling Application Block everything works as expected.

Can you explain this considering that my 2 scenarios in my initial post

Regards
Rainer Wollgarten
Mar 6, 2009 at 7:35 AM
Edited Mar 6, 2009 at 7:36 AM
Hi,

Sorry I mis understood your original question. So, now you are asking why is it in PIAB with WCF, the FaultException<Customfault> is not returned to the client? is that right? Anyway, I have tried to get around with this by configuring the Exception policy to catch the generic type Exception. I'm just not sure if it will fit your need. Also, We'll investigate further on this and confirm this behavior with the Ent Lib team and get back to you. but for the mean time, please try my proposed workaround.

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com