views:

197

answers:

1

In my Workflow Foundation 4.0 RC app I have a 'Receive' and 'SendReplyToReceive' WCF messaging pair that work fine with a simple request/response operation, but I'm having trouble attempting to perform validation on the request and reply with a fault.

In WCF I am able to create a throw custom fault contracts (which in turn sent out SOAP faults) but I just can't see how to achieve this with the built-in workflow messaging activities.

I can only seem to response with a data transfer object (I'm not even able to respond with a choice of object).

Any ideas? (Can you save my day yet again Maurice!?)

Thanks!

+2  A: 

It turns out this can be done but is not quite as discoverable as I would like it to be. I don't think I would have discovered this if Matt Milner and Dave Cliffe hadn't shown me how this works.

The trick is to add a second SendReply for the same Receive activity. This second SendReply return a variable of type FaultException and its purpose is to help define the correct operation contract.

When an error occurs either just throw the FaultException as you normally would killing the workflow or return the fault and leaving the workflow intact and now the client will see it as such.

Update: Check this document for a new white paper "How to Send and Receive Faults in Workflow Services". Also see my blog post here.

Maurice
Great stuff - thanks Maurice!
Lygpt