Showing posts with label fault contract. Show all posts
Showing posts with label fault contract. Show all posts

Wednesday, 27 March 2013

WCF Lesson 4:-Fault Contract in WCF


Fault Contract in WCF

With the help of fault contract we can describe how to exchange error information from service to client. If we get any error in the service then we can pass this error information from service to client with the help of Fault contract.

For Example:-

Everybody is familiar with the error DivideByZero. It occurs when we try to divide a number with zero, It occurs this exception. Same example I am using here.

I create Error class which will be used to pass to the client at the time of error occur:-

[DataContract]
public class Error
{
    [DataMember]
    public string ErrorMessage;

    [DataMember]
    public string ErrorMethod;

}