Creating a Web Service with Web Matrix - Testing the web service with built-in mini web server
(Page 2 of 4 )
This is a functioning web service. If a client calls this web service by sending two arguments, a and b to it, the service will return the result of adding a to b and send the result to the client. You may run this program after saving the file by clicking the little blue arrow in the main menu of ASP.NET Web Matrix. You can recognize this by placing the mouse over this blue arrow. You should see a pop-up showing "Start." When you click this arrow, the following window pops up.

The default radio button option will open up a mini-web server (I believe it is called Cassini) with the port set to 8899. You may change this port if you want. The mini web server can only have web pages from the local machine created in Web Matrix.
The other radio button will create a virtual root on your IIS, assuming you have one. With this you may be able to write a client to consume the web service created in Web Matrix. If you click on the Start button in the above window, you will see the following displayed in your browser. Notice that the URL is that of the mini web server, http://localhost:8899/test.asmx. The service name is the same as the class name. The method Add () is shown as a hyperlink. The Service Description is another hyperlink on this display. The page is truncated to conserve space, but at the very bottom of the page there are hyperlinks giving you access to the various standards that make this web service possible. If you are planning to work with web services it is recommended that these should be reviewed.

If you now click on Add, your browser will display the following page. In this page you may test the functionality of your web service.

If you insert values for a=3 and b=4 and click Invoke, the method will be invoked passing these values, and the resulting display returns the value as shown in an XML format. This is just for testing the service locally. This is not how it will be used in practice. In practice, the client (aka consumer of the service) sends the values a and b through some mechanism. This mechanism may be a web page, a Windows form, or some type of message. The service will return a suitable response after processing.

Now you click on the other hyperlink, Service Provider. You will get a screen full of information about this web service with the URL pointing to: http://localhost:8899/test.asmx?WSDL. WSDL stands for Web Services Discovery Language, a protocol that helps with finding the details about a service. This tutorial format is somewhat limited to explain the details. You may notice that the nodes are collapsed and there is a lot of information hidden in the file. You may also review my other article at the ASP FREE site, Encoding/Decoding Web Service which shows how to create a Web Service in Visual Studio 2003.

Next: Second example: the Pythagoras Theorem >>
More XML Articles
More By Jayaram Krishnaswamy