This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
in SOAP::Lite abstracts a considerable amount of detail from the developer’s point of
No matter which server class is used by an application, it will be necessary to create a
server object (at least one) and associate local (server-side) routines to be called for
the incoming requests. Like the client classes described in the previous chapter, the
server classes are designed so that the constructor is called automatically when
needed. Explicit calls to
new aren’t that common (except in educational examples, of
objects_by_reference method used earlier is one of several ways serv-
ers can be associated with local subroutines. Various examples later on will show the
different techniques and compare their benefits and features.
Each of the server classes has some variation of the
handle method. In most cases, it
is a loop that continues indefinitely while waiting for incoming connections.
Chapter 8 which discusses the non-HTTP server classes, will show some examples
that operate differently.
The rest of this chapter will proceed to design and build a simple server application.
This application will not only demonstrate basic server aspects, it will also be used to
illustrate the kinds of considerations that come into play when designing code to be
used in a web service. It will also be the basis for the examples in Chapter 8.
The sample application maintains a “wish list,” or shopping list, of books at a web-
based storefront. For the sake of this chapter, the design goals are kept on the simple
side. The server provides the following functionality:
• Get the current wish-list contents in an abbreviated form.
• Pull the data record for a given entry on the wish list.
• Add and remove entries from the list.
• If the user already has billing and shipping information on file, they should be
able to trigger the purchase of one or more items from the list.
In the last requirement, the server doesn’t handle all the issues around securely
receiving a credit-card number or other confidential information. Instead, if the
user’s customer record indicates that they have all the needed information already on
file, they are given the chance to easily make the purchases. The server also allows
some operations that aren’t user-specific:
• Search for books by author or title, each using substring matching.
• Retrieve a limited subset of information on a given book, less than what is given
to registered users but enough to be useful to some extent.