WCF Contracts – Easy WCF
Skip to content

WCF Contracts

WCF Contracts:

 

In WCF, all services expose contracts.

The contract is a platform-neutral and standard way of describing what the service does.

WCF defines five types of contracts.

  • Service Contracts
  • Operation Contracts
  • Data Contract
  • Message contract
  • fault contract.

Service Contract:

A service contract defines the operations which are exposed by the service to the client. A service contract is the interface of the WCF service and it tells the client what the service can do.

It may have service-level settings, such as the name of the service and namespace for the service.

Operation Contract:

An operation contract is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the op-eration, the directions of the operation (one-way, two-way, or both ways), and fault contract of the operation.

Data Contract:

A data contract defines the data type of the information that will be exchange be-tween the client and the service.

A data contract can be used by an operation contract as a parameter or return type, or it can be used by a message contract to define elements.

Message Contract:

When an operation contract required to pass a message as a parameter or return value as a message, the type of this message will be defined as message contract. A message contract defines the elements of the message (like as Message Header, Message Body), as well as the message-related settings, such as the level of message security.
Message contracts give you complete control over the content of the SOAP header, as well as the structure of the SOAP body.

FaultContract:

A fault contract defines errors raised by the service, and how the service handles and propagates errors to its clients. An operation contract can have zero or more fault contracts associated with it.

© 2015, admin. All rights reserved.

2 thoughts on “WCF Contracts

  1. Pingback: WCF Interview questions (Part – 3) | EasyWCF

  2. Pingback: Top 10 WCF Interview Questions | EasyWCF

Leave a Reply

Your email address will not be published. Required fields are marked *