How to test a web service in ASP.NET

When you want to test a web service in ASP.NET, you don’t need to write a dedicated client application. You can use a test page that ASP.NET uses automatically when you request the URL of an .asmx file in a browser.  In Visual Studio you need to set the .asmx file as the start page for your application and then run it. The next picture shows a test page with two web methods and their descriptions, and the page’s title is the name of the web services:

 

The web service test page

The web service test page

The next picture shows he page that allows you to test the GetBooksCount() method:

 

Testing a web method

Testing a web method

When you click the Invoke button, a new web page appears with an XML document that contains the requested data, presented by the next picture. If you look at the URL, you can see that it incorporates the .asmx file, followed by the web service method name:

 

The results for GetBooksCount()

The results for GetBooksCount()