Re: using the RPC::XML perl module, getting started
Ted Pedersen <[email protected]> Thu, 13 Jan 2011 14:56:40 -0600
| Newsgroups | gmane.text.xml.rpc.specification |
|---|---|
| Message-ID | <[email protected]> |
Hi Bill,
I am able to run the server just fine, I'm just not clear on what the client
should consist of.
The server looks like this:
Example C-7. fortune-RPC::XML.pl
#!/usr/bin/perl -w
use strict;
use XRFortune;
use RPC::XML::Server;
# The object created by the constructor will be used to
# chain on a set of calls to add_proc( ) (which means it
# isn't necessary to deal with the local routines being
# called as methods), and then drop directly into the
# server_loop( ) method.
RPC::XML::Server->new(port => 9000)
# add_proc can take a pre-created RPC::XML::Procedure
# object, or a hash reference.
->add_proc({ name => 'books',
signature => [ 'array',
'array string',
'array array' ],
code => \&XRFortune::books })
# It gets called once for each routine being made
# public by the server.
->add_proc({ name => 'fortune',
signature => [ 'array',
'array string',
'array array' ],
code => \&XRFortune::fortune })
# There are other ways of specifying the server-side
# procedures, but for an example of this size, this way
# is just as efficient.
->add_proc({ name => 'weighted_fortune',
signature => [ 'array',
'array string',
'array array' ],
code => \&XRFortune::weighted_fortune })
# This method will only return after a signal interrupts
# it.
->server_loop;
exit;
The XRFortune.pm module and other background info can be seen here, should
that be of interest...
http://www.zanshu.com/ebook/219_programmingwebserviceswithperl/0596002068_pwebserperl-app-c-sect-2.html
So...given that I have this server running, what should the client look like
to get this going?
Thanks!
Ted
On Thu, Jan 13, 2011 at 2:42 PM, Bill Moseley <[email protected]> wrote:
>
>
> I just happen to have been working with RPC::XML as your mail came in --
> hadn't touched it in months.
>
> I don't have the book you mention -- is the problem you need a server to
> connect to to test? Or that you are not clear how to write the Perl code to
> use the module?
>
> For testing I often just start a web server and process requests using
> RCP::XML. And then write a small script to send requests and dump
> responses.
>
> Something as simple as this:
>
> my $client = RPC::XML::Client->new( $endpoint );
>
> my $response = $client->send_request( $method, \%request_data )
> || die 'failed to send';
>
> print Dumper $response->value;
>
> Maybe I'm not understanding your question, though. Maybe you can provide
> an example of the code you are trying to get working?
>
>
> On Thu, Jan 13, 2011 at 12:11 PM, ted_pedersen <[email protected]<duluthted%40gmail.com>>
> wrote:
>
> > Greetings all,
> >
> > I'm just getting started with using XML-RPC, and I'm using the Perl
> module
> > RPC::XML as my implementation tool, so far at least. :)
> >
> > There is a nice but incomplete RPC::XML example in a book called Web
> > Services with Perl (by Ray and Kulkchenko) which has a server side
> program
> > for a fortune cookie example, but doesn't provide the client side code.
> Does
> > anyone have this (using RPC::XML) and if you could, would you be willing
> to
> > share this? I just like to have something simple I can test to make sure
> > things are basically working.
> >
> > There is a second example in the book based on the OReilly Meerkat
> service,
> > and that's a complete example with client and server, but as best I can
> tell
> > this service is no longer available (so I can't run the examples).
> >
> > I've checked out the book page and written to the authors without success
> > so wanted to check here.
> >
> > http://www.blackperl.com/pwswp/
> >
> > And yes, I know I should just figure this out and it must not be too
> hard,
> > but I'm in the early days of working with this and it just helps to
> convince
> > myself that this module and paradigm works at all by running a simple
> > example. So I am hoping some industrious reader of this boo might have
> > already worked this out or that there's a client available somewhere...
> >
> > Also, if anyone has any good recommendations on starter materials for
> > programming with XML-RPC in Perl (using RPC::XML or any other module).
> The
> > book I've mentioned is ok, although the fact that I'm struggling a bit to
> > get something really simple going might suggest it's missing a few
> details.
> > I know Perl reasonably well and understand what XML-RPC is trying to do,
> so
> > it's mostly the mechanics of using the Perl code that is tripping me up
> (I
> > think).
> >
> > Cordially,
> > Ted
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
> --
> Bill Moseley
> [email protected] <moseley%40hank.org>
>
> [Non-text portions of this message have been removed]
>
>
>
--
Ted Pedersen
http://www.d.umn.edu/~tpederse
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xml-rpc/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/xml-rpc/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/