#!/usr/bin/perl -w use SOAP::Lite on_fault => \&faultHandler; ## The .wsdl service definition could live locally, ## with an address like $wsdl="file:./ExamineNames.wsdl" . my $wsdl = "http://bob.marlboro.edu/~msie/2002/ipl/perl/lectures/jun15/names/ExamineNames.wsdl"; ## This next line defines everything about the service, ## and creates an $EN object (what the author calls a "stub") ## which will act exactly like it would if you'd created it with ## use ExamineNames; ## my $EN = new ExamineNames; ## You just call its (remote) methods, and get results back directly (!) my $EN = SOAP::Lite->service($wsdl); my $nickname = "Jim"; my $gender = $EN->getGender($nickname); # A remote call. print " The gender of '$nickname' is '$gender'. \n"; my $fullname = $EN->expandNickname($nickname); # Another remote call. print " The fullname of '$nickname' is '$fullname'. \n"; my $name1 = "Jim Mahoney"; my $name2 = "JAMES H MAHONEY"; my $rating = $EN->sameNames($name1, $name2); # And a third. print " Rating of '$name1' == '$name2' is '$rating'. \n"; ## In the client-ExamineNames.pl version, the $som object contained ## the full XML response, which you could query in various ways. ## Here you don't have that - instead, the $EN object you get tries to ## hide all that from you. ## ## These "virtual" objects can even maintain state on the remote server, ## if the remote process is persistent. Very cool. ## ## SOAP::Lite implements several syntax variations. ## For example, one option is to bypass the $EN object completely, ## and define the methods from ExamineNames in the current package, ## like this: # # use SOAP::Lite on_fault => \&faultHandler, # service => 'file:./ExamineNames.wsdl'; # my $gender = getGender($nickname); # This is a remote call! # # Also very cool. # ------------------------------------ sub faultHandler { my ($soap, $som) = @_; # see distribution/SOAP-Lite-0.55/examples/ die( $som->fault ? $som->faultstring : $soap->transport->status ); }