Creating a Simple Web Service

Though a web service has no user interface and no visual component, the architecture and files used to create a web service are similar to those used to create a web page, which are described in detail in previous chapters. Some of these similarities include the following:

  • Full implementation of the .NET Framework and Common Language Runtime (CLR), including the object-oriented architecture, all the base class libraries, and features such as caching, state, and data access

  • Nearly identical file and code structures

  • All source code files in plain text, which can be created in any text editor

  • Full support by VS2005, with all its productivity features, including IntelliSense, code completion, and integrated debugging

  • Configurable on a global or application-wide basis using plain-text configuration files and the Web Site Administration Tool in VS2005

That said, web pages and web services are conceptually very different. A web page entails an interface designed for interaction with a person sitting at a web browser. A web service, on the other hand, consists only of methods, some of which are available for remote calls by client applications.

A web service can be coded in-line, in a single file with an extension of .asmx. Alternatively, the application logic of the web service can be segregated into a code-behind file, which is the default behavior of VS2005. One in-line example will be shown here, to aid in your understanding of how web services work, but all the ...

Get Programming ASP.NET, 3rd Edition 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.