Creating simple WCF Service

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.