This example in the XML::RPC documentation:
my $result = $xmlrpc->call( 'examples.getStateStruct', { state1 => 12, state2 => 28 } );
may also be written:
my $result = $xmlrpc->call('examples.getStateStruct', { state1 => sub { {i4 => 12} }, state2 => 28 }
The i4 designates the XML::RPC data type (4-byte integer).

This example:

$xmlrpc->call( 'method_name', { name => sub { {'base64' => encode_base64($data)} } } );
will add a named parameter called 'name' with a data type of 'base64'. This is a way of passing arbitrary binary data.

Since perl doesn't have a special way to designate boolean values, you have to do this to pass boolean typed parameters:

$xmlrpc->call(..., { name => sub { {boolean => $value} } });
It would be a good idea to make sure that $value is either 0 or 1.

Here's a succinct overview of XML-RPC data types: http://www.xmlrpc.com/spec

To learn more about anonymous subroutines (aka CODEREFs), have a look at perldoc perlsub.


In reply to Re: Accessing Trac via XML::RPC by pc88mxer
in thread Accessing Trac via XML::RPC by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.