What is Windows Communication Foundation

From msdn,Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

An endpoint can be a client of a service that requests data from a service endpoint.

Creating Service

Here i am creating WCF service out side of the application(ie., Toย  be host in IIS, to useย  service by other end)

Step 1:

Open File -> New -> Project (choose WCF Workflow Service Application) like shown below image

Creating WCF 1

Step 2:

After successful creation of project, project hierarchy will shown like below

Creating WCF 2

Step 3:

Let we write the operationcontract in the IService1.cs to consume in the other end point

[OperationContract]
string DisplayUserName(string name);

and then define this contract in the Service1.svc.cs

public string DisplayUserName(string cusName)
{
return “Welcome” + cusName +”to our site!!!”;
}

Output :

After code level completion, check whether its running correctly or not by open the Service1.svc.cs and the press F5 like below, then it will list out the service methods.

Creating WCF 3