XmlBlaster Logo

REQUIREMENT

client.perl

XmlBlaster Logo


Type NEW
Priority HIGH
Status CLOSED
Topic XmlBlaster provides a simple client library written in Perl using XmlRpc.
Des
cription

You find the perl client code in the directory xmlBlaster/demo/perl/xmlrpc. Please use the file XmlBlaster.pm which provides access to xmlBlaster in an easy way. See xmlBlasterClient.pl as an example.

Following access methods are supported:

Example
PERL

Here is an example hello.pl showing raw access.

NOTE: You should prefer the example xmlBlasterClient.pl which uses the perl modules of Cyrille for simpler xmlBlaster access.

      
 1 #!/usr/bin/perl
       2 # Name: xmlBlaster/demo/perl/xmlrpc/hello.pl (xmlBlaster.org)
       3 # Invoke
       4 #   perl hello.pl http://myHost:8080/
       5 # if xmlBlaster runs on 'myHost'
       6 
       7 use Frontier::Client;
       8 use MIME::Base64;
       9 #use String::Trim;
      10     
      11 #$server_url = 'http://MyHost:8080/';
      12 $server_url = @ARGV[0];
      13 if ($#ARGV == -1) {
      14    $host = `uname -n`;
      15    $host =~ s/^\s*(.*?)\s*$/$1/; # trim whitespace
      16    $server_url = "http://" . $host . ":8080/";  # guess where xmlBlaster is
      17 }
      18 print "\nTrying to connect to xmlBlaster server on $server_url ...\n";
      19 
      20 # Make an object to represent the XMLRPC server.
      21 $server = Frontier::Client->new(url => $server_url);
      22 print "Connected to xmlBlaster server on $server_url \n";
      23 
      24 # Call the remote server and get our result.
      25 $sessionId = $server->call('authenticate.login', "ben", "secret",
      26                                                  "<qos></qos>", "");
      27 print "Login success, got secret sessionId=$sessionId \n";
      28 
      29 # Call the server and get its current memory consumption.
      30 $queryKey = "<key oid='__cmd:?totalMem'/>";
      31 # Call the server and query all messages with XPath:
      32 #$queryKey = "<key queryType='XPATH'>/xmlBlaster</key>";
      33 
      34 @msgUnits = $server->call('xmlBlaster.get', $sessionId, $queryKey, "<qos/>");
      35 print "\nResults for a get($queryKey):";
      36 for $i (0 .. $#msgUnits) {
      37    for $j (0 .. $#{$msgUnits[$i]}) {
      38       print "\n-------------#$j-------------------";
      39       $key = $msgUnits[$i][j][0];
      40       $contentBase64AndEncoded = $msgUnits[$i][j][1];
      41       $content = decode_base64($contentBase64AndEncoded->value());
      42       $qos = $msgUnits[$i][j][2];
      43       print $key;
      44       print "\n<content>" . $content . "</content>\n";
      45       print $qos;
      46       print "\n-------------#$j-------------------\n";
      47    }
      48 }
      49 
      50 # Try publishing a message:
      51 $returnQos = $server->call('xmlBlaster.publish', $sessionId,
      52                            "<key oid='MyMessage'></key>",
      53                            "Hello world", "<qos><forceUpdate /></qos>");
      54 print "\nResult for a publish():\n------------", $returnQos, "\n------------\n";
      55 
      56 
      57 # Logout from xmlBlaster
      58 $server->call('authenticate.logout', $sessionId);
      59 print "\nLogout done, bye.\n";

Try it like this:

 - Start xmlBlaster (with xmlrpc dumping switched on)

      cd xmlBlaster
      java -jar lib/xmlBlaster.jar -plugin/xmlrpc/debug true


 - Run the client :

      (1) cd xmlBlaster/demo/perl/xmlrpc

      (2) hello.pl

      It will try to lookup xmlBlaster on the same machine, or try

      (3) perl hello.pl http://myHost:8080/

      If xmlBlaster is running on 'myHost'
   
Configure

You need the XML package and the Frontier XML-RPC module to run our Perl clients:

  • XML Expat: Install expat (expat-1.95.2 at http://sourceforge.net/projects/expat/) on my linux redhat 7.2 it was already installed.
  • XML Parser: perl module XML-Parser (XML-Parser.2.30 at http://search.cpan.org/search?dist=XML-Parser)
  • XMLRPC driver: xml-rpc implemeted by Frontier (thanks to Ken MacLeod). Look at CPAN for this package or at http://bitsko.slc.ut.us/~ken/xml-rpc/ (Frontier-RPC-0.07b4.tar.gz)

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

Todo
  • Fix the callback server example
  • Add a multi threaded demo with asynchronous access
See CODE hello.pl
See CODE xmlBlasterClient.pl
See CODE xmlBlaster/XmlBlaster.pm
See http://www.xmlBlaster.org/xmlBlaster/demo/perl/xmlrpc/README
See REQ interface

This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.perl.xml

Back to overview