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 applica‐
23 tion. Each remote procedure listed in the API of the user defined
24 application will correspond to a hash key that is defined in the "new"
25 method of a Frontier::Responder object. This is exactly the way Fron‐
26 tier::Daemon works as well. In order to process the request and get
27 the response, the "answer" method is needed. Its return value is XML
28 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 implementa‐
34 tion languages of the server (here called a listener), and the client
35 can be different. This can be a powerful and simple way to have very
36 different platforms work together without acrimony. Implicit in the use
37 of XML-RPC is a contract or API that an XML-RPC listener implements and
38 an XML-RPC client calls. The API needs to list not only the various
39 procedures that can be called, but also the XML-RPC datatypes expected
40 for input and output. Remember that although Perl is permissive about
41 datatyping, other languages are not. Unforuntately, the XML-RPC spec
42 doesn't say how to document the API. It is recomended that the author
43 of a Perl XML-RPC listener should at least use POD to explain the API.
44 This allows for the programmatic generation of a clean web page.
45
47 new( OPTIONS )
48 This is the class constructor. As is traditional, it returns a
49 blessed reference to a Frontier::Responder object. It expects argu‐
50 ments to be given like a hash (Perl's named parameter mechanism).
51 To be effective, populate the "methods" parameter with a hashref
52 that has API procedure names as keys and subroutine references as
53 values. See the SYNOPSIS for a sample usage.
54
55 answer()
56 In order to parse the request and execute the procedure, this
57 method must be called. It returns a XML string that contains the
58 procedure's response. In a typical CGI program, this string will
59 simply be printed to STDOUT.
60
62 perl(1), Frontier::RPC2(3)
63
64 <http://www.scripting.com/frontier5/xml/code/rpc.html>
65
67 Ken MacLeod <ken@bitsko.slc.ut.us> wrote the underlying RPC library.
68
69 Joe Johnston <jjohn@cs.umb.edu> wrote an adaptation of the Fron‐
70 tier::Daemon class to create this CGI XML-RPC listener class.
71
72
73
74perl v5.8.8 2002-08-02 Frontier::Responder(3)