Google Hacks Free Open Book

Google Hacks

Previous Section Next Section

Hack 52 The SOAP::Lite Perl Module

figs/expert.giffigs/hack52.gif

Installing the SOAP::Lite Perl module, backbone of the vast majority of hacks in this book.

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 book; just about all the hacks in the Google Web API Applications [Chapter 6] section are written in Perl using SOAP::Lite.

52.1 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.

52.2 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).

52.2.1 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.

52.2.2 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.

52.2.3 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.

52.3 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 Hacks.

Never fear, there's more hackery afoot. PoXML [Hack #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 [Hack #54] doesn't even require an XML parser (gasp!), doing all its work with regular expressions. And then there's XooMLe [Hack #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 hack.

    Previous Section Next Section


         Main Menu
    Main Page
    Table of content
    Copyright
    Dedication
    Credits
    Foreword
    Preface
    Chapter 1. Searching Google
    Chapter 2. Google Special Services and Collections
    Chapter 3. Third-Party Google Services
    Chapter 4. Non-API Google Applications
    Chapter 5. Introducing the Google Web API
    5.1 Hacks #50-59
    5.2 Why an API?
    5.3 Signing Up and Google's Terms
    5.4 The Google Web APIs Developer's Kit
    5.5 Using the Key in a Hack
    5.6 What's WSDL?
    5.7 Understanding the Google API Query
    5.8 Understanding the Google API Response
    Hack 50 Programming the Google Web API with Perl
    Hack 51 Looping Around the 10-Result Limit
    Hack 52 The SOAP::Lite Perl Module
    Hack 53 Plain Old XML, a SOAP::Lite Alternative
    Hack 54 NoXML, Another SOAP::Lite Alternative
    Hack 55 Programming the Google Web API with PHP
    Hack 56 Programming the Google Web API with Java
    Hack 57 Programming the Google Web API with Python
    Hack 58 Programming the Google Web API with C# and .NET
    Hack 59 Programming the Google Web API with VB.NET
    Chapter 6. Google Web API Applications
    Chapter 7. Google Pranks and Games
    Chapter 8. The Webmaster Side of Google
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele