Hello All, We are going to start new batch from next week. message/call or mail us for more details.

4 September 2013

Windows Communication Foundation (WCF) in C#

In this article I am trying to explain the concept of Windows Communication Foundation (WCF) in C#.

Introduction:


Windows communication foundation (WCF) is a unified programming model for communication over distributed -network to the other application. This is a programming platform and runtime system for building, configuring and deploying network-distributed services. This is recently added service oriented  technology .today’s WCF  becomes very popular technology  for remote activity such as for communications.WCF operate  regardless what platform or what application is interested to use services provide. The fundamental characteristics of WCF are unified programming model provided in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.

 


 

Advantage of WCF


Ø  WCF is interoperable with other services when compared to .Net Remoting, where the client and service have to be .Net.

Ø  WCF services provide better reliability and security in compared to ASMX web services.

Ø  In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.

Ø  WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.

Why we need WCF, when we have already other Communication are Available?


We have more number of existing approaches to building distributed applications. These are Web services, .NET Remoting, Message Queuing (MSMQ) and COM+/Enterprise Services. Windows Communication Foundation (WCF) unifies these into a single framework for building and consuming services. Microsoft originally introduced WCF as part of the .NET Framework 3.0 and above.

Building distributed application with above have some limitation regarding to the platform, transportation (e.g. http, tcp etc). in such case these approach  work on specific environment, so if we change the approach of  consuming services, then we have  to change the service accordingly, in other some consumer unable to take the service due to constrained enforce by the service.

In such scenario we need a single unified distributed- network application by which we can communicate with almost every application regardless, what platform? What technology it supports and what transportation are being used. Thus WCF overcome from this limitation by changing a bit of code in some.

Now we will discuss what are the limitation of web service, so we need WCF.However it does not meant web service gets depreciated over WCF. It is still widely used. Our main objective to lighting on limitation of web services over WCF. As following table depicts:

Difference between WCF and Web service


Web service is considered as subset of WCF. WCF offers much more flexibility and portability to develop a required service when comparing to web service. There are more advantages of WCF over Web service; following table provides detailed difference between them.

Features
Web Service
WCF
 For Hosting
It  can be hosted in IIS server
It can be hosted in on many servers like IIS, windows activation service, Self-hosting, Windows service
 In term of Programming
[WebService] attribute has to be added to the class, in order to create class as web services
On the other hand in WCF,[ServiceContract] attribute has to be added to the class for creating Windows communication Foundation
Model
[WebMethod] attribute represents the method exposed to client.(i.e. this method Is now visible to the service consumer)
[OperationContract] attribute represents the method exposed to client
Operation mode
One-way(Simplex communication mode) Request- Response are the different operations supported in web service
One-Way, Request-Response, Duplex are different type of operations supported in WCF
XML serialization
System.Xml.serialization name space is used for serialization
System.Runtime.Serialization namespace is used for serialization
Encoding Scheme
XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom
XML 1.0, MTOM, Binary, Custom
Transports feature
Can be accessed through HTTP, TCP, Custom
Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
Protocols
Security
Security, Reliable messaging, Transaction

1 comment: