Creating Web Services

You can create an ASP.NET Web Service using the Visual Studio .NET interface by selecting the option to create a Web Service and specifying the name of the Web server, as show in Figure 7.3 (here, the server being used is the localhost).

Figure 7.3. Specification of a new Web Service within Visual Studio .NET.

To create a Web Service, you create a file with an .asmx extension. You then need to perform the following steps:

1.
Mark the class that should be available via the Web Service by using the WebService attribute. For example:
 [WebService(Namespace="http://NetExam.org/StringProc")] public class Strings : System.Web.Services.WebService ...

Get Developing and Implementing Windows®-Based Applications with Visual C#™ .NET and Visual Studio® .NET Exam Cram™ 2 (Exam 70-316) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.