Hello Monks, I am trying to use jsonrpc perl modules and am having trouble with the example at:

http://search.cpan.org/~makamaka/JSON-1.07/lib/JSONRPC/Transport/HTTP.pm

I set the following files - I am new to json in general and am trying to set up rpc for mysql - something to the effect of:
http://search.cpan.org/~yosty/DBIx-JSON-0.02/lib/DBIx/JSON.pm

Any more concrete examples or guidance you can provide will be greatly appreciated.

Thanks, Brian

root@localhost ~# cat /usr/lib/perl5/site_perl/5.8.8/MyApp.pm
#!/usr/bin/perl #-------------------------- # In your application class package MyApp; sub own_method { # called by clients my ($server, @params) = @_; # $server is JSONRPC object. return 5; # return a scalar value or a hashref or an arryaref. } 1;
root@localhost ~# cat /usr/lib/perl5/site_perl/5.8.8/MyApp/Test.pm
#!/usr/bin/perl use JSONRPC::Transport::HTTP; use MyApp; # a la XMLRPC::Lite JSONRPC::Transport::HTTP::CGI->dispatch_to('MyApp')->handle();
root@localhost ~# cat /usr/local/bin/server.pl
#!/usr/bin/perl ################## # Daemon version # ################## use strict; use lib qw(. ./lib); use JSONRPC::Transport::HTTP; my $daemon = JSONRPC::Transport::HTTP::Daemon ->new(LocalPort => 8080) ->dispatch_to('MyApp/Test'); $daemon->handle();
root@localhost ~# cat /usr/local/bin/client.pl
#!/usr/bin/perl use JSONRPC::Transport::HTTP; my $uri = 'http://127.0.0.1:8080/MyApp/Test/'; my $res = JSONRPC::Transport::HTTP ->proxy($uri) ->call('echo',['This is test.']) ->result; if($res->error){ print $res->error,"\n"; } else{ print $res->result,"\n"; } # or my $client = JSONRPC::Transport::HTTP->proxy($uri); print $client->echo('This is test.'); # the alias, _echo is same.
I get the following output from the client:

[root@localhost ~]# client.pl 64 0 No such a method. 64 0


and from the server:

[root@localhost ~]# server.pl [root@localhost ~]# server.pl Status: 500 Content-Type: text/plain; charset=UTF-8

In reply to json help request by btoovey

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.