Sunday, January 30, 2011

A basic tutorial for WCF: Windows Communication Foundation

What is WCF:  Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for your services, enabling you to expose CLR types as services, and to consume other services as CLR types
WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on operation systems that support it.

Why do we need this: This is the latest SOA technologies and it combines the features of Web Service,MSMQ,Remoting and COM+.
It provides a common plateform for all .NET communication. Interoperability is the fundamental characteristics of WCF.

ABC's of WCF: The 3 parts of the WCF. Address, Binding and Contract.
Address: Address is the address of the service. like (http://localhost:61685/Service1.svc)
Binding: It has number of binding models. It specifies the protocol to communicate.
Contract: Contract is the method exposed to the client. It gives the Data member serialization this is the main reason that it is faster than Webservice.

It includes Service Contract, Operation Contract and Data Contract

[Service Contract]: This attribute define saying which application interface will be exposed as service.
[Operation Contract]: It defines which method should be exposed to the external client, using this service.
[Data Contract]: Data Contract  defines which type of complex data will be exchanged between the client and server.

The sample code is not a simple "Hello World" application. The sample includes a login system application.
It includes  WCF host and one client. The host authenticate the user against a username and password, checked by WCF host and returns a boolean variable.The client includes a username and password screen, where user can put the username and password to authenticate the client application.


 


Download Code