What is Fault Contracts in WCF?

 Posted by Prasham on 10/11/2010 | Category: WCF Interview questions | Views: 7915 | Points: 40

Fault Contracts is the way to handle exceptions in WCF. The problem with exceptions is that those are technology specific and therefore cannot be passed to other end because of interoperability issue. (Means either from Client to Server or vice-versa). There must be another way representing the exception to support the interoperability. And here the SOAP Faults comes into the picture.

Soap faults are not specific to any particular technology and they are based on industry standards.

To support SOAP Faults WCF provides FaultException class. This class has two forms:

a. FaultException : to send untyped fault back to consumer
b. FaultException<T>: to send typed fault data to the client

WCF service also provides FaultContract attribute so that developer can specify which fault can be sent by the operation (method). This attribute can be applied to operations only.

| Alert Moderator 

Comments or Responses

Login to post response