Section 15.5. Deriving from the WebService Class

15.5. Deriving from the WebService Class

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:



Application and Session

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.



User

This object is useful for authenticating the caller of a web service. For a complete discussion of security, see Chapter 12.



Context

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.



Programming ASP. NET
Programming ASP.NET 3.5
ISBN: 0596529562
EAN: 2147483647
Year: 2003
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net