The SOAP::Lite Perl Module

advanced tipscreenshot tip52.gif

Installing the SOAP::Lite Perl module, backbone of the vast majority of tips in this tutorial.



SOAP::Lite (http://www.soaplite.com) is the defacto standard for interfacing with SOAP-based web services from Perl. As such, it is used extensively throughout this tutorial; just about all the tips in the Google Web API Applications [] section are written in Perl using SOAP::Lite.

SOAPing your ISP

It's unfortunately not that common for internet service providers (ISPs) to make SOAP::Lite available to their users. In many cases, ISPs are rather restrictive in general about what modules they make available and scripts they allow users to execute. Others are rather more accomodating and more than willing to install Perl modules upon request. Before taking up your time and brainpower installing SOAP::Lite yourself, check with your service provider.

Installing SOAP::Lite

Probably the easiest way to install SOAP::Lite is via another Perl module, CPAN, included with just about every modern Perl distribution. The CPAN module automates the installation of Perl modules, fetching components and any prerequisites from the Comprehensive Perl Archive Network (thus the name, CPAN) and building the whole kit-and-kaboodle on the fly.


CPAN installs modules into standard system-wide locations and, therefore, assumes you're running as the root user. If you have no more than regular user access, you'll have to install SOAP::Lite and its prerequisites by hand (see Unix installation by hand).


Unix and Mac OS X installation via CPAN

Assuming you have the CPAN module, have root access, and are connected to the Internet, installation should be no more complicated than:

% su
Password:
# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.52)
ReadLine support available (try ``install Bundle::CPAN'')
cpan» install SOAP::Lite

Or, if you prefer one-liners:

% sudo perl -MCPAN -e 'install SOAP::Lite'

In either case, go grab yourself a cup of coffee, meander the garden, read the paper, and check back once in a while. Your terminal's sure to be riddled with incomprehensible gobbledegook that you can, for the most part, summarily ignore. You may be asked a question or three; in most cases, simply hitting return to accept the default answer will do the trick.

Unix installation by hand

If CPAN installation didn't quite work as expected, you can of course install SOAP::Lite by hand. Download the latest version from SOAPLite.com (http://www.soaplite.com/), unpack, and build it like so:

% tar xvzf SOAP-Lite-latest.tar.gz
SOAP-Lite-0.55
SOAP-Lite-0.55/Changes
...
SOAP-Lite-0.55/t/37-mod_xmlrpc.t SOAP-Lite-0.55/t/TEST.pl
% cd SOAP-Lite-0.55
% perl Makefile.PL
We are about to install SOAP::Lite and for your convenience will 
provide you with list of modules and prerequisites, so you'll be able 
to choose only modules you need for your configuration.
XMLRPC::Lite, UDDI::Lite, and XML::Parser::Lite are included by default.
Installed transports can be used for both SOAP::Lite and XMLRPC::Lite.
Client HTTP support (SOAP::Transport::HTTP::Client) [yes]
Client HTTPS support (SOAP::Transport::HTTPS::Client... [no]
...
SSL support for TCP transport (SOAP::Transport::TCP) [no]
Compression support for HTTP transport (SOAP::Transport... [no]
Do you want to proceed with this configuration? [yes] 
During "make test" phase we may run tests with several SOAP servers 
that may take long and may fail due to server/connectivity problems. 
Do you want to perform these tests in addition to core tests? [no] 
Checking if your kit is complete...
Looks good
...
% make
mkdir blib mkdir blib/lib
...
% make test
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/System/Library/Perl/darwin -I/System/Library/Perl -e 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;'
t/01-core.t t/02-payload.t t/03-server.t t/04-attach.t t/05-customxml.t t/06-modules.t t/07-xmlrpc_payload.t t/08-schema.t t/01-core...........
...
% su
Password:
# make install
Installing /Library/Perl/XMLRPC/Lite.pm Installing /Library/Perl/XMLRPC/Test.pm
...

If, during the perl Makefile.PL phase, you run into any warnings about installing prerequisites, you'll have to install each in turn before attempting to install SOAP::Lite again. A typical prerequisite warning looks something like this:

Checking if your kit is complete...
Looks good Warning: prerequisite HTTP::Daemon failed to load: Can't locate HTTP/Daemon.pm in @INC (@INC contains: /System/Library/Perl/darwin
/System/Library/Perl /Library/Perl/darwin /Library/Perl /Library/Perl
/Network/Library/Perl/darwin /Network/Library/Perl
/Network/Library/Perl .) at (eval 8) line 3.

If you've little more than user access to the system and still insist on installing SOAP::Lite yourself, you'll have to install it and all its prerequisites somewhere in your home directory. ~/lib, a lib directory in your home directory, is as good a place as any. Inform Perl of your preference like so:

% perl Makefile.PL LIB=/home/login/lib

Replace /home/login/lib with an appropriate path.

Windows installation via PPM

If you're running Perl under Windows, chances are its ActiveState's ActivePerl (http://www.activestate.com/Products/ActivePerl/). Thankfully, ActivePerl's outfitted with a CPAN-like module installation utility. The Programmer's Package Manager (PPM, http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/) grabs nicely packaged module bundles from the ActiveState archive and drops them into place on your Windows system with little need of help from you.

Simply launch PPM from inside a DOS terminal window and tell it to install the SOAP::Lite bundle.

C:\»ppm
PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM» install SOAP::Lite

If you're running a reasonably recent build, you're probably in for a pleasant surprise:

C:\»ppm
PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM» install SOAP::Lite
Version 0.55 of 'SOAP-Lite' is already installed.

SOAP::Lite Alternatives


Having trouble? Perhaps your ISP doesn't deem SOAP::Lite worthy. Attempts at installing it yourself have you pulling out your hair?

While SOAP::Lite is the preferred method for interfacing with the Google Web API - and, indeed, web services in general. That said, it'd hardly be fair of us to leave you high and dry, unable to tuck in to this comprehensive collection of Google Tips.

Never fear, there's more tipery afoot. PoXML [Tip #53], our home-brewed, lightweight Perl module treats Google's SOAP as plain old XML, using the LWP::UserAgent module to make HTTP requests and XML::Simple to parse the XML response. Going one step further, our NoXML [Tip #54] doesn't even require an XML parser (gasp!), doing all its work with regular expressions. And then there's XooMLe [Tip #36], a third-party service offering an intermediary plain old XML interface to the Google Web API. Each of these alternatives provides a drop-in replacement for SOAP::Lite with little more than a two-line alteration to the tip.