<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <link rel="STYLESHEET" href="lib.css" type='text/css' /> <link rel="SHORTCUT ICON" href="../icons/pyfav.gif" /> <link rel='start' href='../index.html' title='Python Documentation Index' /> <link rel="first" href="lib.html" title='Python Library Reference' /> <link rel='contents' href='contents.html' title="Contents" /> <link rel='index' href='genindex.html' title='Index' /> <link rel='last' href='about.html' title='About this document...' /> <link rel='help' href='about.html' title='About this document...' /> <LINK rel="next" href="module-SimpleXMLRPCServer.html"> <LINK rel="prev" href="module-Cookie.html"> <LINK rel="parent" href="internet.html"> <LINK rel="next" href="serverproxy-objects.html"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name='aesop' content='information' /> <META name="description" content="xmlrpclib -- XML-RPC client access"> <META name="keywords" content="lib"> <META name="resource-type" content="document"> <META name="distribution" content="global"> <title>11.20 xmlrpclib -- XML-RPC client access</title> </head> <body> <DIV CLASS="navigation"> <div id='top-navigation-panel'> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="11.19.3 Example" href="cookie-example.html"><img src='../icons/previous.png' border='0' height='32' alt='Previous Page' width='32' /></A></td> <td class='online-navigation'><a rel="parent" title="11. Internet Protocols and" href="internet.html"><img src='../icons/up.png' border='0' height='32' alt='Up One Level' width='32' /></A></td> <td class='online-navigation'><a rel="next" title="11.20.1 ServerProxy Objects" href="serverproxy-objects.html"><img src='../icons/next.png' border='0' height='32' alt='Next Page' width='32' /></A></td> <td align="center" width="100%">Python Library Reference</td> <td class='online-navigation'><a rel="contents" title="Table of Contents" href="contents.html"><img src='../icons/contents.png' border='0' height='32' alt='Contents' width='32' /></A></td> <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' border='0' height='32' alt='Module Index' width='32' /></a></td> <td class='online-navigation'><a rel="index" title="Index" href="genindex.html"><img src='../icons/index.png' border='0' height='32' alt='Index' width='32' /></A></td> </tr></table> <div class='online-navigation'> <b class="navlabel">Previous:</b> <a class="sectref" rel="prev" href="cookie-example.html">11.19.3 Example</A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="serverproxy-objects.html">11.20.1 ServerProxy Objects</A> </div> <hr /></div> </DIV> <!--End of Navigation Panel--> <H1><A NAME="SECTION00132000000000000000000"> 11.20 <tt class="module">xmlrpclib</tt> -- XML-RPC client access</A> </H1> <P> <A NAME="module-xmlrpclib"><!--z--></A> <P> <span class="versionnote">New in version 2.2.</span> <P> XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. This module supports writing XML-RPC client code; it handles all the details of translating between conformable Python objects and XML on the wire. <P> <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-3412' class="class">ServerProxy</tt></b>(</nobr></td> <td><var>uri</var><big>[</big><var>, transport</var><big>[</big><var>, encoding</var><big>[</big><var>, verbose</var><big>[</big><var>, allow_none</var><big>]</big><big>]</big><big>]</big><big>]</big>)</td></tr></table></dt> <dd> A <tt class="class">ServerProxy</tt> instance is an object that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the server. The optional second argument is a transport factory instance; by default it is an internal <tt class="class">SafeTransport</tt> instance for https: URLs and an internal HTTP <tt class="class">Transport</tt> instance otherwise. The optional third argument is an encoding, by default UTF-8. The optional fourth argument is a debugging flag. If <var>allow_none</var> is true, the Python constant <code>None</code> will be translated into XML; the default behaviour is for <code>None</code> to raise a <tt class="exception">TypeError</tt>. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see <a class="url" href="http://ontosys.com/xml-rpc/extensions.html">http://ontosys.com/xml-rpc/extensions.html</a> for a description. <P> Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: <code>http://user:pass@host:port/path</code>. The <code>user:pass</code> portion will be base64-encoded as an HTTP `Authorization' header, and sent to the remote server as part of the connection process when invoking an XML-RPC method. You only need to use this if the remote server requires a Basic Authentication user and password. <P> The returned instance is a proxy object with methods that can be used to invoke corresponding RPC calls on the remote server. If the remote server supports the introspection API, the proxy can also be used to query the remote server for the methods it supports (service discovery) and fetch other server-associated metadata. <P> <tt class="class">ServerProxy</tt> instance methods take Python basic types and objects as arguments and return Python basic types and classes. Types that are conformable (e.g. that can be marshalled through XML), include the following (and except where noted, they are unmarshalled as the same Python type): <P> <table border align="center" style="border-collapse: collapse"> <thead> <tr class="tableheader"> <th align="left"><b>Name</b> </th> <th align="left"><b>Meaning</b> </th> </tr> </thead> <tbody valign="baseline"> <tr><td align="left" valign="baseline"><tt class="constant">boolean</tt></td> <td align="left">The <tt class="constant">True</tt> and <tt class="constant">False</tt> constants</td> <tr><td align="left" valign="baseline"><tt class="constant">integers</tt></td> <td align="left">Pass in directly</td> <tr><td align="left" valign="baseline"><tt class="constant">floating-point numbers</tt></td> <td align="left">Pass in directly</td> <tr><td align="left" valign="baseline"><tt class="constant">strings</tt></td> <td align="left">Pass in directly</td> <tr><td align="left" valign="baseline"><tt class="constant">arrays</tt></td> <td align="left">Any Python sequence type containing conformable elements. Arrays are returned as lists</td> <tr><td align="left" valign="baseline"><tt class="constant">structures</tt></td> <td align="left">A Python dictionary. Keys must be strings, values may be any conformable type.</td> <tr><td align="left" valign="baseline"><tt class="constant">dates</tt></td> <td align="left">in seconds since the epoch; pass in an instance of the <tt class="class">DateTime</tt> wrapper class</td> <tr><td align="left" valign="baseline"><tt class="constant">binary data</tt></td> <td align="left">pass in an instance of the <tt class="class">Binary</tt> wrapper class</td></tbody> </table> <P> This is the full set of data types supported by XML-RPC. Method calls may also raise a special <tt class="exception">Fault</tt> instance, used to signal XML-RPC server errors, or <tt class="exception">ProtocolError</tt> used to signal an error in the HTTP/HTTPS transport layer. Note that even though starting with Python 2.2 you can subclass builtin types, the xmlrpclib module currently does not marshal instances of such subclasses. <P> When passing strings, characters special to XML such as "<tt class="samp"><</tt>", "<tt class="samp">></tt>", and "<tt class="samp">&</tt>" will be automatically escaped. However, it's the caller's responsibility to ensure that the string is free of characters that aren't allowed in XML, such as the control characters with ASCII values between 0 and 31; failing to do this will result in an XML-RPC request that isn't well-formed XML. If you have to pass arbitrary strings via XML-RPC, use the <tt class="class">Binary</tt> wrapper class described below. <P> <tt class="class">Server</tt> is retained as an alias for <tt class="class">ServerProxy</tt> for backwards compatibility. New code should use <tt class="class">ServerProxy</tt>. <P> </dl> <P> <div class="seealso"> <p class="heading"><b>See Also:</b></p> <dl compact class="seetitle"> <dt><em class="citetitle"><a href="http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto.html" >XML-RPC HOWTO</a></em></dt> <dd>A good description of XML operation and client software in several languages. Contains pretty much everything an XML-RPC client developer needs to know.</dd> </dl> <dl compact class="seetitle"> <dt><em class="citetitle"><a href="http://xmlrpc-c.sourceforge.net/hacks.php" >XML-RPC-Hacks page</a></em></dt> <dd>Extensions for various open-source libraries to support instrospection and multicall.</dd> </dl> </div> <P> <p><br /></p><hr class='online-navigation' /> <div class='online-navigation'> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> <UL CLASS="ChildLinks"> <LI><A href="serverproxy-objects.html">11.20.1 ServerProxy Objects</a> <LI><A href="boolean-objects.html">11.20.2 Boolean Objects</a> <LI><A href="datetime-objects.html">11.20.3 DateTime Objects</a> <LI><A href="binary-objects.html">11.20.4 Binary Objects</a> <LI><A href="fault-objects.html">11.20.5 Fault Objects</a> <LI><A href="protocol-error-objects.html">11.20.6 ProtocolError Objects</a> <LI><A href="node474.html">11.20.7 Convenience Functions</a> <LI><A href="xmlrpc-client-example.html">11.20.8 Example of Client Usage</a> </ul> <!--End of Table of Child-Links--> </div> <DIV CLASS="navigation"> <div class='online-navigation'><hr /> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td class='online-navigation'><a rel="prev" title="11.19.3 Example" rel="prev" title="11.19.3 Example" href="cookie-example.html"><img src='../icons/previous.png' border='0' height='32' alt='Previous Page' width='32' /></A></td> <td class='online-navigation'><a rel="parent" title="11. Internet Protocols and" rel="parent" title="11. Internet Protocols and" href="internet.html"><img src='../icons/up.png' border='0' height='32' alt='Up One Level' width='32' /></A></td> <td class='online-navigation'><a rel="next" title="11.20.1 ServerProxy Objects" rel="next" title="11.20.1 ServerProxy Objects" href="serverproxy-objects.html"><img src='../icons/next.png' border='0' height='32' alt='Next Page' width='32' /></A></td> <td align="center" width="100%">Python Library Reference</td> <td class='online-navigation'><a rel="contents" title="Table of Contents" rel="contents" title="Table of Contents" href="contents.html"><img src='../icons/contents.png' border='0' height='32' alt='Contents' width='32' /></A></td> <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' border='0' height='32' alt='Module Index' width='32' /></a></td> <td class='online-navigation'><a rel="index" title="Index" rel="index" title="Index" href="genindex.html"><img src='../icons/index.png' border='0' height='32' alt='Index' width='32' /></A></td> </tr></table> <div class='online-navigation'> <b class="navlabel">Previous:</b> <a class="sectref" rel="prev" href="cookie-example.html">11.19.3 Example</A> <b class="navlabel">Up:</b> <a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A> <b class="navlabel">Next:</b> <a class="sectref" rel="next" href="serverproxy-objects.html">11.20.1 ServerProxy Objects</A> </div> </div> <hr /> <span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</span> </DIV> <!--End of Navigation Panel--> <ADDRESS> See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. </ADDRESS> </BODY> </HTML>