Home > DeveloperSection > Articles > ABC of WCF


.NET WCF  WCF Binding  WCF Endpoint 
0 Comment(s)
 1148  View(s)
Rate this:


This article explains the use of Addresses (A), binding (B) and contracts (C) of WCF.


WCF provides a common method for communication in support for SOA (service oriented Architecture). Now, developers can use WCF instead of multiple technologies used earlier. WCF is a new communication subsystem to enable application, in one machine or across multiple machine connected through a network, to communicate.  These WCF application can be developed in any language, which can target the .Net runtime.


WCF service is a program that exposes a collection of Endpoints. Each Endpoint is a portal for communicating with the world. All the WCF communications are take place through end point

The <endpoint> element contains the following attributes:

ABC (Address, Binding, Contract) of WCF:

A: Address (where)

Address: WCF services must have an address. The address specifies the location of the service which will be exposed for clients that will use it to communicate with the service. The address’s protocol that WCF can provided: HTTP, TCP, NamedPipe, peer2peer, MSMQ.

B: Binding (How)

Binding: WCF binding is a set of binding elements and each element specify, how the service and client will communicates with each other. Each binding must have at least one transport element and one message encoding element.

Types of binding

1.      Basic binding

2.      Web binding

3.      Web service binding(WS)

4.      WS dual binding

5.      TCP binding

6.      IPC binding

7.      Federated WS binding

8.      MSMQ binding

9.      Peer Network binding

10.  MSMQ Integration binding


Basic binding:

This binding is provided by the BasicHttpBinding class.

·          This is interoperable binding.

·         This is commonly used as replacement for earlier web service on ASMX.

·         It supports Http & Https protocols.

·         It supports Message transmission Optimization Mechanism (MTOM) encoding.

·         It support text encoding.


Web binding:

This binding is provided by the WebHttpBinding class.

·         This is a secure binding.

·         This is an interoperable binding.

·         It supports Http/Https protocol.

·         It does not use SOAP message format.


Web service (WS) binding:

This binding is provided by the WSHttpBinding class.

·         This is a secure binding.

·         This is interoperable binding.

·         This uses SOAP over Http.

·         This support reliability over internet.

·         This support transaction over internet.

·         This supports Http/Https protocol.

·         This supports text and MTOM encoding.

·         This is default binding providing by WCF.


WS Dual binding:

This binding is provided by the WsDualHttpBinding class.

·         This support all the feature of WsHttpBinding.

·         This is mainly used for Duplex Service Contracts.

·         This supports bidirectional communication.


TCP binding:

This binding is provided by the NetTcpBinding class. The NetTcpBinding is primarly used for cross-machine communication on the Intranet and supports variety of features, including reliability, transactions, and security and is optimized for WCF-to-WCF communication only .net clients can communicate to .net services using this binding. This is an ideal replacement of the socket-based communication.

IPC binding: 

This binding is a provided by the NetNamedPiped class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept call from outside the machine and it supports a variety of features similar to the TCP binding. It can be used efficiently for cross product communication.

Federated WS binding:

This binding is providing by the WSFederationHttpBinding class.

The WSFederationHttpBinding binding is a specialization of the WS binding, offering support for federated security.

Peer Network binding:

This binding is provided by the NetPeerTcpBinding Class.

The NetPeerTcpBinding is used for peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast message to it.

MSMQ binding:

This binding is provided by NetMsmqBinding class. NetMsmqbinding uses MSMQ for transport and is designed to offer support for disconnected queued calls.

MSMQ integration binding:

This binding is provided by the MsmqIntegrationBinding class.

MsmqIntegrationBinding converts WCF message to and from Msmq messages, and is designed to interoperate with legacy MSMQ client.


C: contract (What)

The contract is an agreement between the client and the server about the structure and content of message being exchanged. The data contract is about the structure of the message, whereas the message contract is about the content of the message being exchange.

Types of Contract:

Service Contract

Operation Contract

Data Contract

Message Contract

Fault contract

Service contracts:

Describe which operations the client can perform on the service.

Operation contract:

An operation contract is defined within a service contract.  It defines the parameters and return types of an operation. An operation contract can also defines operation-level settings.

Data contract:

Define which data types are passed to and from the service. WCF defines implicit contract for built-in types such as int and string, but you can easily define explicit Opt-in contracts for custom types.

Fault contract:

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

Message Contract:

Default SOAP message format is provided by the WCF runtime for communication between client and service. If it is not meeting your requirement then we can create our own message format.  This can be achieved by using Message contract attribute.

Don't want to miss updates? Please click the below button!

Follow MindStick