Subject: | envelope subroutine() in XMLRPC/Lite.pm incorrectly requires method parameter for a response envelope |
Date: | Mon, 29 Oct 2007 10:51:47 -0400 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Dave Lawrence <dkl [...] redhat.com> |
I was using the XMLRPC::Lite envelope() routine to format a response in
my code
where I just wanted the resulting XML data and not actually send it. I
noticed that
the code is set to die if a method name is not passed in even though it
is returning
a response. I feel that a method name should not be required except when
needed
for a request.
For example a simple test script is:
#!/usr/bin/perl
use XMLRPC::Lite;
my $data = {
name => "David Lawrence",
age => 38,
pets => ["Lucie", "Kitty"],
};
my $serializer = new XMLRPC::Serializer();
my $result = $serializer->envelope('response', 'foo', $data);
print $result;
exit;
If I do not pass in 'foo' as the second argument, it will die
with "Unspecified method for XMLRPC call" even though
the method name 'foo' is not in the resulting XML data. The
code should be:
my $result = $serializer->envelope('response', $data);
I have submitted a patch that will only ask for a method name
if type eq 'method'.
Thanks
Dave
--
David Lawrence, RHCE dkl@redhat.com
------------------------------------
Red Hat, Inc. Web: www.redhat.com
1801 Varsity Drive Raleigh, NC 27606
--- /usr/lib/perl5/site_perl/5.8.8/XMLRPC/Lite.pm 2004-11-14 14:30:50.000000000 -0500
+++ /tmp/Lite.pm 2007-10-29 11:04:19.000000000 -0400
@@ -73,12 +73,12 @@
my($body);
if ($type eq 'method' || $type eq 'response') {
- my $method = shift or die "Unspecified method for XMLRPC call\n";
if ($type eq 'response') {
$body = XMLRPC::Data->name(methodResponse => \XMLRPC::Data->value(
XMLRPC::Data->type(params => [@_])
));
} else {
+ my $method = shift or die "Unspecified method for XMLRPC call\n";
$body = XMLRPC::Data->name(methodCall => \XMLRPC::Data->value(
XMLRPC::Data->type(methodName => UNIVERSAL::isa($method => 'XMLRPC::Data') ? $method->name : $method),
XMLRPC::Data->type(params => [@_])