WCF BASICS-1

Step towards Windows Communication Foundation Part-2

Introduction:

In previous article we have seen what is WCF? How it’s came in programming all the things. In this  article we will see some basic 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 .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 Simple Term:

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 application. WCF is provided as a framework with it’s own runtime & libraries. .Net component is executed using CLR but the request-response will be handled by the WCF framework. It is built on the top of .Net framework.

How WCF provides this communication environment?:

Every WCF application that we develop includes following structure/components using which it provides it’s reach communication model.

1) Endpoint:

This is a structure which provide info about service(program). Endpoint includes three things and they are easily referred as ‘ABC’.

A- Address:

A network address where the endpoint resides.

Exam:

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 most important attribute which adds all WCF functionality to our component so that it can be exposed as a contract in Endpoint.

Ex:

[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.

Ex:

[ServiceContract]

Class Employee

{

[OpearationContract]

Void Delete();

}

If we do not write operation contract then those methods are accessible within .Net class only not to 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.

Ex:

[OpearationContract]

Public void Add(Job j);

{}

 

[DataContract]

Class Job

{}

Conclusion:

In this article we have seen some basic step towards Windows Communication Foundation. In second 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?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s