Oh Wise Monks,

I have given up trying to write a SOAP server. Instead, I need to write an XML-RPC Listener. So I have installed Frontier-RPC and started playing with the examples. I got server a working with Frontier::Daemon no problem. I use this script to test it ...

#!/usr/bin/perl # Testing sum() use strict; use warnings; use Frontier::Client; my $url = "http://localhost:8181/RPC2"; my @args = (2,5); my $client = Frontier::Client->new( url => $url, debug => 1 ); print "$args[0] + $args[1] = ", $client->call('sum', @args), "\n";
... here's the output to that shows my daemon server works:
$ ./fcclient.pl ---- request ---- <?xml version="1.0"?> <methodCall> <methodName>sum</methodName> <params> <param><value><i4>2</i4></value></param> <param><value><i4>5</i4></value></param> </params> </methodCall> ---- response ---- <?xml version="1.0"?> <methodResponse> <params> <param><value><string>7</string></value></param> </params> </methodResponse> 2 + 5 = 7
... but I also want to use Frontier::Responder so I can respond to request for normal CGI processes. So I put the script in my webserver's cgi-bin dir ...
plankton@ubuntu:/usr/lib/cgi-bin$ cat fcresponder.cgi #!/usr/bin/perl -w use strict; use Frontier::Responder; use CGI; my $cgi = new CGI; my $xml = $cgi->param('POSTDATA'); my $res = Frontier::Responder->new( methods => { sum => sub{ $_[0] + $ +_[1] }, add => sub{ $_[0] + $ +_[1] }, cat => sub{ $_[0] . $ +_[1] }, }, ); print $res->answer;
... and then I change my test script to this ...
plankton@ubuntu:/usr/lib/cgi-bin$ cat test_fcresonder.cgi #!/usr/bin/perl -w use strict; use Frontier::Client; my $server = Frontier::Client->new(url => "http://localhost/cgi-bin/fc +responder.cgi", debug => 1); my $method = 'sum'; my @args = (1,1); my $result = $server->call($method, @args); print "$result\n";
... and when I run the above I get this output ...
plankton@ubuntu:/usr/lib/cgi-bin$ ./test_fcresonder.cgi ---- request ---- <?xml version="1.0"?> <methodCall> <methodName>sum</methodName> <params> <param><value><i4>1</i4></value></param> <param><value><i4>1</i4></value></param> </params> </methodCall> ---- response ---- no element found at line 1, column 0, byte -1 at /usr/lib/perl5/XML/Pa +rser.pm line 187
... what am I doing wrong?

In reply to Testing XML-RPC Servers written in Perl by Plankton

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.