Richard Yang wrote via RT
Show quoted text> Hi,
Hello,
Show quoted text> The module does not create valid requests for slightly more
> complicated structures, I've only had it working for simple
> "encode_xmlrpc_request" structures that involve a single list
> without nesting arrays/hashes (i.e. 'methodnamehere, param1,
> param2..').
I can assure you that this module was written to handle more than
trivial structures. It was (and as far as I know still is) used in
code at my previous $job to handle hundreds of encodings per minute
of moderately complex structures (at least, more complex than the
example you provide below).
Show quoted text> For example, the code below does not work (although it
> should as it was taken from a decoded working request, modified to
> module's correct syntax):
>
> my $xml = encode_xmlrpc( method => 'system.multicall' [ {
> 'methodName' => 'd.custom.set', 'params' => [
> 'AKDF54456456AS4D56AS4D65A4SD56AS4D56AS4', 'name1', 'value1' ] }, {
> 'methodName' => 'd.custom.set', 'params' => [
> '5A6S4D6A4SD5AS4D6A4SD6A5S4DA6SD56A4SD65', 'name2', 'value2' ], } ]
> The above request has the error of the subject title of this email;
> [~some type~] in this case is "<struct>". Note I've gotten errors in
> the case of "<string>" as well, and am very like to get errors for
> other types.
Putting your example in a file, fixing the typo:
$ cat t/cpan-rt-123887.t
#!perl
use v5.10;
use strict;
use warnings;
use XMLRPC::Fast;
my $xml = encode_xmlrpc(
method => 'system.multicall', [
{
'methodName' => 'd.custom.set',
'params' => [ 'AKDF54456456AS4D56AS4D65A4SD56AS4D56AS4', 'name1', 'value1' ]
},
{
'methodName' => 'd.custom.set',
'params' => [ '5A6S4D6A4SD5AS4D6A4SD6A5S4DA6SD56A4SD65', 'name2', 'value2' ]
}
]);
say $xml;
Executing it:
<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>system.multicall</methodName><params><param><value><array><data><struct><member><name>params</name><value><array><data><string>AKDF54456456AS4D56AS4D65A4SD56AS4D56AS4</string><string>name1</string><string>value1</string></data></array></value></member><member><name>methodName</name><value><string>d.custom.set</string></value></member></struct><struct><member><name>methodName</name><value><string>d.custom.set</string></value></member><member><name>params</name><value><array><data><string>5A6S4D6A4SD5AS4D6A4SD6A5S4DA6SD56A4SD65</string><string>name2</string><string>value2</string></data></array></value></member></struct></data></array></value></param></params></methodCall>
Passing the result through xml_pp:
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>system.multicall</methodName>
<params>
<param>
<value>
<array>
<data>
<struct>
<member>
<name>methodName</name>
<value>
<string>d.custom.set</string>
</value>
</member>
<member>
<name>params</name>
<value>
<array>
<data>
<string>AKDF54456456AS4D56AS4D65A4SD56AS4D56AS4</string>
<string>name1</string>
<string>value1</string>
</data>
</array>
</value>
</member>
</struct>
<struct>
<member>
<name>methodName</name>
<value>
<string>d.custom.set</string>
</value>
</member>
<member>
<name>params</name>
<value>
<array>
<data>
<string>5A6S4D6A4SD5AS4D6A4SD6A5S4DA6SD56A4SD65</string>
<string>name2</string>
<string>value2</string>
</data>
</array>
</value>
</member>
</struct>
</data>
</array>
</value>
</param>
</params>
</methodCall>
Piping the original program to XMLRPC::Fast decode_xmlrpc():
$ perl -Ilib t/cpan-rt-123887.t | perl -Ilib -MXMLRPC::Fast -MData::Dump=dd -e 'dd decode_xmlrpc(<>)'
{
methodName => "system.multicall",
params => [
[
{
methodName => "d.custom.set",
params => ["AKDF54456456AS4D56AS4D65A4SD56AS4D56AS4", "name1", "value1"],
},
{
methodName => "d.custom.set",
params => ["5A6S4D6A4SD5AS4D6A4SD6A5S4DA6SD56A4SD65", "name2", "value2"],
},
],
],
type => "request",
}
As far as I can test with the provided data, everything seems
to works fine.
Wouldn't it be some other part of your program that could mangle
the result?
Regards
--
Sébastien Aperghis-Tramoni
Close the world, txEn eht nepO.