This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Chapter 10: Service Advertising and Discovery with UDDI
Fortunately, the returned values from the get_* routines are much clearer. Each
returns basic UDDI data structures, the number of which depends on how many
keys were passed in the request and how many keys were found in the registry.
Showing More Detail for a Business
This section presents a more in-depth sample application that uses UDDI::Lite to dis-
play a greater amount of detail on one or more business, based on command-line
arguments. The application itself is too long to list here, but the full code (with anno-
tations) is provided in Appendix E.
The idea
The premise for this sample application is simple: given a business name (or partial
name), dump the more relevant information from the UDDI registry in a human-
readable format. The goal is to become familiar with both the structures of UDDI,
and the use of the
UDDI::Lite toolkit itself.
While the application can peer down as deeply as the
tModel structures themselves, it
goes only as deep as the bindings for now. You should take the script and experi-
ment with it, adding the additional functionality as desired. Another useful facet of
the example is to run it with full tracing on (using the
trace interface defined in
Chapter 6). Because the
UDDI::Lite class directly inherits from SOAP::Lite, it may
also use the
SOAP::Trace facility with the same interface. A script can be run with
tracing without having to modify the script; it can simply be passed as an argument
to the Perl command itself:
perl -MUDDI::Lite=trace,debug application [ arguments ]
Recalling the debug tracing level from Chapter 6, it’s especially useful because it
shows the SOAP envelopes for messages, which can help you understand the struc-
ture of data being returned by the registry.
Using UDDI::Lite with auto-dispatch
This application takes advantage of the auto-dispatch capabilities of the SOAP::Lite
toolkit. It also chooses to import some handy utility functionality (such as data-
building routines
name and findQualifiers) from UDDI::Data. Let’s examine some
lines from the first part of the application:
use Text::Wrap qw(wrap $columns);
use Getopt::Long 'GetOptions';
use UDDI::Lite +autodispatch =>
proxy => '',
import => 'UDDI::Data';
GetOptions(\%opts, qw(case exact showkeys)) and
$name = shift or
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Programming with UDDI::Lite
die "USAGE: $0 [ --case ] [ --exact ] [ --showkeys ] " .
The application not only uses the UDDI::Lite classes, but it also uses Getopt::Long for
command-line parsing and
Text::Wrap for simple text formatting. Here are the
options it recognizes:
Tells the application to make the name lookup case-sensitive. The default in
UDDI is case-insensitive.
By default, the UDDI registry takes the name given as an argument and matches
it as a partial string to records in their database. This option forces the match to
be exact.
Because the UUID keys have no real human-readable meaning, the application
doesn’t display them by default. This option requests that the keys be printed
along with the other data.
The options (except for
--showkeys) can create a set of findQualifier elements for
the eventual call to
find_business. This segment creates the parameters for the call:
@qualifiers = ('sortByNameAsc');
push(@qualifiers, 'exactNameMatch') if ($opts{exact});
push(@qualifiers, 'caseSensitiveMatch') if ($opts{case});
This is simple logic: the routines findQualifiers, findQualifier, and name are
imported from
UDDI::Data. In fact, the sortByNameAsc qualifier isn’t actually needed,
because it’s the default behavior. However, it simplifies the logic to have it here and
keeps the application from passing an empty list of qualifiers to the call.
Making the call itself and iterating over the list of businesses returned by the registry
are equally as simple:
my $result = find_business(@params);
for ($result->businessInfos->businessInfo);
Note that because auto-dispatching is used, the return value from find_business is
already converted to a
UDDI::Data object. As with the earlier example, the interim
businessInfos containment structure is quietly skipped over, with the application
going directly for the list of
businessInfo structures. The actual processing of most of
the information is simple. While the
dump_business routine isn’t very special, it calls a
routine named
dump_service that deserves some attention.
Recalling Table 10-9, the structures returned from
find_business aren’t complete
businessEntity records. For this application, they return enough business-level

Get Programming Web Services with Perl now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.