From Exceptions to Faults

A question that I often get asked during workshops on WCF is “Why does WCF use Faults instead of .NET Exceptions?”

Exceptions expose a set of limitations and possible security risks:

- They are platform/technology specific: .NET exceptions may have no meaning on other platforms

- Exceptions can cause tight-coupling between clients and service.

o Clients need to understand exactly what exceptions can be thrown by each operation

- Flowing exceptions to clients may expose service implementation details

- Flowing exceptions to clients may expose private and personal information

- Exceptions and exception hierarchies are not easily represented using metadata

Therefore a map between exceptions on the service and their equivalent on the client is required. This is achieved using SOAP Faults.
It is worth mentioning that exceptions that reach WCF clients are represented as FaultException.

$0.02

Comments

  • Anonymous
    January 12, 2008
    PingBack from http://geeklectures.info/2008/01/12/from-exceptions-to-faults/

  • Anonymous
    January 25, 2008
    I put together the following brief description of WCF Error Handling and some possible best practices

  • Anonymous
    January 25, 2008
    I put together the following brief description of WCF Error Handling and some possible best practices

  • Anonymous
    January 06, 2009
    I am using an ASMX service in my WCF service library. I am adding ASMX services as "Service References" in my WCF service library. I want to catch the soap exceptions thrown by the ASMX services. Can you please suggest me how can I do that?

  • Anonymous
    May 05, 2014
    Thank you for sharing this knowledge... helpful for a beginner in WCF