XMLRPC question

Leland Vandervort leland at DEV.DISCPRO.ORG
Thu Oct 21 12:29:58 EDT 2010


Hi All, 

Apologies in advance if something along these lines has already been raised
on the mailing list ‹ having just joined the list at the suggestion of
runrev support.

I did try via the forums and looking around the wider net for some
information, but have drawn blanks.

Please see below the cruxt of the question/problem that I posted to the
forums.  

Thanks in advance for any guidance, advice, pointers, etc.

Regards, 

Leland

--

>From the forums:

I have an application that I'm trying to prototype that makes extensive use
of XMLRPC, including advanced data structures (such as arrays/array-refs,
hashes/hashrefs, and even arrays with embedded hashes which themselves may
contain additional arrays with further embedded hashes etc.)
I can manage to do just about any manipulation that I need to do for XMLRPC
in Perl, but I'm finding the revXMLRPC functions to be very cumbersome with
unclear documentation and almost no working examples available that I've
been able to find.  To be honest, I'm not even sure of the revXMLRPC
functions even de-serialise the encapsulated XML data to return standard
data structures, or if I then have to use additional functions from revXML
to do that.

Perl, of course, contains a number of various libraries to work with XMLRPC
and simply deserialises the data to return a data structure with which I can
work.

Given that LiveCode/Revolution is toted as "less coding, and more
productive", I'm at a loss to find an equivalent to the types of things that
I'm trying to do here.

For example, with just a few lines in Perl, I can use (in this example) a
couple of XMLRPC calls to obtain a list of virtual machines from a cloud
provider, and the current data concerning those machines.  (using the
Frontier::RPC library for this) .. example:

--- code ---
# other stuff snipped here to get to the nitty gritty
my %vms ;   #empty hash to store the details of my VMs

# login to rpc server
my $rpc = Frontier::Client->new( url => $server_url );
my $key = $rpc->call('login',$username,$password);

# got my key now start calling various methods...
my $vm_list = $rpc->call('vm.list',$key);

# now iterate the vm.list and get the info for each vm and store it into a
local hash for manipulation
foreach my $vm (@{$vm_list}) {
    my $vm_info = $rpc->call('vm_info',$key,$vm->{id});
        # store the data in my %vms hash
    $vms{$vm_info->{id}} = $vm_info ;
}
$rpc->close();

# now I can do whatever I like with the data...
# like iterate through the list and display some useful data...

foreach my $vm (keys %vms) {
  print "VM ID:  $vms{$vm}->{id}  --  Hostname:  $vms{$vm}->{hostname}  --
State:  $vms{$vm}->{state}\n";

  # get a list of interfaces in the VM:
  print "Interface List...\n";

  foreach my $if (@{$vms{$vm}->{ifaces}}) {
      print "Interface ID:  $if->{id} -- Speed: $if->{bandwidth} -- Status:
$if->{state}\n";
  }
}
--- end code ---


I can't seem to find a "reasonable" way to do this in livecode/revolution
with the limited examples/documentation that I have available (and I have
hard-copies of the RunRev 4.0 user manual, and the 3.0 dictionaries volumes
1 and 2) -- Just wondering if there is a relatively straightforward way of
accomplishing the equivalent of the above in livecode as I cannot find any
suitable examples after spending hours searching the forums, and the wider
net... 


Thanks in advance for any pointers, tips, or references that may be useful!

Regards, 

L.




More information about the Use-livecode mailing list