7.1 Basic SOAP::Lite Servers


Clients are good examples to use when getting started with the toolkit, but without any servers out there, there would be nothing for the clients to connect to. So, what approaches and methods are there in this toolkit for designing servers? The short answer is many . The longer answer will span this chapter and the next .

The following snippet illustrates the elements most commonly seen in a server built using any of the SOAP::Lite server classes:

 # Bring in the server class to be used use SOAP::Transport::HTTP; # Create a simple server object my $daemon = SOAP::Transport::HTTP::Daemon      ->new(LocalAddr => localhost => LocalPort => 9000)      ->objects_by_reference('Example::Class')      ->handle; 

As the server example in this chapter is developed, then ported to other transport protocols in the next chapter, this same basic structure will recur. The server support in SOAP::Lite abstracts a considerable amount of detail from the developer's point of view.

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 course). The objects_by_reference method used earlier is one of several ways servers 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.



Programming Web Services with Perl
Programming Web Services with Perl
ISBN: 0596002068
EAN: 2147483647
Year: 2000
Pages: 123

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