How to Create a Simple Web Service in ASP.NET

Introduction

In This Tutorial We will be creating a Web Service. In the next tutorial we will learn how to “Consume” the Web Service that we create here.

Step 1. Create a Web Service

We need to create a web service by right clicking on the project and selecting Add then Selecting New Item. Select Web Service and name it “MyService.asmx”. now go into the Web Service code and paste the following code in there. Note in some versions of Visual Studio this function might already be there, if so move on.

Step 2. Invoking the Function

Now that we have created a simple web service we need to test it out and make sure the function works. Go ahead and run this page then select Hello world and then press the Invoke button. You should see the words Hello World on the screen.

Conclusion

So we have no created a simple web service and in the next tutorial we will learn how to reference this service and Consume it so that we can call it’s functions.

Download Source Files