As mentioned, the client implementation is unimportant as the only thing being exchanged between client and server is a simple text document. While the following example doesn't show the document creation and parsing, it does demonstrate how perl can be used to interact with our servlet:
#!/usr/local/bin/perl use HTTP::Request::Common qw( POST ); use LWP::UserAgent; $ua = LWP::UserAgent->new(); # create $doc my $doc = '<?xml version="1.0"?> <request command="schema"> <record/> </request>'; # POST the document to the servlet my $req = POST 'http://localhost/servlet/demo', Content_Type => 'application/text', Content => $doc; $content = $ua->request( $req )->as_string; # parse $content print $content |
Since I don't program in perl, I didn't want to make this example very complete. Extension of this code into a working model should be a trivial exercise.
Copyright © 2000 by Phil Selby
All rights reserved internationally.