I've started out with a basic soap server (which was shamelessly copied from somewhere or other):
#!/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();
Now in /data/jeff/soap I place a directory Text and within it a module called Caps.pm containing the following code:
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); }
I then call this with the following SOAP::Lite client:
#!/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";
Running this client gives me the desired output
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:
  1. Are only some modules allowed within SOAP servers (perhaps for security reasons)?
  2. How can I add additional modules to that list or circumvent the "feature" in #1?
  3. What sort of code can I add to my server script or module to tell me what is going on with respect to the module loading or other errors?

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.


In reply to SOAP Servers and use-ing various modules by geekondemand

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.