geekondemand has asked for the wisdom of the Perl Monks concerning the following question:
Now in /data/jeff/soap I place a directory Text and within it a module called Caps.pm containing the following code:#!/usr/bin/perl -w use strict; use diagnostics; # Remove from production code use SOAP::Transport::HTTP; # Get the object for standalone servers my $SERVER_PORT = 9000; my $SERVER_NAME = 'localhost'; # Create a SOAP server object my $soap_server = SOAP::Transport::HTTP::Daemon -> new (LocalAddr => $SERVER_NAME, LocalPort => $SERVER_PORT ) # What is the root directory for our objects? # (Remember, the default Perl @INC path will # be ignored.) # Do *not* use /tmp on a real server! -> dispatch_to('/data/jeff/soap'); # Indicate on which port we're expecting # SOAP requests print "SOAP server is waiting on port $SERVER_PORT...\n"; # Now handle the incoming SOAP method call, # and return an appropriate SOAP response. $soap_server->handle();
I then call this with the following SOAP::Lite client:use strict; use LWP; use LWP::UserAgent; #use diagnostics; # Turn off in production code capitalize expects to # receive one argument. It returns that argument, # capitalized, using Perl's built-in # capitalization (uc) function. sub capitalize { my $self = shift; my $word = shift; return uc ($word); }
Running this client gives me the desired output#!/usr/bin/perl -w use strict; use diagnostics; # Remove from production code use SOAP::Lite; # Pass the command-line argument for capitalization my $result = SOAP::Lite -> uri('Text/Caps') -> proxy('http://localhost:9000') -> capitalize('Mares Eat Oats, And Does Eat Oats, and Little Lambs + Eat Ivy') -> result() || ''; # Print the result print "Result = '$result'\n";
Result = 'MARES EAT OATS, AND DOES EAT OATS, AND LITTLE LAMBS EAT IVY'
So far, so good. All of that comes from an exaple found somewhere. Note that in the Text::Caps module I have the LWP modules included just to illustrate they don't cause a problem.
Now what I really want to do involves tasks that need base64 encoding to achieve their results. But if I simply add a "use MIME::Base64;" to the perl module Text::Caps and kill and restart the server script, I get:
Result = ''
when I run the same client script. No error messages are produced in either the client or the server. In fact, I don't think the module is actually loading, as warnings I insert also are not displayed.
My questions are:Note that I know I can write code to do the base64 encoding, that's not the problem. I just want to know the ground rules as there are other modules I'd like to use in my SOAP servers!
Thank you for bearing with me on this extremely long post oh wise and patient monks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SOAP Servers and use-ing various modules
by jhourcle (Prior) on Mar 04, 2005 at 01:24 UTC |