in Education by

What you understand by Fault Exception in WCF?

1 Answer

0 votes
by

A Fault Contract is a way to handle an error/exception in WCF. In C# we can handle the error using try and catch blocks at the client side. The purpose of a Fault Contract is to handle an error by the service class and display in the client side. Whenever the client makes a call to a service class and an unexpected exception comes such as, SQL Server is not responding, or Divide by zero; in this case the service class throws an exception to the client using the Fault Contract.

By default when we throw an exception from a service, it will not reach the client. WCF provides the option to handle and convey the error message to the client from a service using a SOAP Fault Contract.

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

  1. FaultException: to send an untyped fault back to the caller.
  2. FaultException<T>: to send a typed fault data to the client. It is basically a Generic Type.

Syntax

[OperationContract]
[FaultContract(typeof(MyException))]
string getDetails(int value);


The Fault Contract sample demonstrates how to communicate error information from a service to a client. The sample is based with some additional code added to the servie to convert an internal exception to a fault.

Related questions

0 votes
    What is Fault Contract in WCF?...
asked Apr 2, 2021 in Education by JackTerrance
0 votes
    What is Exception Handling in WCF? What are the ways for WCF Exception Handling?...
asked Apr 2, 2021 in Education by JackTerrance
0 votes
    What Message Exchange Patterns (MEPs) supported by WCF? Explain each of them briefly....
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Information cards in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Instance Management in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Duplex in WCF? Explain also Message Exchange Pattern?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is WCF Messaging Layer?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Method overloading in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is MSMQ in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    Explain bindings in WCF with description?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    Explain briefly different Instance Modes in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Transport level security in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is SOA, and Messages in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Streaming in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Security Implementation in WCF? How many are there?...
asked Apr 3, 2021 in Education by JackTerrance
...