How to Create WCF Service in Visual Studio 2013

In this article, I am explain how to use WCF service.

First Open Visual Studio 2013. Create New Project and select WCF Service Application and give name WCFdemo.


WCF SERVICE

Then Click ok. Now In Solution Explorer Right Click on WCFdemo project and Add New Item ADO.net entity data model.


ado.net data model

Add Database here and select Table.


Entity data model

Now Your Solution explorer look like this.


wcf

Now Add New item WCF Service.

wcf service

Select WCF Service and give name.

wcf service

Now EmployeeServices.svc and IEmployeeServices.cs file add in solution explorer.

Create wcf service

Now Open EmployeeServices.svc.cs file and write following code.

wcf service

Here Employee is my database table and m9codersEntities is entity name.

Now Open IEmployeeServices.cs and write method name of EmployeeServices.svc.cs file.

interface in wcf

Now Build Project. (shortcut- F6)

Now Run EmployeeServices.svc file.(ctrl+F5)  

Then Open WCF Client popup window.

wcf test client

And your Service Adding...

wcf test client

After Service added successfully then copy url and paste into your browser.

wcf test service

You can see your all Method here and now use in any project.

In Next article i will explain how to use wcf service in MVC.


Post a Comment