Click here to Skip to main content
Click here to Skip to main content

Windows Communication Foundation Basics

By , 15 Sep 2011
 

Introduction

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

Background

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 

http://localhost:81
http://localhost:81/MyService
net.tcp://localhost:82/MyService
net.pipe://localhost/MyPipeService
net.msmq://localhost/private/MyMsMqService
net.msmq://localhost/MyMsMqService

//

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.

License

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
Member
He is working On C#,Asp.net,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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberMinghang15 Apr '13 - 8:31 
very well explained...can you plz post on how to communicate between two win form apps...like a chat system(a simple string exchanging will do) using wcf.
GeneralMy vote of 4memberVijaychauhan08064 Apr '13 - 17:22 
nice article with images
QuestionShort n Sweet Explanation, But I want moremembersanjaysolanki9025 Jan '13 - 20:35 
Please could you share how to do type of hosting and why
GeneralMy vote of 5memberVelkumar Kannan21 Jan '13 - 18:39 
Really good
Questionselection of security modelmemberb2answer18 Dec '12 - 19:16 
Hi,
I want to publish the WCF application to intranet network. On the other hand, all subscribers connect to the service and this service connect to banking web service. So, which security model i choose?
 
Regards.
QuestionHi Sachinmembersathish_p18 Dec '12 - 18:32 
very Nice article , it very use full for beginners ..
Question:
 
Can you explain me what type application use WCF. We developed ERP PROJECT N-Tire architectural in EXISTING SYSTEM.Now we plan to move service oriented Architectural.
how to pass the value code behind file to other service layers .
We can possible dataset to service layer ..
 
Regards
 
Sathishkumar.P
GeneralMy vote of 5memberdevvvy3 Dec '12 - 15:45 
Although I think the article misses out on pragmatic criticism and comparison of WCF-vs-other tech (ex raw socket... but then this is not what this article is about), I do appreciate the clear explanation and the diagrams. Thank you for the effort!
QuestionWhy we need WCFmemberdevvvy3 Dec '12 - 15:38 
Perhaps somebody can tell me how much advantage you get by rolling your own RPC mechanism as supposed to WCF?
How much time do you think it will take you to code up serialization,encryption,authentication-authorization,[de]compression... etc? And how much time you think you will need to spend on *learning* (memorizing) WCF config file switches and decipher svclog?
 
WCF is just beautiful. It just such cool technology I can't wait spend more time doing it!
dev

QuestionWindows Communication Foundation Basicsmemberbalaji deshmukh29 Nov '12 - 3:56 
Good Article, covered the basic of wcf, with diagram..
AnswerRe:memberpriyanshbhaliya19 Nov '12 - 4:58 
thanks...
QuestionFeed back Windows Communication Foundation BasicsmemberKapil Kumar Khandelwal31 Oct '12 - 21:17 
Its gud article, for get basic secnario of wcf...Thanks
 
Kapil Kr. Khandelwal
CCPL, Jaipur
GeneralMy vote of 5memberAmol Borkar, Pune, India9 Oct '12 - 0:16 
Thanks...
GeneralMy vote of 5memberpetervanekeren23 Jul '12 - 3:40 
Great diagrams. Helped me choose which binding type to use.
SuggestionNicemember950506872321 May '12 - 19:19 
Sample Example Will More helpfull..........
anyway Good explanation
Questionbeautifully ExplainedmemberMahesh Dandotikar4 Apr '12 - 19:20 
Hi,
 
Thnx for sharing , beautifully explained , my vote of 5.
D.Mahesh

QuestionThanksmemberMember 47502131 Apr '12 - 16:47 
Hi Friend,
 
My knowledge in WCF was zero.
Thanks for explaining the WCF Concept.
 
If possible can u send some small example program to
my mailID - pravinms07@gmail.com
 
Thanks,
M.S.Praveen

GeneralWCFmemberankitaverma27 Mar '12 - 0:05 
hi..its good..
GeneralMy vote of 5membermanoj kumar choubey23 Mar '12 - 0:47 
Nice
GeneralMy vote of 5memberarchanakumari16 Feb '12 - 17:34 
Excellent can you Provide with simple sample example.
GeneralMy vote of 5memberLakshmi Reddy Y30 Jan '12 - 23:34 
Very very................Excellent article
 
Thanks alot.
GeneralMy vote of 3memberSridhar Patnayak23 Jan '12 - 5:19 
Good, but it requires more stuff
GeneralMy vote of 5memberhariazeez7 Dec '11 - 14:41 
the way presenting is good and its makes easy to understand.
GeneralHellomemberMember 41316795 Dec '11 - 20:20 
Good Article .
GeneralMy vote of 5memberDeepak Kaushik (Noida)22 Nov '11 - 0:59 
Good for basic understanding. Well explanned and good example.
GeneralMy vote of 4memberVeerendraMaanikala26 Oct '11 - 23:34 
Excellent. Basics covered.

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 15 Sep 2011
Article Copyright 2011 by Sachin Somanath Mumbare
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid