It seems the Frontier::Client only expects to return simple values, not arrays. You'll have to go down to the Frontier::RPC2 level and do "decode" calls for yourself. Here's an example:
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:
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";
This is the result I got:
<?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>
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.
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. |