SQLAuthority News – Guest Post – FAULT Contract in WCF with Learning Video
- by pinaldave
This is guest post by one of my very good friends and .NET MVP, Dhananjay Kumar. The very first impression one gets when they meet him is his politeness. He is an extremely nice person, but has superlative knowledge in .NET and is truly helpful to all of us.
Objective:
This article will give a basic introduction on:
How to handle Exception at service side?
How to use Fault contract at Service side?
How to handle Service Exception at client side?
A Few Points about Exception at Service
Exception is technology-specific.
Exception should not be shared beyond service boundary.
Since Exception is technology-specific, it cannot be propagated to other clients.
Exception is of many types.
CLR Exception
Windows32 Exception
Runtime Exception at service
C++ Exception
Exception is very much native to the technology in which service is made.
Exception must be converted from technology-specific information to natural information that can be communicated to the client.
SOAP Fault
FaultException<T>
Service should throw FaultException<T>, instead of the usual CLR exception.
FaultException<T> is a specialization of Fault Exception.
Any client that programs against FaultException can handle the Exception thrown by FaultException<T>.
The type parameter T conveys the error detail.
T can be of any type like Exception, CLR Type or any type that can be serialized.
T can be of type Data contract.
T is a generic parameter that conveys the error details.
You can read complete article http://dhananjaykumar.net/2010/05/23/fault-contract-in-wcf-with-learning-video/
Reference: Pinal Dave (http://blog.sqlauthority.com)
Filed under: SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology