Click here to Skip to main content
15,037,928 members
Articles / Web Development / ASP.NET
Posted 15 Sep 2011


174 bookmarked

Windows Communication Foundation Basics

Rate me:
Please Sign up or sign in to vote.
4.74/5 (81 votes)
15 Sep 2011CPOL4 min read
Windows Communication Foundation (WCF) basics for beginners


In this article, I am describing what is Window Communication Foundation (WCF) and why it is introduced in .NET Framework 3.0.


In Modern Application (Distributed Application) development, you can use COM+, .NET Enterprise Services, MSMQ, .NET Remoting, Web services, etc. for communication. All these technologies play a different role and to use it you need to develop different solutions for different technologies. You have to focus on each of the technologies to develop rather than the application business logic.

WCF unifies the capabilities into single, common, general service oriented programming model for Communication. WCF provides a common approach using a common API which developers can focus on their application rather than on communication protocol.

Sample Image - maximum width is 600 pixels

Why Do We Need WCF?

There is one main Bank system which is directly connected with the database, that provides other systems like ATM machine, Loan System data using various communication protocols like Remoting, web service, etc. For communicating with different Systems using different communication protocols, you have to know the API of that technology. In WCF, you have to just make different End points for different services. There is no need to learn a different API. You can use only one common API for communication with different System.

In WCF, you have to just make different End points for different services. There is no need to learn a different API. You can use only one common API for communication with a different System.

Sample Image - maximum width is 600 pixels

Sample Image - maximum width is 600 pixels

WCF Architecture

Sample Image - maximum width is 600 pixels

ABC of an EndPoint in WCF

Sample Image - maximum width is 600 pixels

All communications with the WCF service will happen via the endpoints. The endpoints specify a Contract that defines which methods of the Service class that will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted.

A-Address(Where?): Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.

// The sample address for above transport schema may look like 



B-Binding-Address(How?): Specifies how the two parties will communicate in terms of transport and encoding and protocols.

WCF Supports Nine Types of Bindings

Basic Binding

Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.

TCP Binding

Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.

Peer Network Binding

Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

IPC Binding

Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

Web Service (WS) Binding

Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

Federated WS Binding

Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.

Duplex WS Binding

Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

MSMQ Binding

Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

MSMQ Integration Binding

Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.

Choosing Binding Type

Sample Image - maximum width is 600 pixels

C-Contract(What?): Specifies the interface between client and the server. It's a simple interface with some attribute.

Types of Contracts

Sample Image - maximum width is 600 pixels

What are Various Ways of Hosting WCF Services?

There are three major ways of hosting a WCF services:

  • Self-hosting the service in its own application domain. The service comes into existence when you create the object of Service Host class and the service closes when you call the Close of the Service Host class.
  • Host in application domain or process provided by IIS Server.
  • Host in application domain and process provided by WAS (Windows Activation Service) Server.

Choose Type of Hosting

Sample Image - maximum width is 600 pixels

Your feedback is always welcome.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sachin Somanath Mumbare
Software Developer
India India
He is working On C#,,window communication foundation(WCF),Silverlight from past 4+ years.
He is flair for learning technology.He is active in programming communities and loves to share the knowledge with other developers whenever he gets the opportunity.

Comments and Discussions

QuestionWCF topic Pin
SAGAR1988139-Nov-14 3:38
MemberSAGAR1988139-Nov-14 3:38 
Questionwcf Pin
ramsuhavan patel27-Oct-14 5:04
Memberramsuhavan patel27-Oct-14 5:04 
QuestionI really enjoyed Pin
Member 1111664415-Oct-14 22:41
MemberMember 1111664415-Oct-14 22:41 
GeneralMy vote of 5 Pin
vinod.sankuthodi22-Jun-14 0:32
Membervinod.sankuthodi22-Jun-14 0:32 
GeneralMy vote of 5 Pin
Senthilaan24-Apr-14 3:04
professionalSenthilaan24-Apr-14 3:04 
Questionnice Pin
Member 1058985424-Feb-14 19:52
MemberMember 1058985424-Feb-14 19:52 
GeneralGood Article Pin
Sadique KT22-Jan-14 23:33
MemberSadique KT22-Jan-14 23:33 
Generalnice:) Pin
Member 105135309-Jan-14 22:00
MemberMember 105135309-Jan-14 22:00 
QuestionMultiple WCF Projects for Silverlight Pin
AravindhanT21-Oct-13 18:36
MemberAravindhanT21-Oct-13 18:36 
Questionvery nice article sachin Pin
Member 427897425-Sep-13 3:25
MemberMember 427897425-Sep-13 3:25 
GeneralMy vote of 5 Pin
Member 1021217018-Sep-13 7:36
MemberMember 1021217018-Sep-13 7:36 
GeneralMy vote of 5 Pin
chandu sonkar22-Aug-13 19:14
professionalchandu sonkar22-Aug-13 19:14 
GeneralMy vote of 4 Pin
Member 916699026-Jun-13 16:26
MemberMember 916699026-Jun-13 16:26 
GeneralMy vote of 5 Pin
Minghang15-Apr-13 8:31
MemberMinghang15-Apr-13 8:31 
GeneralMy vote of 4 Pin
Rockstar_4-Apr-13 17:22
professionalRockstar_4-Apr-13 17:22 
QuestionShort n Sweet Explanation, But I want more Pin
sanjaysolanki9025-Jan-13 20:35
professionalsanjaysolanki9025-Jan-13 20:35 
GeneralMy vote of 5 Pin
Velkumar Kannan21-Jan-13 18:39
MemberVelkumar Kannan21-Jan-13 18:39 
Questionselection of security model Pin
b2answer18-Dec-12 19:16
Memberb2answer18-Dec-12 19:16 
QuestionHi Sachin Pin
sathish_p18-Dec-12 18:32
Membersathish_p18-Dec-12 18:32 
GeneralMy vote of 5 Pin
devvvy3-Dec-12 15:45
Memberdevvvy3-Dec-12 15:45 
QuestionWhy we need WCF Pin
devvvy3-Dec-12 15:38
Memberdevvvy3-Dec-12 15:38 
QuestionWindows Communication Foundation Basics Pin
balaji deshmukh29-Nov-12 3:56
Memberbalaji deshmukh29-Nov-12 3:56 
AnswerRe: Pin
priyanshbhaliya19-Nov-12 4:58
professionalpriyanshbhaliya19-Nov-12 4:58 
QuestionFeed back Windows Communication Foundation Basics Pin
Kapil Kr. Khandelwal31-Oct-12 21:17
professionalKapil Kr. Khandelwal31-Oct-12 21:17 
GeneralMy vote of 5 Pin
Amol_27101982, India9-Oct-12 0:16
MemberAmol_27101982, India9-Oct-12 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.