cvs: peardoc /en/package/webservices/xml-rpc2 client.xml

From: Date: Mon, 13 Feb 2006 23:16:08 +0000
Subject: cvs: peardoc /en/package/webservices/xml-rpc2 client.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-7511@lists.php.net to get a copy of this message
fab Mon Feb 13 23:16:08 2006 UTC Modified files: /peardoc/en/package/webservices/xml-rpc2 client.xml Log: launch work on client doc http://cvs.php.net/viewcvs.cgi/peardoc/en/package/webservices/xml-rpc2/client.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/webservices/xml-rpc2/client.xml diff -u peardoc/en/package/webservices/xml-rpc2/client.xml:1.1 peardoc/en/package/webservices/xml-rpc2/client.xml:1.2 --- peardoc/en/package/webservices/xml-rpc2/client.xml:1.1 Sun Feb 12 00:52:19 2006 +++ peardoc/en/package/webservices/xml-rpc2/client.xml Mon Feb 13 23:16:08 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.webservices.xml-rpc2.client"> <refnamediv> @@ -6,14 +6,130 @@ <refpurpose></refpurpose> </refnamediv> - <refsect1 id="package.webservices.xml-rpc2.client.general"> - <title>to be written</title> - + <refsect1 id="package.webservices.xml-rpc2.client.intro"> + <title>Introduction about the XML_RPC2 client side usage</title> + <para> + Thanks to PHP5, it's really easy to do XMLRPC client requests with + XML_RPC2. The usage is really straightforward. + </para> + <para> + First, you include 'XML/RPC2/Client.php' file (only this one). + <programlisting role="php"> + <![CDATA[ +require_once 'XML/RPC2/Client.php'; + ]]> + </programlisting> + </para> + <para> + Second, you make an assocative arrays of options to tune XML_RPC2 (prefix, + proxy, manual backend choice...). + <programlisting role="php"> + <![CDATA[ +$options = array( + 'prefix' => 'package.' +); + ]]> + </programlisting> + </para> + <para> + Third, you make a XML_RPC2_Client object with the server URL and the with + the options array. + <programlisting role="php"> + <![CDATA[ +$client = XML_RPC2_Client::create('http://pear.php.net/xmlrpc.php', $options); + ]]> + </programlisting> + </para> + <para> + Then, you send your request by calling the server method as it was a local + method of the $client object. + <programlisting role="php"> + <![CDATA[ +$result = $client->info('XML_RPC2'); + ]]> + </programlisting> + This single line will encode a XMLRPC client request for the package.info() (prefix + method name) + method with a single argument (the string 'XML_RPC2'), will send the request over HTTP to the + server and will decode the response into PHP native types. With a single line ! + </para> + <para> + Of course, to catch server errors, you have to add a few lines around you client call like for example : + <programlisting role="php"> + <![CDATA[ +try { + $result = $client->info('XML_RPC2'); + print_r($result); +} catch (XML_RPC2_FaultException $e) { + // The XMLRPC server returns a XMLRPC error + die('Exception #' . $result->getFaultCode() . ' : ' . $e->getFaultString()); +} catch (Exception $e) { + // Other errors (HTTP or networking problems...) + die('Exception : ' . $e->getFaultString()); +} + ]]> + </programlisting> + </para> + </refsect1> + <refsect1 id="package.webservices.xml-rpc2.client.options"> + <title>The options array</title> <para> - to be written + This array is completely optional but really usefull. The following keys + are available : + <table> + <title>Options available keys</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Option</entry> + <entry>Data Type</entry> + <entry>Default Value</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>prefix</entry> + <entry>&type.string;</entry> + <entry>''</entry> + <entry>Prefix added before XMLRPC called method name</entry> + </row> + <row> + <entry>proxy</entry> + <entry>&type.string;</entry> + <entry>''</entry> + <entry>Proxy used for the HTTP request (default : no proxy)</entry> + </row> + <row> + <entry>debug</entry> + <entry>&type.bool;</entry> + <entry>&false;</entry> + <entry>Debug mode ?</entry> + </row> + <row> + <entry>encoding</entry> + <entry>&type.string;</entry> + <entry>''</entry> + <entry>Encoding of the request 'utf-8', 'iso-8859-1' (for now, only these two ones are officialy supported)</entry> + </row> + <row> + <entry>uglyStructHack</entry> + <entry>&type.bool;</entry> + <entry>&true;</entry> + <entry>ugly hack to circumvent a XMLRPCEXT bug/feature , see + <ulink url="http://bugs.php.net/bug.php?id=21949">this PHP bug</ulink> + for more details. The only (reasonable) counterpart of this hack is + that you can't use structs with a key beginning with the string + 'xml_rpc2_ugly_struct_hack_' as arguments of the called method. + </entry> + </row> + </tbody> + </tgroup> + </table> + TO BE CONTINUED + TO BE CONTINUED + TO BE CONTINUED </para> </refsect1> - </refentry> <!-- Keep this comment at the end of the file

« previous php.pear.doc (#7511) next »