291 lines
4.7 KiB
HTML
291 lines
4.7 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Common XML-RPC Interfaces</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
|
|
"><LINK
|
|
REL="HOME"
|
|
TITLE="XML-RPC HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="XML-RPC vs. Other Protocols"
|
|
HREF="xmlrpc-howto-competition.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="A Sample API: sumAndDifference"
|
|
HREF="xmlrpc-howto-api.html"></HEAD
|
|
><BODY
|
|
CLASS="section"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>XML-RPC HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="xmlrpc-howto-competition.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="xmlrpc-howto-api.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H1
|
|
CLASS="section"
|
|
><A
|
|
NAME="xmlrpc-howto-interfaces"
|
|
>4. Common XML-RPC Interfaces</A
|
|
></H1
|
|
><P
|
|
>Several XML-RPC servers provide built-in methods. These aren't
|
|
part of XML-RPC itself, but they make handy add-ons.</P
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="xmlrpc-howto-api-introspection"
|
|
>4.1. Introspection: Discovering Server APIs</A
|
|
></H2
|
|
><P
|
|
>Edd Dumbill <A
|
|
HREF="http://xmlrpc.usefulinc.com/doc/reserved.html"
|
|
TARGET="_top"
|
|
>proposed</A
|
|
>
|
|
the following set of methods:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="synopsis"
|
|
><SPAN
|
|
CLASS="returnvalue"
|
|
>array</SPAN
|
|
> <TT
|
|
CLASS="function"
|
|
>system.listMethods</TT
|
|
> ()
|
|
<SPAN
|
|
CLASS="returnvalue"
|
|
>string</SPAN
|
|
> <TT
|
|
CLASS="function"
|
|
>system.methodHelp</TT
|
|
> (<SPAN
|
|
CLASS="type"
|
|
>string</SPAN
|
|
> <TT
|
|
CLASS="parameter"
|
|
><I
|
|
>methodName</I
|
|
></TT
|
|
>)
|
|
<SPAN
|
|
CLASS="returnvalue"
|
|
>array</SPAN
|
|
> <TT
|
|
CLASS="function"
|
|
>system.methodSignature</TT
|
|
> (<SPAN
|
|
CLASS="type"
|
|
>string</SPAN
|
|
> <TT
|
|
CLASS="parameter"
|
|
><I
|
|
>methodName</I
|
|
></TT
|
|
>)</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>If a server supports these methods, you can ask it to print out
|
|
some documentation:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
>import xmlrpclib
|
|
server = xmlrpclib.Server("http://xmlrpc-c.sourceforge.net/api/sample.php")
|
|
for method in server.system.listMethods():
|
|
print method
|
|
print server.system.methodHelp(method)
|
|
print</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>These methods are currently supported by servers written in
|
|
PHP, C and Microsoft .NET. Partial introspection support is included
|
|
in recent updates to UserLand Frontier. Introspection support for
|
|
Perl, Python and Java is available at the <A
|
|
HREF="http://xmlrpc-c.sourceforge.net/hacks.php"
|
|
TARGET="_top"
|
|
>XML-RPC
|
|
Hacks</A
|
|
> page. Please feel free to add introspection support to
|
|
other XML-RPC servers!</P
|
|
><P
|
|
>Various client-side tools (documentation generators, wrapper
|
|
generators, and so on) can be found at the XML-RPC Hacks page as
|
|
well.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="xmlrpc-howto-api-boxcarring"
|
|
>4.2. Boxcarring: Sending Multiple Requests at Once</A
|
|
></H2
|
|
><P
|
|
>If you're writing an XML-RPC client which makes lots of small
|
|
function calls, you may discover that your round-trip time is fairly
|
|
high, thanks to Internet backbone latency. Some servers allow you to
|
|
batch up multiple requests using the following function:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="synopsis"
|
|
><SPAN
|
|
CLASS="returnvalue"
|
|
>array</SPAN
|
|
> <TT
|
|
CLASS="function"
|
|
>system.multicall</TT
|
|
> (<SPAN
|
|
CLASS="type"
|
|
>array</SPAN
|
|
> <TT
|
|
CLASS="parameter"
|
|
><I
|
|
>calls</I
|
|
></TT
|
|
>)</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>You can find more information in the <A
|
|
HREF="http://www.xmlrpc.com/discuss/msgReader$1208"
|
|
TARGET="_top"
|
|
>system.multicall
|
|
RFC</A
|
|
>.</P
|
|
><P
|
|
>This method is currently supported by servers written in C and
|
|
UserLand Frontier. Servers written in Python and Perl can use the
|
|
code at the <A
|
|
HREF="http://xmlrpc-c.sourceforge.net/hacks.php"
|
|
TARGET="_top"
|
|
>XML-RPC
|
|
Hacks</A
|
|
> page.</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="xmlrpc-howto-competition.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="xmlrpc-howto-api.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>XML-RPC vs. Other Protocols</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>A Sample API: <TT
|
|
CLASS="function"
|
|
>sumAndDifference</TT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |