I've written a very basic XML RPC client in Perl (use RPC::XML) that is interfacing with a Java-based XML RPC server. Things work fine when the send_request method uses only strings. However, there is a particular server method that requires a java.lang.boolean type.

#!/usr/bin/perl use strict; use RPC::XML; use RPC::XML::Client; my @auth = qw(admin adminpass); my $cli = RPC::XML::Client->new('http://172.18.1.1:2500/'); my $resp = $cli->send_request("XMLServerRPC.getEventLog", @auth); print ${$resp} # Works FINE my $resp = $cli->send_request("XMLServerRPC.getPlans", @auth, 1); if ((ref $resp) eq 'RPC::XML::fault') { print "ERROR: ${%{$resp}->{'faultString'}}" } else { print ${$resp} }

The question is: what do I put in place of the '1' as the last arg to the second 'send_request("XMLServerRPC.getPlans", @auth, ???)'? The Java server expects a java.lang.boolean. I've tried:

1 : Error = expected java.lang.boolean not java.lang.integer '1' : Error = expected java.lang.boolean not java.lang.string 'TRUE' : Error = expected java.lang.boolean not java.lang.string pack("b*", 1) : Error = An invalid XML character (Unicode: 0x1) found

It seems that Perl is happily sending along the value as an integer or string. Since Perl doesn't have a native boolean type, I guess the real question is how do I create a Java type boolean in Perl?


In reply to Perl variable to Java Boolean by VinsWorldcom

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.