WCF Exception Handling
WCF introduces new exception handling concepts to address the differences between traditional component-oriented systems and SOA. While traditional component-oriented systems can share native types for exception reporting and handling, this does not work across service boundaries. Exceptions are serialized as SOAP faults between clients and services. The service model can handle this automatically by converting exceptions into faults, or faults can be explicitly created using new CLR types introduced with WCF for this purpose.
In this section, I’ll introduce the concept of fault exceptions and then provide a high-level explanation of the way services and clients deal with exceptions and faults.
WCF introduces several new exception types, most of which derive from a common base
CommunicationException. Among the types that
FaultException is the most important. Both types are from the
FaultException properties are
closely related to the SOAP fault— they are
FaultException provides access to the
entire message associated with the SOAP fault through its
Message property. It is through this property that the detail element of the
fault can be retrieved, for example.
There is also a generic version of the
FaultException<T>. This type provides strongly typed access to the detail element of the fault through its ...