In this post, we are going to discuss how to create a web service in asp.net using the C# programming language. You just follow the given steps to create a simple hello world web service using C# in visual studio IDE. Before we get started, if you want to know about the activation serial key of visual studio, please go through the following article: Activation Key of Visual Studio 2017.

Step 1: Create a project

Open visual studio >> Select File >> New >> Web Site >> Select ASP.NET Web Service

Step 2: Check folder Structure

Web service has been created and the visual studio would create configuration files and other files by default but make sure the files are created without any issues and no file is missing.

Step 3: Add/update web methods in Service.asmx

Open Service.asmx, it would have the default web method ‘HelloWorld’ created. Let us change the web method name to ‘sayHello’ and this method will accept one parameter which is going to be String. The method will return the text ‘Hello’ appended with the String passed as a parameter to it.

Step 4: Run Webservice

Let us run the web service we created. Click on the ‘Start Debugging’ button or press ‘F5′, select Run without debugging. It will open up a browser where the Service we created will be rendered under the URL: http://localhost:23027/SampleService/Service.asmx.

Step 5: Test Webservice

It’s time to test the web service we created, click ‘sayHello’ operation. It will open a web page the web method invocation can be done. Enter the name in the Name textbox and click invoke button. It will open up a new window where the response will be rendered as XML.

How to create web service in ASP.NET using C#

The article was published on October 23, 2019 @ 7:10 PM

Leave a Comment