README
1NAME
2 XML::RPC -- Pure Perl implementation for an XML-RPC client and server.
3
4SYNOPSIS
5 make a call to an XML-RPC server:
6
7 use XML::RPC;
8
9 my $xmlrpc = XML::RPC->new('http://betty.userland.com/RPC2');
10 my $result = $xmlrpc->call( 'examples.getStateStruct', { state1 => 12, state2 => 28 } );
11
12 create an XML-RPC service:
13
14 use XML::RPC;
15 use CGI;
16
17 my $q = new CGI;
18 my $xmlrpc = XML::RPC->new();
19 my $xml = $q->param('POSTDATA');
20
21 print $q->header( -type => 'text/xml', -charset => 'UTF-8' );
22 print $xmlrpc->receive( $xml, \&handler );
23
24 sub handler {
25 my ( $methodname, @params ) = @_;
26 return { you_called => $methodname, with_params => \@params };
27 }
28
29DESCRIPTION
30 XML::RPC module provides simple Pure Perl methods for XML-RPC
31 communication. It's goals are simplicity and flexibility. XML::RPC uses
32 XML::TreePP for parsing.
33
34CONSTRUCTOR AND OPTIONS
35 $xmlrpc = XML::RPC->new();
36 This constructor method returns a new XML::RPC object. Usable for
37 XML-RPC servers.
38
39 $xmlrpc = XML::RPC->new( 'http://betty.userland.com/RPC2', %options );
40 Its first argument is the full URL for your server. The second argument
41 is for options passing to XML::TreePP, for example: output_encoding =>
42 'ISO-8859-1' (default is UTF-8).
43
44METHODS
45 $xmlrpc->call( 'method_name', @arguments );
46 This method calls the provides XML-RPC server's method_name with
47 @arguments. It will return the server method's response.
48
49 $xmlrpc->receive( $xml, \&handler );
50 This parses an incoming XML-RPC methodCall and call the \&handler subref
51 with parameters: $methodName and @parameters.
52
53 $xmlrpc->xml_in();
54 Returns the last XML that went in the client.
55
56 $xmlrpc->xml_out();
57 Returns the last XML that went out the client.
58
59CUSTOM TYPES
60 $xmlrpc->call( 'method_name', { data => sub { { 'base64' => encode_base64($data) } } } );
61 When passing a CODEREF to a value XML::RPC will simply use the returned
62 hashref as a type => value pair.
63
64ERROR HANDLING
65 To provide an error response you can simply die() in the \&handler
66 function. Also you can set the $XML::RPC::faultCode variable to a (int)
67 value just before dieing.
68
69PROXY SUPPORT
70 Default XML::RPC will try to use LWP::Useragent for requests, you can
71 set the environment variable: CGI_HTTP_PROXY to set a proxy.
72
73LIMITATIONS
74 XML::RPC will not create "bool", "dateTime.iso8601" or "base64" types
75 automatically. They will be parsed as "int" or "string". You can use the
76 CODE ref to create these types.
77
78AUTHOR
79 Niek Albers, http://www.daansystems.com/
80
81COPYRIGHT AND LICENSE
82 Copyright (c) 2007-2008 Niek Albers. All rights reserved. This program
83 is free software; you can redistribute it and/or modify it under the
84 same terms as Perl itself.
85
86