Creating a Web Service with Web Matrix
(Page 1 of 4 )
The Web Matrix project appears to have served as a test bed in the development of ASP.NET. This freebie attracted a lot of attention since it did not require an installation of IIS. It had its own http server whenever needed. Of course, one could use it also in the presence of an installed IIS. This tutorial is about creating a web service on Web Matrix and testing the service on the built in mini web server, as well as testing a second example on the IIS 5.1 on the local machine.
Create a file of type XML Web Service: Default Example
When Web Matrix starts, click on File -> New File.... The window for adding a new file, Add New File, opens, presenting a number of types of files you can add. It also shows the folder tree on the right where you can save the file you are adding. Before creating a new file, pick the type of file you want to create. In this case a XML Web Service file is chosen as shown. Since it is a service without any visible controls, the file will be compiled as a class file and requires a class name, hence give a class name that can be remembered; here it is given the value hteksamples which is arbitrary.
You can give a namespace to collect together a set of related classes. Since there is only one class created here, you may give any name for this; it is given the value HODENTEK. Add New File adds a new web service file, test.asmx file as shown to the C:AspApril04 folder (after you click OK to this window). All web service files will have the extension .asmx. The Workspaces window is where the tree view of folders is shown. Under the Workspaces window you will see the Classes window where all the classes starting from System are shown.

When you click OK to the above, the code for the class file you are going to create will open in the code view with a default web service. The service will have a WebMethod having a function name, Add () as shown. This area where you see the code is a text editor where you can make changes. You may notice that all the imports statements have been added by the Web Matrix IDE. You will see the class name we gave is at the very top of this page. The language attribute is 'VB', but you can also use C# or J#.

Next: Testing the web service with built-in mini web server >>
More XML Articles
More By Jayaram Krishnaswamy