cvs: peardoc /en/package/webservices/xml-rpc2 intro.xml
| From: | Fabien MARTY | Date: | Sun, 12 Feb 2006 22:29:32 +0000 |
| Subject: | cvs: peardoc /en/package/webservices/xml-rpc2 intro.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7502@lists.php.net to get a copy of this message | ||
fab Sun Feb 12 22:29:32 2006 UTC
Modified files:
/peardoc/en/package/webservices/xml-rpc2 intro.xml
Log:
work in progress (not finished)
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/webservices/xml-rpc2/intro.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/webservices/xml-rpc2/intro.xml diff -u peardoc/en/package/webservices/xml-rpc2/intro.xml:1.1 peardoc/en/package/webservices/xml-rpc2/intro.xml:1.2 --- peardoc/en/package/webservices/xml-rpc2/intro.xml:1.1 Sun Feb 12 00:52:19 2006 +++ peardoc/en/package/webservices/xml-rpc2/intro.xml Sun Feb 12 22:29:32 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.webservices.xml-rpc2.intro"> <refnamediv> @@ -6,14 +6,232 @@ <refpurpose></refpurpose> </refnamediv> - <refsect1 id="package.webservices.xml-rpc2.intro.general"> - <title>to be written</title> + <refsect1 id="package.webservices.xml-rpc2.intro.desc"> + &title.desc; + <para> + XML_RPC2 is a "PHP5 only" implementation of the XMLRPC protocol. This package + provides the client and the server side of the protocol. An optimized cache + is also available for both parts. + </para> + <para> + As a client library, XML_RPC2 is capable of creating a proxy class which + exposes the methods exported by the server. So it's very easy and + natural to call XMLRPC exported methods. Like in Python language, the classic + way to use XML_RPC2 client side is : + </para> + <itemizedlist> + <listitem> + <para> + We make a XML_RCP2_Client object with server informations as arguments. + </para> + </listitem> + <listitem> + <para> + In a classic way, we call a method of this object. + </para> + </listitem> + <listitem> + <para> + Then, the method call is XMLRPC encoded, sent to the server, the response + is decoded into PHP native types and we get the result of the call (all this + logic is made by the library in a completely transparent way). + </para> + </listitem> + </itemizedlist> + <para> + As a server library, XML_RPC2 is capable of exposing methods from a class or + object instance, seamlessly capable of exposing methods from a class or + object instance, seamlessly exporting local methods as remotely callable + procedures. Method signatures are automatically determined and checked by using + the reflection API and PHPDOC comments. An automatic documentation about + XMLRPC exported methods is dynamically built and available at the server URL + (with a simple HTTP GET). + </para> + <para> + For both sides, an optimized cache based on Cache_Lite can be set. It can + be really usefull especially on public XMLRPC servers. + </para> + </refsect1> + + <refsect1 id="package.webservices.xml-rpc2.intro.requirements"> + <title>Requirements</title> + <para> + XML_RCP2 need PHP5 and the CURL extension. To avoid in next version, the CURL + dependency, we are waiting for a PHP5 E_STRICT PEAR module for HTTP_Request. + </para> + <para> + If you want to use the integrated cache, you will also need the Cache_Lite + PEAR module but it's of course an optional dependency. + </para> + <para> + XML_RPC2 can use two backends for the XMLRPC encoding/decoding : + </para> + <itemizedlist> + <listitem> + <para> + XMLRPCEXT, which of course need this PHP extension (probably the better + choice but it's an additional dependency) ; + </para> + </listitem> + <listitem> + <para> + PHP, which doesn't need the XMLRPCEXT extension at all (this is full PHP + but slower). + </para> + </listitem> + </itemizedlist> + </refsect1> + + <refsect1 id="package.webservices.xml-rpc2.intro.exampleclient"> + <title>A first example of the client side use</title> + <para> + Let's start with a XMLRPC call to the pear.php.net XMLRPC server : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/Client.php'; + +$options = array( + 'prefix' => 'package.' +); + +// We make the XML_RPC2_Client object (as the backend is not specified, XMLRPCEXT +// will be used if available (full PHP else)) +$client = XML_RPC2_Client::create('http://pear.php.net/xmlrpc.php', $options); + +try { + + // Because of the prefix specified in the $options array, indeed, we will call + // the package.info() method with a single argument (the string 'XML_RPC2') + $result = $client->info('XML_RPC2'); + + // $result is a complex PHP type (no XMLRPC decoding needed, it's already done) + 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.intro.exampleserver"> + <title>A first example of the server side use</title> <para> - to be written + Let's build a XMLRPC "echo server" : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/Server.php'; + +// Let's define a class with public static methods +// PHPDOC comments are really important because they are used for automatic +// signature checking + +class EchoServer { + + /** + * echoes the message received + * + * @param string Message + * @return string The echo + */ + public static function echoecho($string) { + return $string; + } + +} + +$options = array( + 'prefix' => 'test.' // we define a sort of "namespace" for the server +); + +// Let's build the server object with the name of the Echo class +$server = XML_RPC2_Server::create('EchoServer', $options); +$server->handleCall(); + +?> + ]]> + </programlisting> + If you do a simple HTTP GET on the server URL, you will get an automatic + HTML documentation about the echoecho function. If you make a XMLRPC client + request on the same URL about the "test.echoecho()" method (with one argument), + you will get your argument as a response. If you call another method or with a + bad arguments number, you will get an error (because of automatic method + signature checking). </para> </refsect1> + <refsect1 id="package.webservices.xml-rpc2.intro.examplecachedclient"> + <title>A first example of the client side use (with integrated cache)</title> + <para> + As the caching process is completely transparent, this is very similar to the standard client side use : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/CachedClient.php'; + +$options = array( + 'prefix' => 'package.', + 'cacheDebug' => false // with cacheDebug set to true, it's very easy to get an indication about the cache using (or not) + 'cacheOptions' => array( + 'cacheDir' => '/tmp/', + 'lifetime' => 3600, // during this lifetime, the local cache will be used + 'cacheByDefault' => true // all methods call will be cached (but a more precise way is possible) + ) +); + +// We make the XML_RPC2_CachedClient object (same syntax than XML_RPC2_Client) +$client = XML_RPC2_CachedClient::create('http://pear.php.net/xmlrpc.php', $options); + +try { + + // First call, the cache won't be used + $result = $client->info('XML_RPC2'); + print_r($result); + + // Second call, the cache will be used (in a transparent way) and no + // additional HTTP request will be sent to the server + $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.intro.examplecachedserver"> + <title>A first example of the server side use (with integrated cache)</title> + <para> + TO BE WRITTEN + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/webservices/xml-rpc2/intro.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/webservices/xml-rpc2/intro.xml diff -u peardoc/en/package/webservices/xml-rpc2/intro.xml:1.1 peardoc/en/package/webservices/xml-rpc2/intro.xml:1.2 --- peardoc/en/package/webservices/xml-rpc2/intro.xml:1.1 Sun Feb 12 00:52:19 2006 +++ peardoc/en/package/webservices/xml-rpc2/intro.xml Sun Feb 12 22:29:32 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.webservices.xml-rpc2.intro"> <refnamediv> @@ -6,14 +6,232 @@ <refpurpose></refpurpose> </refnamediv> - <refsect1 id="package.webservices.xml-rpc2.intro.general"> - <title>to be written</title> + <refsect1 id="package.webservices.xml-rpc2.intro.desc"> + &title.desc; + <para> + XML_RPC2 is a "PHP5 only" implementation of the XMLRPC protocol. This package + provides the client and the server side of the protocol. An optimized cache + is also available for both parts. + </para> + <para> + As a client library, XML_RPC2 is capable of creating a proxy class which + exposes the methods exported by the server. So it's very easy and + natural to call XMLRPC exported methods. Like in Python language, the classic + way to use XML_RPC2 client side is : + </para> + <itemizedlist> + <listitem> + <para> + We make a XML_RCP2_Client object with server informations as arguments. + </para> + </listitem> + <listitem> + <para> + In a classic way, we call a method of this object. + </para> + </listitem> + <listitem> + <para> + Then, the method call is XMLRPC encoded, sent to the server, the response + is decoded into PHP native types and we get the result of the call (all this + logic is made by the library in a completely transparent way). + </para> + </listitem> + </itemizedlist> + <para> + As a server library, XML_RPC2 is capable of exposing methods from a class or + object instance, seamlessly capable of exposing methods from a class or + object instance, seamlessly exporting local methods as remotely callable + procedures. Method signatures are automatically determined and checked by using + the reflection API and PHPDOC comments. An automatic documentation about + XMLRPC exported methods is dynamically built and available at the server URL + (with a simple HTTP GET). + </para> + <para> + For both sides, an optimized cache based on Cache_Lite can be set. It can + be really usefull especially on public XMLRPC servers. + </para> + </refsect1> + + <refsect1 id="package.webservices.xml-rpc2.intro.requirements"> + <title>Requirements</title> + <para> + XML_RCP2 need PHP5 and the CURL extension. To avoid in next version, the CURL + dependency, we are waiting for a PHP5 E_STRICT PEAR module for HTTP_Request. + </para> + <para> + If you want to use the integrated cache, you will also need the Cache_Lite + PEAR module but it's of course an optional dependency. + </para> + <para> + XML_RPC2 can use two backends for the XMLRPC encoding/decoding : + </para> + <itemizedlist> + <listitem> + <para> + XMLRPCEXT, which of course need this PHP extension (probably the better + choice but it's an additional dependency) ; + </para> + </listitem> + <listitem> + <para> + PHP, which doesn't need the XMLRPCEXT extension at all (this is full PHP + but slower). + </para> + </listitem> + </itemizedlist> + </refsect1> + + <refsect1 id="package.webservices.xml-rpc2.intro.exampleclient"> + <title>A first example of the client side use</title> + <para> + Let's start with a XMLRPC call to the pear.php.net XMLRPC server : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/Client.php'; + +$options = array( + 'prefix' => 'package.' +); + +// We make the XML_RPC2_Client object (as the backend is not specified, XMLRPCEXT +// will be used if available (full PHP else)) +$client = XML_RPC2_Client::create('http://pear.php.net/xmlrpc.php', $options); + +try { + + // Because of the prefix specified in the $options array, indeed, we will call + // the package.info() method with a single argument (the string 'XML_RPC2') + $result = $client->info('XML_RPC2'); + + // $result is a complex PHP type (no XMLRPC decoding needed, it's already done) + 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.intro.exampleserver"> + <title>A first example of the server side use</title> <para> - to be written + Let's build a XMLRPC "echo server" : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/Server.php'; + +// Let's define a class with public static methods +// PHPDOC comments are really important because they are used for automatic +// signature checking + +class EchoServer { + + /** + * echoes the message received + * + * @param string Message + * @return string The echo + */ + public static function echoecho($string) { + return $string; + } + +} + +$options = array( + 'prefix' => 'test.' // we define a sort of "namespace" for the server +); + +// Let's build the server object with the name of the Echo class +$server = XML_RPC2_Server::create('EchoServer', $options); +$server->handleCall(); + +?> + ]]> + </programlisting> + If you do a simple HTTP GET on the server URL, you will get an automatic + HTML documentation about the echoecho function. If you make a XMLRPC client + request on the same URL about the "test.echoecho()" method (with one argument), + you will get your argument as a response. If you call another method or with a + bad arguments number, you will get an error (because of automatic method + signature checking). </para> </refsect1> + <refsect1 id="package.webservices.xml-rpc2.intro.examplecachedclient"> + <title>A first example of the client side use (with integrated cache)</title> + <para> + As the caching process is completely transparent, this is very similar to the standard client side use : + <programlisting role="php"> + <![CDATA[ +<?php + +require_once 'XML/RPC2/CachedClient.php'; + +$options = array( + 'prefix' => 'package.', + 'cacheDebug' => false // with cacheDebug set to true, it's very easy to get an indication about the cache using (or not) + 'cacheOptions' => array( + 'cacheDir' => '/tmp/', + 'lifetime' => 3600, // during this lifetime, the local cache will be used + 'cacheByDefault' => true // all methods call will be cached (but a more precise way is possible) + ) +); + +// We make the XML_RPC2_CachedClient object (same syntax than XML_RPC2_Client) +$client = XML_RPC2_CachedClient::create('http://pear.php.net/xmlrpc.php', $options); + +try { + + // First call, the cache won't be used + $result = $client->info('XML_RPC2'); + print_r($result); + + // Second call, the cache will be used (in a transparent way) and no + // additional HTTP request will be sent to the server + $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.intro.examplecachedserver"> + <title>A first example of the server side use (with integrated cache)</title> + <para> + TO BE WRITTEN + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file