0

I am working on a WCF service exposes its functionality in a RESTful format. Each services adhere to SOA format and I need flexibility in the way the services are deployed. So when it comes to the exception handling, I want them to be handled at a single point with in the service level, rather than handling at global level. I want to avoid writing try/catch block for each service API.Is it possible to handle the exceptions in a one common place specific to each service. In other words, is there any method which I can hookup to in the WCF call stack where all the exceptions can be handled.

Hunter
  • 2,370
  • 2
  • 20
  • 24
  • 1
    http://stackoverflow.com/questions/6875267/adding-global-error-handling-to-wcf-rest-service – L-Four Mar 28 '13 at 12:34
  • Agreed. But I want to do it at the service level instead. The idea is to make the service self contained SOA. In this proposed solution, I need to do handle it at global level where all the services are hosted. – Hunter Mar 28 '13 at 13:42

1 Answers1

0

I've used custom behavior extensions to do this sort of thing. Basically, you create a new class that implements IErrorHandler and then put in your code for handling the error how you want and for what dispatch levels (IServiceBehavior, IEndpointBehavior, IContractBehavior, etc). Add the error handler to the service behaviors and you are set.

Here is an example I found online of it to use as a starting point (you can also set behaviors in config file): http://wcfpro.wordpress.com/2010/11/18/wcf-extensions-error-handler/

Chris Holwerda
  • 1,255
  • 1
  • 10
  • 20