Introduction
What is the use of FaultContract?
In simple WCF service errors can be passed to the client(service Consumer) by using FaultContract
How do you handle errors in ASP.NET? It's very simple just by adding the simple Try & Catch blocks. You can handle the error and log it some where & can do whatever stuff required but when you come to WCF Service if any unexpected error occurred in service then error details can be passed to client by using Fault Contract.
Using the Code
This is a very simple WCF service implementation to understand the usage of the FaultContract. Here I am implementing the TestConnection() method in the WCF service. This method try to open some SQL Server connection if any errors occurs while opening the connection it throws the error details to the cleint by using the Fault Contract.
What is the use of FaultContract?
In simple WCF service errors can be passed to the client(service Consumer) by using FaultContract
How do you handle errors in ASP.NET? It's very simple just by adding the simple Try & Catch blocks. You can handle the error and log it some where & can do whatever stuff required but when you come to WCF Service if any unexpected error occurred in service then error details can be passed to client by using Fault Contract.
Using the Code
This is a very simple WCF service implementation to understand the usage of the FaultContract. Here I am implementing the TestConnection() method in the WCF service. This method try to open some SQL Server connection if any errors occurs while opening the connection it throws the error details to the cleint by using the Fault Contract.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
No comments:
Post a Comment