SIGN UP MEMBER LOGIN:    
ARTICLE

Steps Towards Windows Communication Foundation: Part 2

Posted by Krishna Garad Articles | WCF with C# March 22, 2011
In this article we will see some basic of Windows Communication Foundation .
Reader Level:


Introduction:

My previous article was an introduction to WCF, including it's history. This article is about some basics of Windows Communication Foundation .

Windows Communication Foundation:

WCF is nothing but the distributed programming between .Net to any user with their own proprietary methods. For a .Net user today to develop a service WCF is the only preferred way. In general you can say:

WCF=.Net Remoting + Web Service + New Standard.

WCF in simple terms:

  1. One stop-shop for service.
  2. Consistent object model.
  3. Great feature.

Next Generation of ASMX is WCF:

The unified framework for rapidly building service-oriented applications. WCF is provided as a framework with it's own runtime & libraries. A .Net component is executed using CLR but the request-response will be handled by the WCF framework. It is built on the top of the .Net framework.

How WCF provides this communication environment?:

Every WCF application that we develop includes the following structure/components that provides it's communication model.

1. Endpoint:

This is a structure which provides info about service (program). Endpoint includes three things and they are easily referred to as 'ABC'.

A- Address:

A network address where the endpoint resides.

Example:

http://csharpcorner.com/services/stepwcf.svc.
Net-tcp://192.168.100.5/myservice/stepwcf.svc

B- Binding:

Specify how the endpoint communicates with the world. As well defines the following three things.
  1. Transport (eg. Http , Tcp)
  2. Encoding (Text , Binary)
  3. Security Option(SSL, Message Security)

C- Contract:

Specify what Endpoint communicates.
  1. Message exchange pattern (One-way, Duplex).
  2. Service Operation.
  3. Service Behavior (Exchange Meta-Data, Impersonate Authorization).

2. Service Contract:

This is the most important attribute; it adds all WCF functionality to our component so that it can be exposed as a contract for the Endpoint.

Example:

[ServiceContract]
Class Employee
{
}

3. Operation Contract:

Again an attribute which makes an operation exposed in our service. This attribute is written to method of [ServiceContract] Class.

Example:

[ServiceContract]
Class Employee
{
[OpearationContract]
Void Delete();
}

If we do not write an operation contract then those methods are accessible only within the .Net class; not to the outside world.

4. Data Contract:

In operationcontract or WCF enabled methods if we are using any complex types to represent either Data/Action then we must declare them as DataContract.

Example:

[OpearationContract]
Public void Add(Job j);
{}

[DataContract]
Class Job
{}

Conclusion:

In this article we have seen some basic steps of the Windows Communication Foundation. In my next article we will see: how to create our own service using WCF? How to host this service? How to consume the service created using WCF?

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor