.netWCF

Create,Test and Access WCF web service in DOT NET 4.5

How to create a WCF web service using C#

Here are the steps to create a simple WCF web service in C#.

Open visual studio .net

Click on File–>New–>Project

Select C#–>WCF–>WCF service Library

 

ASP2

For any service there should be an operation contract and operation contract attributes defined

ASP3

Make the change in contract: change int to string in Iservice1.cs

ASP4

Add the below code snippet to service1.cs

ASP5

Testing the Web Service:

Press F5 to run the service

ASP6

In the WCF Test Client form, double-click the GetData() method under IService1. The GetData tab will be displayed.

In the Request box, select the Value field and type 10.

Click the Invoke button. If a Security Warning dialog box is displayed, click OK. The result will be displayed in the Response box.

ASP7

On the File menu, click Exit to close the test form

How to Access the web service:

On the File menu, point to Add and then click New Project.

In the New Project dialog box, expand the Visual Basic or Visual C# node and select Windows, and then select Windows Forms Application. Click OK to open the project.

 

Right-click WindowsApplication1 and click Add Service Reference. The Add Service Reference dialog box will appear.

In the Add Service Reference dialog box, click Discover.

ASP9

Click Ok to add service reference.

© 2015, www.techkatak.com. All rights reserved.

One thought on “Create,Test and Access WCF web service in DOT NET 4.5

Comments are closed.