in reply to Getting an XML-RPC array with Frontier::Client
sub doCommand { # Decode the results of the raw command from XML. my ($uri, $coder, @rest) = @_; my $encoded = doRawCommand($uri, $coder, @rest); return $encoded if ($encoded eq ""); my $result; # Decode XML RPC wrapper case. my $decoded = $coder->decode($encoded); # Note: the result is an array ref with params inside $result = $decoded->{value}[0]; return $result; }
Update: I should explain that doRawCommand is a routine I wrote to encode and make an XML-RPC request, and that $coder is an instance of Frontier::RPC2.
Update2: One thing about your original code is that Frontier::Client::call will never return an array of values, even if the decoding had worked. It should be able to do an array reference, though.
Update3: I just tried an encoding example, trying to match what Advogato returns:
This is the result I got:use strict; use Frontier::RPC2; my $coder = Frontier::RPC2->new(use_objects => 1); my $result = [ "you guessed", 42 ]; my $xml_string = $coder->encode_response($result); print $xml_string,"\n";
The difference is a "value" tag around the "array" level. I believe that is what is throwing off your decode. Advogato must be using a different version of the encoding scheme.<?xml version="1.0"?> <methodResponse> <params> <param><value><array><data> <value><string>you guessed</string></value><value><i4>42</i4></value>< +/data></array></value> </param> </params> </methodResponse>
I would suggest asking their support board. If they can't help, you could use a wrapper like my subroutine above and munge the return value to the right syntax before decoding it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getting an XML-RPC array with Frontier::Client
by jaldhar (Vicar) on Apr 10, 2003 at 22:59 UTC | |
|
Re^2: Getting an XML-RPC array with Frontier::Client
by Anonymous Monk on Aug 28, 2007 at 00:10 UTC | |
by Anonymous Monk on Aug 28, 2007 at 00:12 UTC |