Introduction
In this article, I'm going to explain how to create a Web Service in Notepad. This will perhaps help you when you are asked in an interview to create a sample Web Service in C# using Notepad.
Using the code
Just follow the steps below. It's an easy and simple exercise.
Step 1
Open Notepad and start typing. In the first line, include the Directory tag as follows:
<%@ WebService Language="C#" Class="MyClass" %>
Step 2
Type the code below in Notepad below the above line:
using System;
using System.Web.Services;
public class MyClass : System.Web.Services.WebService
{
public MyClass()
{
}
public string HelloWorld()
{
return "Hello Welcome to the World";
}
}
Step 3
Check whether your class name and the name in the directory section are the same.
Step 4
Save the Notepad file as "MyWebService.asmx". Don't forget to save the file with the extension ".asmx".
How to access the Web Service
- Copy the Web Service into the WWWRoot folder.
- Open a new project. Select Solution Explorer.
- Add a WebReference. In that, select Available in local machine.
- That will list out the available Web Services. Pick the one you created just now.
That's it.
Points of Interest
This demo shows how to create a Web Service without the help of VS.NET. As we know, Web Services can be written/created in any language. I have written this Web Service in C#.