14.1. Creating a Web Service
You want to create your own web service.
Use Visual Studio 2005 to create a new web service and then add methods to expose the functionality required for your web service.
To create the new web service:
On the Visual Studio 2005 File menu, choose New → Web Site….
When the New Web Site dialog box is displayed, select the ASP.NET Web Site template, the desired language, and the location for the web site.
Right-click on the new web site in the Solution Explorer, select Add New Item, and select the Web Service template.
Enter the name of the web service in the Name text box, select the desired language, and click Add.
Visual Studio 2005 creates a folder for the web site that contains an .asmx file and code-behind files for the web service, like those shown in Examples 14-2, 14-3, 14-4 through 14-5. The web service is fully functional at this point but is a shell with no useful functionality.
Visual Studio 2005 places the code-behind files for web services in the App_Code directory instead of placing them in the same folder as the .asmx file, as Visual Studio 2003 did.
You need to add methods to the code-behind to expose the functionality required for your web service. The code-behind shown in Examples 14-6 (VB) and 14-7 (C#) shows a method we have added to our example web service to return a list of books from a database.
You can add a web service to an existing web application by selecting the web site in the Solution Explorer and then selecting ...