
66
|
Chapter 4: Web Services
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
An important difference between the single-file web service and the code-behind
implementation is that for the code-behind version, you must compile the code-
behind class into an assembly manually and place it in the bin directory before the
web service will work. Note that this step is automatic when you build a web
service project in Visual Studio .NET. If you’re writing code by hand, this step can
be accomplished by using a DOS batch file containing the commands shown in
the following snippet:
vbc /t:library /r:System.Web.dll /r:System.dll /r:System.Web.Services.dll /
r:System.Xml.dll /r:System.Data.dll /out:bin\qotd_cb.dll qotd_cb.vb
pause
Note that all command-line options for the vbc.exe compiler should be part of a
single command. The
pause command allows you to see any warnings or errors
generated during compilation before the command window is closed.
Inheriting from WebService
In Example 4-1, the Current property of the HttpContext class is used to get a
reference to the Context object for the current request. Getting this reference is
necessary to access to the Server intrinsic object so that we can call its MapPath
method to get the local path to the XML file used to store the quotes. However, as
you add more methods that use the XML file, you end ...