Fetching text file small.txt Displaying response object contents: This is a small text file. Fetching text file small.xml Displaying response as plain text: Unknown tag encountered: Something #### #!/usr/bin/perl -w use strict; use RPC::XML::Server; my $server = RPC::XML::Server->new(port => 9000); $server->add_method( { name => 'dump_file', version => '1.0', hidden => 0, code => \&dump_file, signature => [ 'string string' ], help => 'Dumps the contents of the specified file' } ); $server->server_loop(); sub dump_file { my $server = shift; my $fname = shift; my $buffer; print "Calling dump_file\n"; if (-f $fname) { print " Dumping contents of file $fname\n"; open(FILE, $fname); $buffer = join('', ()); } else { print "Can't find file $fname: $!\n"; return undef; } return $buffer; } #### #!/usr/bin/perl -w use strict; use RPC::XML::Client; my $client = RPC::XML::Client->new('http://localhost:9000/'); my @files = qw(small.txt small.xml); my ($request, $response); foreach my $file (@files) { print "Fetching text file $file\n"; $request = RPC::XML::request->new('dump_file', $file); $response = $client->send_request($request); display_response($response); } sub display_response { my $response = shift; if (ref($response) && $response->can('as_string')) { print "Displaying response object contents:\n", $response->as_string(), "\n"; } else { print "Displaying response as plain text:\n", $response, "\n"; } } #### This is a small text file. ####