Skip to content

In this article we will see how we can use the WCF fault contracts to handle exceptions. This tutorial will help you to create WCF service step by step with fault contracts.

Notifications You must be signed in to change notification settings

geeksarray/handling-wcf-service-exceptions-using-fault-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Handling wcf service exceptions using fault contracts and data contracts

n this article, we will see how we can use WCF fault contracts to handle exceptions. WCF gives you enough flexibility to handle exceptions and send required detail to clients. By default, WCF sends exception details to clients using SOAP FaultContract. The default FaultContract will allow you to set Message, Reason properties and throw it to clients.

Why we should use the FaultContract rather than using .Net exceptions?

Exceptions have limitations and security risks.

  1. .Net exception can be used by only CLR supported languages so losing great WCF feature of interoperability.
  2. Throwing exceptions can provide service implementation and private details to clients.
  3. Exceptions are tightly coupled between clients and service.

Projects

  1. Northwind WCF Services - WCF Services with implementation of Fault Contract.
  2. Client App - It is a client application consuming WCF services and using Fault contract response sent by WCF services.

Your project structure will be like this

Add WCF Service reference

For more details about implementation of FaultContract see https://geeksarray.com/blog/handling-wcf-service-exceptions-using-fault-contracts

About

In this article we will see how we can use the WCF fault contracts to handle exceptions. This tutorial will help you to create WCF service step by step with fault contracts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages