views:

57

answers:

1

We have many WCF services, we have not been using contract first. So now we have a lot of code that throws exceptions, that are not specified in the FaultContracts.

Other than manually inspecting the code. Is there a way to generate FaultContracts or at least get a warning when a FaultContract is missing?

Thanks

Shiraz

A: 

The Microsoft Enterprise Library Exception Handling Block has a feature which allows exceptions to be declaratively mapped to faults at the service boundary level. This means that you don't have to explicitly raise the faults yourself; they will be created for you by the block when an exception reaches a service boundary. See this article for more details.

However this won't help you identify service operations which are missing fault contracts. I'm not aware of a tool which can do this, so you may have to write your own.

pmarflee
Thanks for the reply, but this would still require me to manually specify all the fault contracts, unless I have misunderstood something.
Shiraz Bhaiji
@Shiraz: Yes, that's correct. I'm not aware of a tool that will analyse code coverage for fault contracts. It's probably something you would have to write yourself using reflection.
pmarflee