Home/MVC/Creating simple WCF Service

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.

READ  Confirmation message after clicking the ActionLink in MVC

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

READ  store array in viewbag and retrieving in the view

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!!!”;
}

READ  Bundling and minification

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

Leave A Comment