In the StockTickerSimple web service, with the class file listed in Example 15-4, the Service class inherits from the WebService class.
Deriving from the WebService class is optional, but it offers several advantages. The principal one is that you gain access to several common ASP.NET objects:
These objects allow the application to take advantage of state management. For a complete discussion of state management, see Chapter 6. State as it pertains specifically to web services will be covered in more detail later in this chapter.
This object is useful for authenticating the caller of a web service. For a complete discussion of security, see Chapter 12.
This object provides access to all HTTP-specific information about the caller's request contained in the HttpContext class.
The main reason you might not want to inherit from WebService is to overcome the limitation imposed by the .NET Framework that a class can only inherit from one other class. Multiple inheritance is not supported. It would be very inconvenient to have to inherit from WebService if you needed to inherit from another class.