VinsWorldcom has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl variable to Java Boolean
by ikegami (Patriarch) on Jan 26, 2010 at 17:46 UTC |