1 #!/usr/local/bin/perl
  2 #
  3 #       messagesList.pl
  4 #
  5 #       HOWTO RUN :
  6 
  7 #               type on your keyboard :
  8 #               $ ./messagesList.pl your.host:port
  9 #
 10 # 04/07/02 17:21 mad@ktaland.com
 11 #       upgrade to fit new xmlBlaster implementation
 12 #       done with BRANCH_0_7_9g on date 2002-07-08
 13 #
 14 # 12/02/02 13:18 mad@ktaland.com
 15 #
 16 #       - create that cool tool after made demo xmlBlasterClient.pl
 17 #
 18 # 2001-12-17 11:54 mAd@ktaland.com
 19 #
 20 #       Connect to xmlBlaster via XMLRPC
 21 #       IOR with MICO is to heavy to install ;o{
 22 #
 23 #       Lib required :
 24 #
 25 #       - XMLRPC implemeted by Frontier (Frontier-RPC-0.07b3)
 26 #       - XML Parser :
 27 #               install expat (expat-1.95.2 at http://sourceforge.net/projects/expat/)
 28 #               then perl module XML-Parser (XML-Parser.2.30 at http://search.cpan.org/search?dist=XML-Parser)
 29 #
 30 
 31 use Frontier::Client;
 32 use Data::Dumper;
 33 
 34 use lib( '.' );
 35 
 36 use xmlBlaster::Exception ;
 37 use xmlBlaster::XmlBlaster ;
 38 use xmlBlaster::MsgUnit ;
 39 
 40 use strict;
 41 
 42 # MAIN
 43 try
 44 {
 45         my $server =  $ARGV[0];
 46         if( ! defined($server) ){
 47                 print "give me a server url like : MyHost:8080\n";
 48                 exit ;
 49         }
 50 
 51         #
 52         #       Connecting 2 clients
 53         #
 54 
 55         print "> Construct client for server $server ...\n";
 56         my $xb = xmlBlaster::XmlBlaster->new(
 57                                         {
 58                                         'host'=> $server,
 59                                         'user'=> 'guest',
 60                                         'passwd'=> 'secret',
 61                                         }
 62                                 );
 63 
 64         print "> Connect with $xb ...\n";
 65         $xb->connect();
 66         print "> Connected ...\n";
 67 
 68         #
 69         #       We're connected
 70         #       do some work ...
 71         #
 72 
 73         my $cpt = getMessageList ( $xb );
 74 
 75         print "> $cpt messages found.\n";
 76 
 77         # Logout from xmlBlaster
 78 
 79         print "> Disconnect ...\n";
 80         $xb->logout();
 81 
 82 }
 83 catch
 84 {
 85     my $exception = shift ;
 86         $exception->dump ;
 87 };
 88 
 89 ##################################
 90 sub getMessageList {
 91 
 92         my( $srv )=shift ;
 93 
 94         #
 95         #       User try to get the list of messages from xmlBlaster.
 96         #
 97 
 98         print "> get list of all messages ...\n" ;
 99 
100         #my $queryString = '//key' ;
101         my $queryString = '/xmlBlaster/key' ;
102 
103         my $key = "<key oid='' queryType='XPATH'>\n".$queryString."</key>" ;
104 
105         my $messages_aref = $srv->get( $key );
106         my $cpt = 0 ;
107 
108         foreach my $message ( @$messages_aref ){
109 
110                 my $message_unit = xmlBlaster::MsgUnit->new( $message );
111                 print $message_unit->dump() ;
112                 $cpt ++ ;
113         }
114 
115         return $cpt ;
116 
117 }#getMessageList
118 
119 1;


syntax highlighted by Code2HTML, v. 0.9.1