1Frontier::Responder(3)User Contributed Perl DocumentationFrontier::Responder(3)
2
3
4
6 Frontier::Responder - Create XML-RPC listeners for normal CGI processes
7
9 use Frontier::Responder;
10 my $res = Frontier::Responder->new( methods => {
11 add => sub{ $_[0] + $_[1] },
12 cat => sub{ $_[0] . $_[1] },
13 },
14 );
15 print $res->answer;
16
18 Use Frontier::Responder whenever you need to create an XML-RPC listener
19 using a standard CGI interface. To be effective, a script using this
20 class will often have to be put a directory from which a web server is
21 authorized to execute CGI programs. An XML-RPC listener using this
22 library will be implementing the API of a particular XML-RPC
23 application. Each remote procedure listed in the API of the user
24 defined application will correspond to a hash key that is defined in
25 the "new" method of a Frontier::Responder object. This is exactly the
26 way Frontier::Daemon works as well. In order to process the request
27 and get the response, the "answer" method is needed. Its return value
28 is XML ready for printing.
29
30 For those new to XML-RPC, here is a brief description of this protocol.
31 XML-RPC is a way to execute functions on a different machine. Both the
32 client's request and listeners response are wrapped up in XML and sent
33 over HTTP. Because the XML-RPC conversation is in XML, the
34 implementation languages of the server (here called a listener), and
35 the client can be different. This can be a powerful and simple way to
36 have very different platforms work together without acrimony. Implicit
37 in the use of XML-RPC is a contract or API that an XML-RPC listener
38 implements and an XML-RPC client calls. The API needs to list not only
39 the various procedures that can be called, but also the XML-RPC
40 datatypes expected for input and output. Remember that although Perl is
41 permissive about datatyping, other languages are not. Unforuntately,
42 the XML-RPC spec doesn't say how to document the API. It is recomended
43 that the author of a Perl XML-RPC listener should at least use POD to
44 explain the API. This allows for the programmatic generation of a
45 clean web page.
46
48 new( OPTIONS )
49 This is the class constructor. As is traditional, it returns a
50 blessed reference to a Frontier::Responder object. It expects
51 arguments to be given like a hash (Perl's named parameter
52 mechanism). To be effective, populate the "methods" parameter with
53 a hashref that has API procedure names as keys and subroutine
54 references as values. See the SYNOPSIS for a sample usage.
55
56 answer()
57 In order to parse the request and execute the procedure, this
58 method must be called. It returns a XML string that contains the
59 procedure's response. In a typical CGI program, this string will
60 simply be printed to STDOUT.
61
63 perl(1), Frontier::RPC2(3)
64
65 <http://www.scripting.com/frontier5/xml/code/rpc.html>
66
68 Ken MacLeod <ken@bitsko.slc.ut.us> wrote the underlying RPC library.
69
70 Joe Johnston <jjohn@cs.umb.edu> wrote an adaptation of the
71 Frontier::Daemon class to create this CGI XML-RPC listener class.
72
73
74
75perl v5.28.0 2002-08-03 Frontier::Responder(3)