Cover | Table of Contents | Colophon
expedia.com and tvguide.com, but that puts you at the mercy
of the web designers of those sites. Every time they decide to make
their pages look prettier, you'll have to rewrite
your screenscraper.
XMLRPC::Lite toolkit:
#!/usr/bin/perl -w
use XMLRPC::Lite;
$client = XMLRPC::Lite
->proxy('http://www.oreillynet.com/meerkat/xml-rpc/server.php')
->on_fault(sub { die "Transport error: " . $_[1]->faultstring });
$resp = $client->call('meerkat.getItems',
{ 'search' => '/[pP]erl/',
num_items => 5,
descriptions => 75 })->result( );
foreach $story (@$resp) {
print $story->{description}, "\n";
print " ", $story->{link}, "\n";
print "\n";
}
Deploy USE_GNOMENG infrastrcuture o USE_REINPLACE instead of PERL o Mark http://www.FreshPorts.org/audio/freebirth/ Support for merging, speed improvements, support for XTMPath, and LTM. http://www.garshol.priv.no/download/xmltools/prod/XTMBase.html Michael Stevens compares two popular mail filtering tools, both written in http://www.perl.com/pub/a/2002/08/27/filtering.html Directory layouts of py-gtk and py-gnome packages have been changed, so tha http://www.FreshPorts.org/mail/pmail/ Directory layouts of py-gtk and py-gnome packages have been changed, so tha http://www.FreshPorts.org/editors/moleskine/
book),
attributes (isbn), and data
("Programming Web Services with
Perl"):
<book isbn="0596002068">Programming Web Services with Perl</book>
é for the character
é.
http://www.xmlrpc.com, is a good source for
more history of the specification. It also features links to various
toolkits and the current specification as well.
http://www.xmlrpc.com, is a good source for
more history of the specification. It also features links to various
toolkits and the current specification as well.
i4 and int may be considered
distinct), and also supports serialization of arrays and structures
(name/value pairs just like Perl's hashes). The data
types are explained in Table 3-1.
http://meerkat.oreillynet.com and then
customize the way the news content is presented. From the browser
interface, it is possible to select not only the channels themselves
but also to fine-tune the set of stories that are chosen for display
by applying a search pattern (which can in fact be a regular
expression) as a filter against the list. For example, a filter of
"perl" against the stories from the
"Scripting News" channel limits the
results to just the stories that mention Perl.
http://www.xmlrpc.com is the single and
definitive source for evaluating a claimant to the stamp of XML-RPC
compatibility.
Content-Length header. This
method is often used with streaming content models such as multimedia
types, but it can also be used in cases in which an application wants
(or needs) to start the transmission of data before the complete
length of the response is known.
Frontier::RPC2 package by
Ken MacLeod. The name refers to the original system the package was
intended to support, the Frontier content management system from
UserLand Software, the source of the XML-RPC specification itself. In
mid-2002, the package was taken over by a new maintainer. The time
proved right for renaming the modules, and now the module is known as
RPC::XMLSimple.
XMLRPC::Lite component of the
SOAP::Lite package for Perl. Support for XML-RPC
was added at a later point than the SOAP components themselves, but
the functionality builds on the framework that the author, Pavel
Kulchenko, had already created to support the SOAP standards. As a
result, it integrates very smoothly, and benefits from elements
already present in SOAP::Lite, such as a pure-Perl
XML parser that can be used when none of the CPAN-based XML modules
are available.
RPC::XML package. Like
the RPC::XMLSimple package, this module requires
that the XML::Parser module from CPAN be
installed. It doesn't provide a native XML parser
the way XMLRPC::Lite does. It relies on the
LWP package for client transport, but on the
server side it can work with the Frontier::RPC2 package by
Ken MacLeod. The name refers to the original system the package was
intended to support, the Frontier content management system from
UserLand Software, the source of the XML-RPC specification itself. In
mid-2002, the package was taken over by a new maintainer. The time
proved right for renaming the modules, and now the module is known as
RPC::XMLSimple.
XMLRPC::Lite component of the
SOAP::Lite package for Perl. Support for XML-RPC
was added at a later point than the SOAP components themselves, but
the functionality builds on the framework that the author, Pavel
Kulchenko, had already created to support the SOAP standards. As a
result, it integrates very smoothly, and benefits from elements
already present in SOAP::Lite, such as a pure-Perl
XML parser that can be used when none of the CPAN-based XML modules
are available.
RPC::XML package. Like
the RPC::XMLSimple package, this module requires
that the XML::Parser module from CPAN be
installed. It doesn't provide a native XML parser
the way XMLRPC::Lite does. It relies on the
LWP package for client transport, but on the
server side it can work with the HTTP::Daemon
package (from LWP), the
Net::Server package (from CPAN), or with Apache
and mod_perl directly as a
mod_perl
location-handler.
RPC::XMLSimple
module provides support code for the client and server classes,
RPC::XMLSimple::Client and
RPC::XMLSimple::Daemon. An application will
include only the server or client code, as needed. Both of those
modules already include the core elements.
XML::Parser
module to handle the XML data, and the LWP module
for both client communications and server functionality.
meer2html.pl tool from Chapter 3 using the toolkit instead of building and
parsing XML-RPC requests and responses manually. Comparing just the
length in lines of the two versions of the utility (with comments and
blank lines excluded), the Frontier version is less than half the
length of the manual version.
meer2html-Frontier.pl code. The sections shown are
those that differ significantly from the original version.
use RPC::XMLSimple::Client;
$client = RPC::XMLSimple::Client->new(url => MEERKAT);
sub show_data {
my $data = shift;
print STDOUT qq(<span class="meerkat">\n<dl>\n);
for (@$data) {
print STDOUT <<"END_HTML";
<dt class="title"><a href="$_->{link}">$_->Programming Web Services with Perl</a></dt>
<dd class="description">$_->{description}</dd>
END_HTML
}
print STDOUT qq(</dl>\n</span>\n);
}
sub resolve_name {
my ($str, $name) = @_;
$name = "meerkat.get${name}BySubstring";
my $resp = $client->call($name, $str);
die "resolve_name: $str returned more than 1 match"
if (@$resp > 1);
$resp->[0]{id};
}
sub get_data {
my ($key, $val, $num) = @_;
$client->call('meerkat.getItems',
{ $key => $val,
time_period => '7DAY',
num_items => $num,
descriptions => 200 });
}XMLRPC::Lite package is part of the
SOAP::Lite suite, written by one of the authors of
this book, Pavel Kulchenko. It shares much of the same underlying
architecture and structure as the SOAP package. As a result, it also
supports some transport protocols that aren't
officially part of XML-RPC, such as TCP/IP and the POP3 protocol.
This package is also the only one of the three toolkits that can be
used without dependency on an external XML parser. It will use the
faster XML::Parser if it is available, however.
SOAP::Lite itself. That
installation process is described in greater detail in Chapter 6 so it won't be covered here.
XMLRPC::Lite. Notice how similar it appears to the
RPC::XMLSimple version of this application (Example 4-1). The interface design of all the XML-RPC
toolkits are very similar, which should simplify switching between
them, if need be. As always, full code is available in Appendix C.
use XMLRPC::Lite;
$client = XMLRPC::Lite->proxy(MEERKAT)
->on_fault(sub { die "Transport error: " .
$_[1]->faultstring });
sub show_data {
my $data = shift;
print STDOUT qq(<span class="meerkat">\n<dl>\n);
for (@$data) {
print STDOUT <<"END_HTML";
<dt class="title"><a href="$_->{link}">$_->Programming Web Services with Perl</a></dt>
<dd class="description">$_->{description}</dd>
END_HTML
}
print STDOUT qq(</dl>\n</span>\n);
}
sub resolve_name {
my ($str, $name) = @_;
$name = "meerkat.get${name}BySubstring";
my $resp = $client->call($name, $str)->result;
die "resolve_name: $str returned more than 1 match"
if (@$resp > 1);
$resp->[0]{id};
}
sub get_data {
my ($key, $val, $num) = @_;
$client->call('meerkat.getItems',
{ $key => $val,
time_period => '7DAY',
num_items => $num,
descriptions => 200 })->result;
}RPC::XML package, developed by one of the authors
of this book, Randy J. Ray. This package isn't quite
as independent as the XMLRPC::Lite implementation;
it requires an external XML parser (currently the
XML::Parser package from CPAN).
RPC::XML::Server, can function as a standalone
server using either the HTTP::Daemon class from
the LWP package or the
Net::Server package from CPAN. This latter package
supports several different multiprocess models and provides all the
background operation for whichever model the application chooses to
use. Applications can even choose a model on-the-fly, rather than
being locked into a specific one. The RPC::XML
package also provides a server class designed especially to act as a
content handler for Apache and mod_perl.
RPC::XML
version of the Meerkat example isn't significantly
different from the other toolkits' versions. Example 4-5 shows the relevant parts of this version of
the script. Appendix C lists the full program.
use RPC::XML::Client;
$client = RPC::XML::Client
# Remember that MEERKAT was declared with "use constant"
->new(MEERKAT,
error_handler =>
sub { die "Transport error: $_[0]" });
sub show_data {
my $data = shift;
print STDOUT qq(<span class="meerkat">\n<dl>\n);
for (@$data) {
print STDOUT <<"END_HTML";
<dt class="title"><a href="$_->{link}">$_->Programming Web Services with Perl</a></dt>
<dd class="description">$_->{description}</dd>
END_HTML
}
print STDOUT qq(</dl>\n</span>\n);
}
sub resolve_name {
my ($str, $name) = @_;
$name = "meerkat.get${name}BySubstring";
my $resp = $client->simple_request($name, $str);
die "resolve_name: $str returned more than 1 match"
if (@$resp > 1);
$resp->[0]{id};
}
sub get_data {
my ($key, $val, $num) = @_;
$client->simple_request('meerkat.getItems',
{ $key => $val,
time_period => '7DAY',
num_items => $num,
descriptions => 200 });
}SOAP::Lite, which will be introduced in Chapter 6. Understanding the form and function of SOAP
messages helps you understand the functionality of the toolkit
components. This chapter is by no means a complete overview of SOAP.
The number (and length) of books devoted to the topic of SOAP is a
testimony to the depth of the subject.
Content-type header (and any other relevant
headers) look like?