JSONRPC - Perl implementation of JSON-RPC protocol
#-------------------------- # In your application class package MyApp;
sub own_method { # called by clients my ($server, @params) = @_; # $server is JSONRPC object. ... # return a scalar value or a hashref or an arryaref. }
#-------------------------- # In your main cgi script. use JSONRPC::Transport::HTTP; use MyApp;
# a la XMLRPC::Lite JSONRPC::Transport::HTTP::CGI->dispatch_to('MyApp')->handle();
#-------------------------- # Client version use JSONRPC::Transport::HTTP; my $uri = 'http://www.example.com/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.
my $srv = JSONRPC::Transport::HTTP::CGI->new; $srv->jsonParser->{unmapping} = 1;
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |