|
RPC::XML Module
Part:
1
2
3
4
(Continued from previous part...)
Installing NMake 1.5
Based on the documation, the installation process of RPC::XML module requires the "make" utility.
Since I am using a Windows system now, so I need to download a "make" utility for Windows.
John Bokma has written a nice instruction on how to download and install Microsoft NMake at:
http://johnbokma.com/perl/make-for-windows.html. I used the following steps to install NMake 1.5
on my local machine.
1. Download nmake15.exe at: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084
2. Double click on nmake15.exe. It will generate 3 files: nmake.exe, nmake.err and readme.txt.
3. Copy nmake.exe and nmake.err to \perl\bin, which is where ActivePerl executable files are
located.
4. Now try the nmake command in a command window. If you see the following message, NMake 1.5
is installed correctly:
>nmake
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
Installing RPC::XML Module
With NMake installed, now I am ready to install RPC::XML. Here is what I did:
1. Go to http://www.blackperl.com/RPC::XML/ to read the introduction of RPC::XML.
2. Download RPC-XML-0.57.tar.gz from http://search.cpan.org/search?dist=RPC-XML.
3. Extract RPC-XML-0.57.tar.gz with WinZIP 8.1 to \RPC-XML-0.57.
4. Now use NMake to install RPC::XML in a command window as shown below:
>cd \RPC-XML-0.57
>perl Makefile.PL
......
Writing Makefile for RPC::XML
>nmake test
......
t\30_method.........ok
t\40_server.........ok
>nmake install
......
Writing \Perl\site\lib\auto\RPC\XML\.packlist
Appending installation info to \Perl\lib/perllocal.pod
5. Now run the following command in a command window to test the installation.
If you don't see any error messages, RPC::XML module is installed correctly.
>perl -e "use RPC::XML;"
Please do not delete the .tar file after installation. It contains some very
interesting files. There are many testing programs in the "t" directory. All
server side default methods are defined in the "methods" directory.
RPC::XML Server and Client Sample Programs
To test RPC::XML, I wrote the following the sample server program,
RpcXmlServer.pl:
#- RpcXmlServer.pl
#- Copyright (c) 2005 by Dr. Herong Yang
#
use RPC::XML;
use RPC::XML::Server;
my $host = "localhost";
my $port = "8001";
my $daemon = RPC::XML::Server->new(host => $host, port => $port);
#
print "Adding com.herong.hello...\n";
$daemon->add_method({ name => 'com.herong.hello',
signature => ['string'],
code => sub {return "Hello world!";} });
#
print "Adding com.herong.getCelsius...\n";
my @sig = ('double', 'double double');
$daemon->add_method({ name => 'com.herong.getCelsius',
signature => \@sig, code => \&getCelsius });
#
print "Adding com.herong.getInfo...\n";
$daemon->add_method({ name => 'com.herong.getInfo',
signature => ['array'], code => \&getInfo });
#
print "Listening at $host:$port...\n";
$daemon->server_loop();
#
sub getCelsius {
my $s = shift; # The first parameter is the server object
my $f = shift;
$f = 0.0 unless $f;
print "getCelsius called with ".$f."...\n";
return ($f-32.0)/1.8;
}
#
sub getInfo {
my @info = ("Author","Herong Yang", "Version", "2005");
return \@info;
}
(Continued on next part...)
Part:
1
2
3
4
|