- Initial import of the mob, reorganizing dirs to match packaged version
[plcapi.git] / doc / xmlrpc_php.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <?xml-stylesheet href="docbook-css/driver.css" type="text/css"?>\r
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"\r
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
5 <!--\r
6 PHP-XMLRPC User manual\r
7 $Id: xmlrpc_php.xml,v 1.27 2008/09/19 18:35:33 ggiunta Exp $\r
8 -->\r
9 <book lang="en">\r
10   <title>XML-RPC for PHP</title>\r
11 \r
12   <subtitle>version 2.2.2</subtitle>\r
13 \r
14   <bookinfo>\r
15     <date>XXX YY, 2008</date>\r
16 \r
17     <authorgroup>\r
18       <author>\r
19         <firstname>Edd</firstname>\r
20 \r
21         <surname>Dumbill</surname>\r
22       </author>\r
23 \r
24       <author>\r
25         <firstname>Gaetano</firstname>\r
26 \r
27         <surname>Giunta</surname>\r
28       </author>\r
29 \r
30       <author>\r
31         <firstname>Miles</firstname>\r
32 \r
33         <surname>Lott</surname>\r
34       </author>\r
35 \r
36       <author>\r
37         <firstname>Justin R.</firstname>\r
38 \r
39         <surname>Miller</surname>\r
40       </author>\r
41 \r
42       <author>\r
43         <firstname>Andres</firstname>\r
44 \r
45         <surname>Salomon</surname>\r
46       </author>\r
47     </authorgroup>\r
48 \r
49     <copyright>\r
50       <year>1999,2000,2001</year>\r
51 \r
52       <holder>Edd Dumbill, Useful Information Company</holder>\r
53     </copyright>\r
54 \r
55     <legalnotice>\r
56       <para>All rights reserved.</para>\r
57 \r
58       <para>Redistribution and use in source and binary forms, with or without\r
59       modification, are permitted provided that the following conditions are\r
60       met:</para>\r
61 \r
62       <para><itemizedlist>\r
63           <listitem>\r
64             <para>Redistributions of source code must retain the above\r
65             copyright notice, this list of conditions and the following\r
66             disclaimer.</para>\r
67           </listitem>\r
68 \r
69           <listitem>\r
70             <para>Redistributions in binary form must reproduce the above\r
71             copyright notice, this list of conditions and the following\r
72             disclaimer in the documentation and/or other materials provided\r
73             with the distribution.</para>\r
74           </listitem>\r
75 \r
76           <listitem>\r
77             <para>Neither the name of the "XML-RPC for PHP" nor the names of\r
78             its contributors may be used to endorse or promote products\r
79             derived from this software without specific prior written\r
80             permission.</para>\r
81           </listitem>\r
82         </itemizedlist></para>\r
83 \r
84       <para>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r
85       CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
86       BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
87       FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
88       REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
89       SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
90       TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
91       PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
92       LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
93       NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
94       SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</para>\r
95     </legalnotice>\r
96   </bookinfo>\r
97 \r
98   <chapter id="introduction">\r
99     <title>Introduction</title>\r
100 \r
101     <para>XML-RPC is a format devised by <ulink\r
102     url="http://www.userland.com/">Userland Software</ulink> for achieving\r
103     remote procedure call via XML using HTTP as the transport. XML-RPC has its\r
104     own web site, <ulink\r
105     url="http://www.xmlrpc.com/">www.xmlrpc.com</ulink></para>\r
106 \r
107     <para>This collection of PHP classes provides a framework for writing\r
108     XML-RPC clients and servers in PHP.</para>\r
109 \r
110     <para>Main goals of the project are ease of use, flexibility and\r
111     completeness.</para>\r
112 \r
113     <para>The original author is Edd Dumbill of <ulink\r
114     url="http://usefulinc.com/">Useful Information Company</ulink>. As of the\r
115     1.0 stable release, the project has been opened to wider involvement and\r
116     moved to <ulink\r
117     url="http://phpxmlrpc.sourceforge.net/">SourceForge</ulink>.</para>\r
118 \r
119     <para>A list of XML-RPC implementations for other languages such as Perl\r
120     and Python can be found on the <ulink\r
121     url="http://www.xmlrpc.com/">www.xmlrpc.com</ulink> site.</para>\r
122 \r
123     <sect1>\r
124       <title>Acknowledgements</title>\r
125 \r
126       <para>Daniel E. Baumann</para>\r
127 \r
128       <para>James Bercegay</para>\r
129 \r
130       <para>Leon Blackwell</para>\r
131 \r
132       <para>Stephane Bortzmeyer</para>\r
133 \r
134       <para>Daniel Convissor</para>\r
135 \r
136       <para>Geoffrey T. Dairiki</para>\r
137 \r
138       <para>Stefan Esser</para>\r
139 \r
140       <para>James Flemer</para>\r
141 \r
142       <para>Ernst de Haan</para>\r
143 \r
144       <para>Tom Knight</para>\r
145 \r
146       <para>Axel Kollmorgen</para>\r
147 \r
148       <para>Peter Kocks</para>\r
149 \r
150       <para>Daniel Krippner</para>\r
151 \r
152       <para>S. Kuip</para>\r
153 \r
154       <para>A. Lambert</para>\r
155 \r
156       <para>Dan Libby</para>\r
157 \r
158       <para>Arnaud Limbourg</para>\r
159 \r
160       <para>Ernest MacDougal Campbell III</para>\r
161 \r
162       <para>Lukasz Mach</para>\r
163 \r
164       <para>Kjartan Mannes</para>\r
165 \r
166       <para>Ben Margolin</para>\r
167 \r
168       <para>Nicolay Mausz</para>\r
169 \r
170       <para>Justin Miller</para>\r
171 \r
172       <para>Jan Pfeifer</para>\r
173 \r
174       <para>Giancarlo Pinerolo</para>\r
175 \r
176       <para>Peter Russel</para>\r
177 \r
178       <para>Viliam Simko</para>\r
179 \r
180       <para>Douglas Squirrel</para>\r
181 \r
182       <para>Idan Sofer</para>\r
183 \r
184       <para>Anatoly Techtonik</para>\r
185 \r
186       <para>Eric van der Vlist</para>\r
187 \r
188       <para>Christian Wenz</para>\r
189 \r
190       <para>Jim Winstead</para>\r
191 \r
192       <para>Przemyslaw Wroblewski</para>\r
193     </sect1>\r
194   </chapter>\r
195 \r
196   <chapter id="news">\r
197     <title>What's new</title>\r
198 \r
199     <para><emphasis>Note:</emphasis> not all items the following list have\r
200     (yet) been fully documented, and some might not be present in any other\r
201     chapter in the manual. To find a more detailed description of new\r
202     functions and methods please take a look at the source code of the\r
203     library, which is quite thoroughly commented in javadoc-like form.</para>\r
204 \r
205     <sect1>\r
206       <title>2.2.2</title>\r
207 \r
208       <para><itemizedlist>\r
209           <listitem>\r
210             <para>fixed: encoding of utf-8 characters outside of the BMP\r
211             plane</para>\r
212           </listitem>\r
213 \r
214           <listitem>\r
215             <para>fixed: character set declarations surrounded by double\r
216             quotes were not recognized in http headers</para>\r
217           </listitem>\r
218         </itemizedlist></para>\r
219     </sect1>\r
220 \r
221     <sect1>\r
222       <title>2.2.1</title>\r
223 \r
224       <para><emphasis>Note:</emphasis> this is the last release of the library\r
225       that will support PHP 4. Future releases (if any) will target php 5.0 as\r
226       minimum supported version.</para>\r
227 \r
228       <itemizedlist>\r
229         <listitem>\r
230           <para>fixed: work aroung bug in php 5.2.2 which broke support of\r
231           HTTP_RAW_POST_DATA</para>\r
232         </listitem>\r
233 \r
234         <listitem>\r
235           <para>fixed: is_dir parameter of setCaCertificate() method is\r
236           reversed</para>\r
237         </listitem>\r
238 \r
239         <listitem>\r
240           <para>fixed: a php warning in xmlrpc_client creator method</para>\r
241         </listitem>\r
242 \r
243         <listitem>\r
244           <para>fixed: parsing of '1e+1' as valid float</para>\r
245         </listitem>\r
246 \r
247         <listitem>\r
248           <para>fixed: allow errorlevel 3 to work when prev. error handler was\r
249           a static method</para>\r
250         </listitem>\r
251 \r
252         <listitem>\r
253           <para>fixed: usage of client::setcookie() for multiple cookies in\r
254           non-ssl mode</para>\r
255         </listitem>\r
256 \r
257         <listitem>\r
258           <para>improved: support for CP1252 charset is not part or the\r
259           library but almost possible</para>\r
260         </listitem>\r
261 \r
262         <listitem>\r
263           <para>improved: more info when curl is enabled and debug mode is\r
264           on</para>\r
265         </listitem>\r
266       </itemizedlist>\r
267     </sect1>\r
268 \r
269     <sect1>\r
270       <title>2.2</title>\r
271 \r
272       <itemizedlist>\r
273         <listitem>\r
274           <para>fixed: debugger errors on php installs with magic_quotes_gpc\r
275           on</para>\r
276         </listitem>\r
277 \r
278         <listitem>\r
279           <para>fixed: support for https connections via proxy</para>\r
280         </listitem>\r
281 \r
282         <listitem>\r
283           <para>fixed: wrap_xmlrpc_method() generated code failed to properly\r
284           encode php objects</para>\r
285         </listitem>\r
286 \r
287         <listitem>\r
288           <para>improved: slightly faster encoding of data which is internally\r
289           UTF-8</para>\r
290         </listitem>\r
291 \r
292         <listitem>\r
293           <para>improved: debugger always generates a 'null' id for jsonrpc if\r
294           user omits it</para>\r
295         </listitem>\r
296 \r
297         <listitem>\r
298           <para>new: debugger can take advantage of a graphical value builder\r
299           (it has to be downloaded separately, as part of jsxmlrpc package.\r
300           See Appendix D for more details)</para>\r
301         </listitem>\r
302 \r
303         <listitem>\r
304           <para>new: support for the &lt;NIL/&gt; xmlrpc extension. see below\r
305           for more details</para>\r
306         </listitem>\r
307 \r
308         <listitem>\r
309           <para>new: server support for the system.getCapabilities xmlrpc\r
310           extension</para>\r
311         </listitem>\r
312 \r
313         <listitem>\r
314           <para>new: <function><link\r
315           linkend="wrap_xmlrpc_method">wrap_xmlrpc_method()</link></function>\r
316           accepts two new options: debug and return_on_fault</para>\r
317         </listitem>\r
318       </itemizedlist>\r
319     </sect1>\r
320 \r
321     <sect1>\r
322       <title>2.1</title>\r
323 \r
324       <para><itemizedlist>\r
325           <listitem>\r
326             <para>The <function>wrap_php_function</function> and\r
327             <function>wrap_xmlrpc_method</function> functions have been moved\r
328             out of the base library file <filename>xmlrpc.inc</filename> into\r
329             a file of their own: <filename>xmlrpc_wrappers.inc</filename>. You\r
330             will have to include() / require() it in your scripts if you have\r
331             been using those functions. For increased security, the automatic\r
332             rebuilding of php object instances out of received xmlrpc structs\r
333             in <function>wrap_xmlrpc_method()</function> has been disabled\r
334             (but it can be optionally re-enabled). Both\r
335             <function>wrap_php_function()</function> and\r
336             <function>wrap_xmlrpc_method()</function> functions accept many\r
337             more options to fine tune their behaviour, including one to return\r
338             the php code to be saved and later used as standalone php\r
339             script</para>\r
340           </listitem>\r
341 \r
342           <listitem>\r
343             <para>The constructor of xmlrpcval() values has seen some internal\r
344             changes, and it will not throw a php warning anymore when invoked\r
345             using an unknown xmlrpc type: the error will only be written to\r
346             php error log. Also <code>new xmlrpcval('true', 'boolean')</code>\r
347             is not supported anymore</para>\r
348           </listitem>\r
349 \r
350           <listitem>\r
351             <para>The new function\r
352             <function>php_xmlrpc_decode_xml()</function> will take the xml\r
353             representation of either an xmlrpc request, response or single\r
354             value and return the corresponding php-xmlrpc object\r
355             instance</para>\r
356           </listitem>\r
357 \r
358           <listitem>\r
359             <para>A new function <function>wrap_xmlrpc_server()</function>has\r
360             been added, to wrap all (or some) of the methods exposed by a\r
361             remote xmlrpc server into a php class</para>\r
362           </listitem>\r
363 \r
364           <listitem>\r
365             <para>A new file has been added:\r
366             <filename>verify_compat.php</filename>, to help users diagnose the\r
367             level of compliance of their php installation with the\r
368             library</para>\r
369           </listitem>\r
370 \r
371           <listitem>\r
372             <para>Restored compatibility with php 4.0.5 (for those poor souls\r
373             still stuck on it)</para>\r
374           </listitem>\r
375 \r
376           <listitem>\r
377             <para>Method <methodname>xmlrpc_server-&gt;service()</methodname>\r
378             now returns a value: either the response payload or xmlrpcresp\r
379             object instance</para>\r
380           </listitem>\r
381 \r
382           <listitem>\r
383             <para>Method\r
384             <methodname>xmlrpc_server-&gt;add_to_map()</methodname> now\r
385             accepts xmlrpc methods with no param definitions</para>\r
386           </listitem>\r
387 \r
388           <listitem>\r
389             <para>Documentation for single parameters of exposed methods can\r
390             be added to the dispatch map (and turned into html docs in\r
391             conjunction with a future release of the 'extras' package)</para>\r
392           </listitem>\r
393 \r
394           <listitem>\r
395             <para>Full response payload is saved into xmlrpcresp object for\r
396             further debugging</para>\r
397           </listitem>\r
398 \r
399           <listitem>\r
400             <para>The debugger can now generate code that wraps a remote\r
401             method into a php function (works for jsonrpc, too); it also has\r
402             better support for being activated via a single GET call (e.g. for\r
403             integration into other tools)</para>\r
404           </listitem>\r
405 \r
406           <listitem>\r
407             <para>Stricter parsing of incoming xmlrpc messages: two more\r
408             invalid cases are now detected (double <literal>data</literal>\r
409             element inside <literal>array</literal> and\r
410             <literal>struct</literal>/<literal>array</literal> after scalar\r
411             inside <literal>value</literal> element)</para>\r
412           </listitem>\r
413 \r
414           <listitem>\r
415             <para>More logging of errors in a lot of situations</para>\r
416           </listitem>\r
417 \r
418           <listitem>\r
419             <para>Javadoc documentation of lib files (almost) complete</para>\r
420           </listitem>\r
421 \r
422           <listitem>\r
423             <para>Many performance tweaks and code cleanups, plus the usual\r
424             crop of bugs fixed (see NEWS file for complete list of\r
425             bugs)</para>\r
426           </listitem>\r
427 \r
428           <listitem>\r
429             <para>Lib internals have been modified to provide better support\r
430             for grafting extra functionality on top of it. Stay tuned for\r
431             future releases of the EXTRAS package (or go read Appendix\r
432             B)...</para>\r
433           </listitem>\r
434         </itemizedlist></para>\r
435     </sect1>\r
436 \r
437     <sect1>\r
438       <title>2.0 final</title>\r
439 \r
440       <para><itemizedlist>\r
441           <listitem>\r
442             <para>Added to the client class the possibility to use Digest and\r
443             NTLM authentication methods (when using the CURL library) for\r
444             connecting to servers and NTLM for connecting to proxies</para>\r
445           </listitem>\r
446 \r
447           <listitem>\r
448             <para>Added to the client class the possibility to specify\r
449             alternate certificate files/directories for authenticating the\r
450             peer with when using HTTPS communication</para>\r
451           </listitem>\r
452 \r
453           <listitem>\r
454             <para>Reviewed all examples and added a new demo file, containing\r
455             a proxy to forward xmlrpc requests to other servers (useful e.g.\r
456             for ajax coding)</para>\r
457           </listitem>\r
458 \r
459           <listitem>\r
460             <para>The debugger has been upgraded to reflect the new client\r
461             capabilities</para>\r
462           </listitem>\r
463 \r
464           <listitem>\r
465             <para>All known bugs have been squashed, and the lib is more\r
466             tolerant than ever of commonly-found mistakes</para>\r
467           </listitem>\r
468         </itemizedlist></para>\r
469     </sect1>\r
470 \r
471     <sect1>\r
472       <title>2.0 Release candidate 3</title>\r
473 \r
474       <para><itemizedlist>\r
475           <listitem>\r
476             <para>Added to server class the property\r
477             <property>functions_parameters_type</property>, that allows the\r
478             server to register plain php functions as xmlrpc methods (i.e.\r
479             functions that do not take an xmlrpcmsg object as unique\r
480             param)</para>\r
481           </listitem>\r
482 \r
483           <listitem>\r
484             <para>let server and client objects serialize calls using a\r
485             specified character set encoding for the produced xml instead of\r
486             US-ASCII (ISO-8859-1 and UTF-8 supported)</para>\r
487           </listitem>\r
488 \r
489           <listitem>\r
490             <para>let php_xmlrpc_decode accept xmlrpcmsg objects as valid\r
491             input</para>\r
492           </listitem>\r
493 \r
494           <listitem>\r
495             <para>'class::method' syntax is now accepted in the server\r
496             dispatch map</para>\r
497           </listitem>\r
498 \r
499           <listitem>\r
500             <para><function>xmlrpc_clent::SetDebug()</function> accepts\r
501             integer values instead of a boolean value, with debugging level 2\r
502             adding to the information printed to screen the complete client\r
503             request</para>\r
504           </listitem>\r
505         </itemizedlist></para>\r
506     </sect1>\r
507 \r
508     <sect1>\r
509       <title>2.0 Release candidate 2</title>\r
510 \r
511       <para><itemizedlist>\r
512           <listitem>\r
513             <para>Added a new property of the client object:\r
514             <code>xmlrpc_client-&gt;return_type</code>, indicating whether\r
515             calls to the send() method will return xmlrpcresp objects whose\r
516             value() is an xmlrpcval object, a php value (automatically\r
517             decoded) or the raw xml received from the server.</para>\r
518           </listitem>\r
519 \r
520           <listitem>\r
521             <para>Added in the extras dir. two new library file:\r
522             <filename>jsonrpc.inc</filename> and\r
523             <filename>jsonrpcs.inc</filename> containing new classes that\r
524             implement support for the json-rpc protocol (alpha quality\r
525             code)</para>\r
526           </listitem>\r
527 \r
528           <listitem>\r
529             <para>Added a new client method: <code>setKey($key,\r
530             $keypass)</code> to be used in HTTPS connections</para>\r
531           </listitem>\r
532 \r
533           <listitem>\r
534             <para>Added a new file containing some benchmarks in the testsuite\r
535             directory</para>\r
536           </listitem>\r
537         </itemizedlist></para>\r
538     </sect1>\r
539 \r
540     <sect1>\r
541       <title>2.0 Release candidate 1</title>\r
542 \r
543       <itemizedlist>\r
544         <listitem>\r
545           <para>Support for HTTP proxies (new method:\r
546           <code>xmlrpc_client::setProxy()</code>)</para>\r
547         </listitem>\r
548 \r
549         <listitem>\r
550           <para>Support HTTP compression of both requests and responses.\r
551           Clients can specify what kind of compression they accept for\r
552           responses between deflate/gzip/any, and whether to compress the\r
553           requests. Servers by default compress responses to clients that\r
554           explicitly declare support for compression (new methods:\r
555           <code>xmlrpc_client::setAcceptedCompression()</code>,\r
556           <code>xmlrpc_client::setRequestCompression()</code>). Note that the\r
557           ZLIB php extension needs to be enabled in PHP to support\r
558           compression.</para>\r
559         </listitem>\r
560 \r
561         <listitem>\r
562           <para>Implement HTTP 1.1 connections, but only if CURL is enabled\r
563           (added an extra parameter to\r
564           <code>xmlrpc_client::xmlrpc_client</code> to set the desired HTTP\r
565           protocol at creation time and a new supported value for the last\r
566           parameter of <code>xmlrpc_client::send</code>, which now can be\r
567           safely omitted if it has been specified at creation time)</para>\r
568 \r
569           <para>With PHP versions greater than 4.3.8 keep-alives are enabled\r
570           by default for HTTP 1.1 connections. This should yield faster\r
571           execution times when making multiple calls in sequence to the same\r
572           xml-rpc server from a single client.</para>\r
573         </listitem>\r
574 \r
575         <listitem>\r
576           <para>Introduce support for cookies. Cookies to be sent to the\r
577           server with a request can be set using\r
578           <code>xmlrpc_client::setCookie()</code>, while cookies received from\r
579           the server are found in <code>xmlrpcresp::cookies()</code>. It is\r
580           left to the user to check for validity of received cookies and\r
581           decide whether they apply to successive calls or not.</para>\r
582         </listitem>\r
583 \r
584         <listitem>\r
585           <para>Better support for detecting different character set encodings\r
586           of xml-rpc requests and responses: both client and server objects\r
587           will correctly detect the charset encoding of received xml, and use\r
588           an appropriate xml parser.</para>\r
589 \r
590           <para>Supported encodings are US-ASCII, UTF-8 and ISO-8859-1.</para>\r
591         </listitem>\r
592 \r
593         <listitem>\r
594           <para>Added one new xmlrpcmsg constructor syntax, allowing usage of\r
595           a single string with the complete URL of the target server</para>\r
596         </listitem>\r
597 \r
598         <listitem>\r
599           <para>Convert xml-rpc boolean values into native php values instead\r
600           of 0 and 1</para>\r
601         </listitem>\r
602 \r
603         <listitem>\r
604           <para>Force the <code>php_xmlrpc_encode</code> function to properly\r
605           encode numerically indexed php arrays into xml-rpc arrays\r
606           (numerically indexed php arrays always start with a key of 0 and\r
607           increment keys by values of 1)</para>\r
608         </listitem>\r
609 \r
610         <listitem>\r
611           <para>Prevent the <code>php_xmlrpc_encode</code> function from\r
612           further re-encoding any objects of class <code>xmlrpcval</code> that\r
613           are passed to it. This allows to call the function with arguments\r
614           consisting of mixed php values / xmlrpcval objects.</para>\r
615         </listitem>\r
616 \r
617         <listitem>\r
618           <para>Allow a server to NOT respond to system.* method calls\r
619           (setting the <code>$server-&gt;allow_system_funcs</code>\r
620           property).</para>\r
621         </listitem>\r
622 \r
623         <listitem>\r
624           <para>Implement a new xmlrpcval method to determine if a value of\r
625           type struct has a member of a given name without having to loop\r
626           trough all members: <code>xmlrpcval::structMemExists()</code></para>\r
627         </listitem>\r
628 \r
629         <listitem>\r
630           <para>Expand methods <code>xmlrpcval::addArray</code>,\r
631           <code>addScalar</code> and <code>addStruct</code> allowing extra php\r
632           values to be added to xmlrpcval objects already formed.</para>\r
633         </listitem>\r
634 \r
635         <listitem>\r
636           <para>Let the <code>xmlrpc_client::send</code> method accept an XML\r
637           string for sending instead of an xmlrpcmsg object, to facilitate\r
638           debugging and integration with the php native xmlrpc\r
639           extension</para>\r
640         </listitem>\r
641 \r
642         <listitem>\r
643           <para>Extend the <code>php_xmlrpc_encode</code> and\r
644           <code>php_xmlrpc_decode</code> functions to allow serialization and\r
645           rebuilding of PHP objects. To successfully rebuild a serialized\r
646           object, the object class must be defined in the deserializing end of\r
647           the transfer. Note that object members of type resource will be\r
648           deserialized as NULL values.</para>\r
649 \r
650           <para>Note that his has been implemented adding a "php_class"\r
651           attribute to xml representation of xmlrpcval of STRUCT type, which,\r
652           strictly speaking, breaks the xml-rpc spec. Other xmlrpc\r
653           implementations are supposed to ignore such an attribute (unless\r
654           they implement a brain-dead custom xml parser...), so it should be\r
655           safe enabling it in heterogeneous environments. The activation of\r
656           this feature is done by usage of an option passed as second\r
657           parameter to both <code>php_xmlrpc_encode</code> and\r
658           <code>php_xmlrpc_decode</code>.</para>\r
659         </listitem>\r
660 \r
661         <listitem>\r
662           <para>Extend the <code>php_xmlrpc_encode</code> function to allow\r
663           automatic serialization of iso8601-conforming php strings as\r
664           datetime.iso8601 xmlrpcvals, by usage of an optional\r
665           parameter</para>\r
666         </listitem>\r
667 \r
668         <listitem>\r
669           <para>Added an automatic stub code generator for converting xmlrpc\r
670           methods to php functions and vice-versa.</para>\r
671 \r
672           <para>This is done via two new functions:\r
673           <code>wrap_php_function</code> and <code>wrap_xmlrpc_method</code>,\r
674           and has many caveats, with php being a typeless language and\r
675           all...</para>\r
676 \r
677           <para>With PHP versions lesser than 5.0.3 wrapping of php functions\r
678           into xmlrpc methods is not supported yet.</para>\r
679         </listitem>\r
680 \r
681         <listitem>\r
682           <para>Allow object methods to be used in server dispatch map</para>\r
683         </listitem>\r
684 \r
685         <listitem>\r
686           <para>Added a complete debugger solution, in the\r
687           <filename>debugger</filename> folder</para>\r
688         </listitem>\r
689 \r
690         <listitem>\r
691           <para>Added configurable server-side debug messages, controlled by\r
692           the new method <code>xmlrpc_server::SetDebug()</code>. At level 0,\r
693           no debug messages are sent to the client; level 1 is the same as the\r
694           old behaviour; at level 2 a lot more info is echoed back to the\r
695           client, regarding the received call; at level 3 all warnings raised\r
696           during server processing are trapped (this prevents breaking the xml\r
697           to be echoed back to the client) and added to the debug info sent\r
698           back to the client</para>\r
699         </listitem>\r
700 \r
701         <listitem>\r
702           <para>New XML parsing code, yields smaller memory footprint and\r
703           faster execution times, not to mention complete elimination of the\r
704           dreaded <filename>eval()</filename> construct, so prone to code\r
705           injection exploits</para>\r
706         </listitem>\r
707 \r
708         <listitem>\r
709           <para>Rewritten most of the error messages, making text more\r
710           explicative</para>\r
711         </listitem>\r
712       </itemizedlist>\r
713     </sect1>\r
714   </chapter>\r
715 \r
716   <chapter id="requirements">\r
717     <title>System Requirements</title>\r
718 \r
719     <para>The library has been designed with goals of scalability and backward\r
720     compatibility. As such, it supports a wide range of PHP installs. Note\r
721     that not all features of the lib are available in every\r
722     configuration.</para>\r
723 \r
724     <para>The <emphasis>minimum supported</emphasis> PHP version is\r
725     4.2.</para>\r
726 \r
727     <para>A compatibility layer is provided that allows the code to run on PHP\r
728     4.0.5 and 4.1. Note that if you are stuck on those platforms, we suggest\r
729     you upgrade as soon as possible.</para>\r
730 \r
731     <para>Automatic generation of xml-rpc methods from php functions is only\r
732     supported with PHP version 5.0.3 and later (note that the lib will\r
733     generate some warnings with PHP 5 in strict error reporting mode).</para>\r
734 \r
735     <para>If you wish to use SSL or HTTP 1.1 to communicate with remote\r
736     servers, you need the "curl" extension compiled into your PHP\r
737     installation. This is available in PHP 4.0.2 and greater, although 4.0.6\r
738     has a bug preventing SSL working, and versions prior to 4.3.8 do not\r
739     support streamlining multiple requests using HTTP Keep-Alive.</para>\r
740 \r
741     <para>The "xmlrpc" native extension is not required to be compiled into\r
742     your PHP installation, but if it is, there will be no interference with\r
743     the operation of this library.</para>\r
744   </chapter>\r
745 \r
746   <chapter id="manifest">\r
747     <title>Files in the distribution</title>\r
748 \r
749     <glosslist>\r
750       <glossentry>\r
751         <glossterm>lib/xmlrpc.inc</glossterm>\r
752 \r
753         <glossdef>\r
754           <para>the XML-RPC classes. <function>include()</function> this in\r
755           your PHP files to use the classes.</para>\r
756         </glossdef>\r
757       </glossentry>\r
758 \r
759       <glossentry>\r
760         <glossterm>lib/xmlrpcs.inc</glossterm>\r
761 \r
762         <glossdef>\r
763           <para>the XML-RPC server class. <function>include()</function> this\r
764           in addition to xmlrpc.inc to get server functionality</para>\r
765         </glossdef>\r
766       </glossentry>\r
767 \r
768       <glossentry>\r
769         <glossterm>lib/xmlrpc_wrappers.inc</glossterm>\r
770 \r
771         <glossdef>\r
772           <para>helper functions to "automagically" convert plain php\r
773           functions to xmlrpc services and vice versa</para>\r
774         </glossdef>\r
775       </glossentry>\r
776 \r
777       <glossentry>\r
778         <glossterm>lib/compat/array_key_exists.php, lib/compat/is_a.php,\r
779         lib/compat/is_scalar.php, lib/compat/var_export.php,\r
780         lib/compat/vesrions_compare.php</glossterm>\r
781 \r
782         <glossdef>\r
783           <para>compatibility functions: these files implement the\r
784           compatibility layer needed to run the library with PHP versions 4.0\r
785           and 4.1</para>\r
786         </glossdef>\r
787       </glossentry>\r
788 \r
789       <glossentry>\r
790         <glossterm>demo/server/proxy.php</glossterm>\r
791 \r
792         <glossdef>\r
793           <para>a sample server implementing xmlrpc proxy\r
794           functionality.</para>\r
795         </glossdef>\r
796       </glossentry>\r
797 \r
798       <glossentry>\r
799         <glossterm>demo/server/server.php</glossterm>\r
800 \r
801         <glossdef>\r
802           <para>a sample server hosting various demo functions, as well as a\r
803           full suite of functions used for interoperability testing. It is\r
804           used by testsuite.php (see below) for unit testing the library, and\r
805           is not to be copied literally into your production servers</para>\r
806         </glossdef>\r
807       </glossentry>\r
808 \r
809       <glossentry>\r
810         <glossterm>demo/client/client.php, demo/client/agesort.php,\r
811         demo/client/which.php</glossterm>\r
812 \r
813         <glossdef>\r
814           <para>client code to exercise some of the functions in server.php,\r
815           including the <function>interopEchoTests.whichToolkit</function>\r
816           method.</para>\r
817         </glossdef>\r
818       </glossentry>\r
819 \r
820       <glossentry>\r
821         <glossterm>demo/client/wrap.php</glossterm>\r
822 \r
823         <glossdef>\r
824           <para>client code to illustrate 'wrapping' of remote methods into\r
825           php functions.</para>\r
826         </glossdef>\r
827       </glossentry>\r
828 \r
829       <glossentry>\r
830         <glossterm>demo/client/introspect.php</glossterm>\r
831 \r
832         <glossdef>\r
833           <para>client code to illustrate usage of introspection capabilities\r
834           offered by server.php.</para>\r
835         </glossdef>\r
836       </glossentry>\r
837 \r
838       <glossentry>\r
839         <glossterm>demo/client/mail.php</glossterm>\r
840 \r
841         <glossdef>\r
842           <para>client code to illustrate usage of an xmlrpc-to-email gateway\r
843           using Dave Winer's XML-RPC server at userland.com.</para>\r
844         </glossdef>\r
845       </glossentry>\r
846 \r
847       <glossentry>\r
848         <glossterm>demo/client/zopetest.php</glossterm>\r
849 \r
850         <glossdef>\r
851           <para>example client code that queries an xmlrpc server built in\r
852           Zope.</para>\r
853         </glossdef>\r
854       </glossentry>\r
855 \r
856       <glossentry>\r
857         <glossterm>demo/vardemo.php</glossterm>\r
858 \r
859         <glossdef>\r
860           <para>examples of how to construct xmlrpcval types</para>\r
861         </glossdef>\r
862       </glossentry>\r
863 \r
864       <glossentry>\r
865         <glossterm>demo/demo1.txt, demo/demo2.txt, demo/demo3.txt</glossterm>\r
866 \r
867         <glossdef>\r
868           <para>XML-RPC responses captured in a file for testing purposes (you\r
869           can use these to test the\r
870           <function>xmlrpcmsg-&gt;parseResponse()</function> method).</para>\r
871         </glossdef>\r
872       </glossentry>\r
873 \r
874       <glossentry>\r
875         <glossterm>demo/server/discuss.php,\r
876         demo/client/comment.php</glossterm>\r
877 \r
878         <glossdef>\r
879           <para>Software used in the PHP chapter of <xref\r
880           linkend="jellyfish" /> to provide a comment server and allow the\r
881           attachment of comments to stories from Meerkat's data store.</para>\r
882         </glossdef>\r
883       </glossentry>\r
884 \r
885       <glossentry>\r
886         <glossterm>test/testsuite.php, test/parse_args.php</glossterm>\r
887 \r
888         <glossdef>\r
889           <para>A unit test suite for this software package. If you do\r
890           development on this software, please consider submitting tests for\r
891           this suite.</para>\r
892         </glossdef>\r
893       </glossentry>\r
894 \r
895       <glossentry>\r
896         <glossterm>test/benchmark.php</glossterm>\r
897 \r
898         <glossdef>\r
899           <para>A (very limited) benchmarking suite for this software package.\r
900           If you do development on this software, please consider submitting\r
901           benchmarks for this suite.</para>\r
902         </glossdef>\r
903       </glossentry>\r
904 \r
905       <glossentry>\r
906         <glossterm>test/phpunit.php, test/PHPUnit/*.php</glossterm>\r
907 \r
908         <glossdef>\r
909           <para>An (incomplete) version PEAR's unit test framework for PHP.\r
910           The complete package can be found at <ulink\r
911           url="http://pear.php.net/package/PHPUnit">http://pear.php.net/package/PHPUnit</ulink></para>\r
912         </glossdef>\r
913       </glossentry>\r
914 \r
915       <glossentry>\r
916         <glossterm>test/verify_compat.php</glossterm>\r
917 \r
918         <glossdef>\r
919           <para>Script designed to help the user to verify the level of\r
920           compatibility of the library with the current php install</para>\r
921         </glossdef>\r
922       </glossentry>\r
923 \r
924       <glossentry>\r
925         <glossterm>extras/test.pl, extras/test.py</glossterm>\r
926 \r
927         <glossdef>\r
928           <para>Perl and Python programs to exercise server.php to test that\r
929           some of the methods work.</para>\r
930         </glossdef>\r
931       </glossentry>\r
932 \r
933       <glossentry>\r
934         <glossterm>extras/workspace.testPhpServer.fttb</glossterm>\r
935 \r
936         <glossdef>\r
937           <para>Frontier scripts to exercise the demo server. Thanks to Dave\r
938           Winer for permission to include these. See <ulink\r
939           url="http://www.xmlrpc.com/discuss/msgReader$853">Dave's\r
940           announcement of these.</ulink></para>\r
941         </glossdef>\r
942       </glossentry>\r
943 \r
944       <glossentry>\r
945         <glossterm>extras/rsakey.pem</glossterm>\r
946 \r
947         <glossdef>\r
948           <para>A test certificate key for the SSL support, which can be used\r
949           to generate dummy certificates. It has the passphrase "test."</para>\r
950         </glossdef>\r
951       </glossentry>\r
952     </glosslist>\r
953   </chapter>\r
954 \r
955   <chapter id="bugs">\r
956     <title>Known bugs and limitations</title>\r
957 \r
958     <para>This started out as a bare framework. Many "nice" bits haven't been\r
959     put in yet. Specifically, very little type validation or coercion has been\r
960     put in. PHP being a loosely-typed language, this is going to have to be\r
961     done explicitly (in other words: you can call a lot of library functions\r
962     passing them arguments of the wrong type and receive an error message only\r
963     much further down the code, where it will be difficult to\r
964     understand).</para>\r
965 \r
966     <para>dateTime.iso8601 is supported opaquely. It can't be done natively as\r
967     the XML-RPC specification explicitly forbids passing of timezone\r
968     specifiers in ISO8601 format dates. You can, however, use the <xref\r
969     linkend="iso8601encode" /> and <xref linkend="iso8601decode" /> functions\r
970     to do the encoding and decoding for you.</para>\r
971 \r
972     <para>Very little HTTP response checking is performed (e.g. HTTP redirects\r
973     are not followed and the Content-Length HTTP header, mandated by the\r
974     xml-rpc spec, is not validated); cookie support still involves quite a bit\r
975     of coding on the part of the user.</para>\r
976 \r
977     <para>If a specific character set encoding other than US-ASCII, ISO-8859-1\r
978     or UTF-8 is received in the HTTP header or XML prologue of xml-rpc request\r
979     or response messages then it will be ignored for the moment, and the\r
980     content will be parsed as if it had been encoded using the charset defined\r
981     by <xref linkend="xmlrpc-defencoding" /></para>\r
982 \r
983     <para>Very large floating point numbers are serialized using exponential\r
984     notation, even though the spec explicitly forbids this behaviour. This\r
985     will not be a problem if this library is used on both ends of the\r
986     communication, but might cause problems with other implementations.</para>\r
987 \r
988     <para>Support for receiving from servers version 1 cookies (i.e.\r
989     conforming to RFC 2965) is quite incomplete, and might cause unforeseen\r
990     errors.</para>\r
991 \r
992     <para>A PHP warning will be generated in many places when using\r
993     <filename>xmlrpc.inc</filename> and <filename>xmlrpcs.inc</filename> with\r
994     PHP 5 in strict error reporting mode. The simplest workaround to this\r
995     problem is to lower the <parameter>error_reporting</parameter> level in\r
996     php.ini.</para>\r
997   </chapter>\r
998 \r
999   <chapter id="support">\r
1000     <title>Support</title>\r
1001 \r
1002     <sect1>\r
1003       <title>Online Support</title>\r
1004 \r
1005       <para>XML-RPC for PHP is offered "as-is" without any warranty or\r
1006       commitment to support. However, informal advice and help is available\r
1007       via the XML-RPC for PHP website and mailing list and from\r
1008       XML-RPC.com.</para>\r
1009 \r
1010       <itemizedlist>\r
1011         <listitem>\r
1012           <para>The <emphasis>XML-RPC for PHP</emphasis> development is hosted\r
1013           on <ulink\r
1014           url="http://phpxmlrpc.sourceforge.net">phpxmlrpc.sourceforge.net</ulink>.\r
1015           Bugs, feature requests and patches can be posted to the <ulink\r
1016           url="http://sourceforge.net/projects/phpxmlrpc">project's\r
1017           website</ulink>.</para>\r
1018         </listitem>\r
1019 \r
1020         <listitem>\r
1021           <para>The <emphasis>PHP XML-RPC interest mailing list</emphasis> is\r
1022           run by the author. More details <ulink\r
1023           url="http://lists.gnomehack.com/mailman/listinfo/phpxmlrpc">can be\r
1024           found here</ulink>.</para>\r
1025         </listitem>\r
1026 \r
1027         <listitem>\r
1028           <para>For more general XML-RPC questions, there is a Yahoo! Groups\r
1029           <ulink url="http://groups.yahoo.com/group/xml-rpc/">XML-RPC mailing\r
1030           list</ulink>.</para>\r
1031         </listitem>\r
1032 \r
1033         <listitem>\r
1034           <para>The <ulink\r
1035           url="http://www.xmlrpc.com/discuss">XML-RPC.com</ulink> discussion\r
1036           group is a useful place to get help with using XML-RPC. This group\r
1037           is also gatewayed into the Yahoo! Groups mailing list.</para>\r
1038         </listitem>\r
1039       </itemizedlist>\r
1040     </sect1>\r
1041 \r
1042     <sect1 id="jellyfish" xreflabel="The Jellyfish Book">\r
1043       <title>The Jellyfish Book</title>\r
1044 \r
1045       <para><graphic align="right" depth="190" fileref="progxmlrpc.s.gif"\r
1046       format="GIF" width="145" />Together with Simon St.Laurent and Joe\r
1047       Johnston, Edd Dumbill wrote a book on XML-RPC for O'Reilly and\r
1048       Associates on XML-RPC. It features a rather fetching jellyfish on the\r
1049       cover.</para>\r
1050 \r
1051       <para>Complete details of the book are <ulink\r
1052       url="http://www.oreilly.com/catalog/progxmlrpc/">available from\r
1053       O'Reilly's web site.</ulink></para>\r
1054 \r
1055       <para>Edd is responsible for the chapter on PHP, which includes a worked\r
1056       example of creating a forum server, and hooking it up the O'Reilly's\r
1057       <ulink url="http://meerkat.oreillynet.com/">Meerkat</ulink> service in\r
1058       order to allow commenting on news stories from around the Web.</para>\r
1059 \r
1060       <para>If you've benefited from the effort that has been put into writing\r
1061       this software, then please consider buying the book!</para>\r
1062     </sect1>\r
1063   </chapter>\r
1064 \r
1065   <chapter id="apidocs">\r
1066     <title>Class documentation</title>\r
1067 \r
1068     <sect1 id="xmlrpcval" xreflabel="xmlrpcval">\r
1069       <title>xmlrpcval</title>\r
1070 \r
1071       <para>This is where a lot of the hard work gets done. This class enables\r
1072       the creation and encapsulation of values for XML-RPC.</para>\r
1073 \r
1074       <para>Ensure you've read the XML-RPC spec at <ulink\r
1075       url="http://www.xmlrpc.com/stories/storyReader$7">http://www.xmlrpc.com/stories/storyReader$7</ulink>\r
1076       before reading on as it will make things clearer.</para>\r
1077 \r
1078       <para>The <classname>xmlrpcval</classname> class can store arbitrarily\r
1079       complicated values using the following types: <literal>i4 int boolean\r
1080       string double dateTime.iso8601 base64 array struct</literal>. You should\r
1081       refer to the <ulink url="http://www.xmlrpc.com/spec">spec</ulink> for\r
1082       more information on what each of these types mean.</para>\r
1083 \r
1084       <sect2>\r
1085         <title>Notes on types</title>\r
1086 \r
1087         <sect3>\r
1088           <title>int</title>\r
1089 \r
1090           <para>The type <classname>i4</classname> is accepted as a synonym\r
1091           for <classname>int</classname> when creating xmlrpcval objects. The\r
1092           xml parsing code will always convert <classname>i4</classname> to\r
1093           <classname>int</classname>: <classname>int</classname> is regarded\r
1094           by this implementation as the canonical name for this type.</para>\r
1095         </sect3>\r
1096 \r
1097         <sect3>\r
1098           <title>base64</title>\r
1099 \r
1100           <para>Base 64 encoding is performed transparently to the caller when\r
1101           using this type. Decoding is also transparent. Therefore you ought\r
1102           to consider it as a "binary" data type, for use when you want to\r
1103           pass data that is not 7-bit clean.</para>\r
1104         </sect3>\r
1105 \r
1106         <sect3>\r
1107           <title>boolean</title>\r
1108 \r
1109           <para>The php values <literal>true</literal> and\r
1110           <literal>1</literal> map to <literal>true</literal>. All other\r
1111           values (including the empty string) are converted to\r
1112           <literal>false</literal>.</para>\r
1113         </sect3>\r
1114 \r
1115         <sect3>\r
1116           <title>string</title>\r
1117 \r
1118           <para>Characters &lt;, &gt;, ', ", &amp;, are encoded using their\r
1119           entity reference as &amp;lt; &amp;gt; &amp;apos; &amp;quot; and\r
1120           &amp;amp; All other characters outside of the ASCII range are\r
1121           encoded using their character reference representation (e.g.\r
1122           &amp;#200 for é). The XML-RPC spec recommends only encoding\r
1123           <literal>&lt; &amp;</literal> but this implementation goes further,\r
1124           for reasons explained by <ulink\r
1125           url="http://www.w3.org/TR/REC-xml#syntax">the XML 1.0\r
1126           recommendation</ulink>. In particular, using character reference\r
1127           representation has the advantage of producing XML that is valid\r
1128           independently of the charset encoding assumed.</para>\r
1129         </sect3>\r
1130       </sect2>\r
1131 \r
1132       <sect2 id="xmlrpcval-creation" xreflabel="xmlrpcval constructors">\r
1133         <title>Creation</title>\r
1134 \r
1135         <para>The constructor is the normal way to create an\r
1136         <classname>xmlrpcval</classname>. The constructor can take these\r
1137         forms:</para>\r
1138 \r
1139         <funcsynopsis>\r
1140           <funcprototype>\r
1141             <funcdef><type>xmlrpcval</type>new\r
1142             <function>xmlrpcval</function></funcdef>\r
1143 \r
1144             <void />\r
1145           </funcprototype>\r
1146 \r
1147           <funcprototype>\r
1148             <funcdef><type>xmlrpcval</type>new\r
1149             <function>xmlrpcval</function></funcdef>\r
1150 \r
1151             <paramdef><type>string</type><parameter>$stringVal</parameter></paramdef>\r
1152           </funcprototype>\r
1153 \r
1154           <funcprototype>\r
1155             <funcdef><type>xmlrpcval</type>new\r
1156             <function>xmlrpcval</function></funcdef>\r
1157 \r
1158             <paramdef><type>mixed</type><parameter>$scalarVal</parameter></paramdef>\r
1159 \r
1160             <paramdef><type>string</type><parameter>$scalartyp</parameter></paramdef>\r
1161           </funcprototype>\r
1162 \r
1163           <funcprototype>\r
1164             <funcdef><type>xmlrpcval</type>new\r
1165             <function>xmlrpcval</function></funcdef>\r
1166 \r
1167             <paramdef><type>array</type><parameter>$arrayVal</parameter></paramdef>\r
1168 \r
1169             <paramdef><type>string</type><parameter>$arraytyp</parameter></paramdef>\r
1170           </funcprototype>\r
1171         </funcsynopsis>\r
1172 \r
1173         <para>The first constructor creates an empty value, which must be\r
1174         altered using the methods <function>addScalar</function>,\r
1175         <function>addArray</function> or <function>addStruct</function> before\r
1176         it can be used.</para>\r
1177 \r
1178         <para>The second constructor creates a simple string value.</para>\r
1179 \r
1180         <para>The third constructor is used to create a scalar value. The\r
1181         second parameter must be a name of an XML-RPC type. Valid types are:\r
1182         "<literal>int</literal>", "<literal>boolean</literal>",\r
1183         "<literal>string</literal>", "<literal>double</literal>",\r
1184         "<literal>dateTime.iso8601</literal>",\r
1185         "<literal>base64</literal>".</para>\r
1186 \r
1187         <para>Examples:</para>\r
1188 \r
1189         <programlisting language="php">\r
1190 $myInt = new xmlrpcvalue(1267, "int");\r
1191 $myString = new xmlrpcvalue("Hello, World!", "string");\r
1192 $myBool = new xmlrpcvalue(1, "boolean");\r
1193 $myString2 = new xmlrpcvalue(1.24, "string"); // note: this will serialize a php float value as xmlrpc string\r
1194 </programlisting>\r
1195 \r
1196         <para>The fourth constructor form can be used to compose complex\r
1197         XML-RPC values. The first argument is either a simple array in the\r
1198         case of an XML-RPC <classname>array</classname> or an associative\r
1199         array in the case of a <classname>struct</classname>. The elements of\r
1200         the array <emphasis>must be <classname>xmlrpcval</classname> objects\r
1201         themselves</emphasis>.</para>\r
1202 \r
1203         <para>The second parameter must be either "<literal>array</literal>"\r
1204         or "<literal>struct</literal>".</para>\r
1205 \r
1206         <para>Examples:</para>\r
1207 \r
1208         <programlisting language="php">\r
1209 $myArray = new xmlrpcval(\r
1210   array(\r
1211     new xmlrpcval("Tom"),\r
1212     new xmlrpcval("Dick"),\r
1213     new xmlrpcval("Harry")\r
1214   ),\r
1215   "array");\r
1216 \r
1217 // recursive struct\r
1218 $myStruct = new xmlrpcval(\r
1219   array(\r
1220     "name" =&gt; new xmlrpcval("Tom", "string"),\r
1221     "age" =&gt; new xmlrpcval(34, "int"),\r
1222     "address" =&gt; new xmlrpcval(\r
1223       array(\r
1224         "street" =&gt; new xmlrpcval("Fifht Ave", "string"),\r
1225         "city" =&gt; new xmlrpcval("NY", "string")\r
1226       ), \r
1227       "struct")\r
1228   ), \r
1229   "struct");\r
1230 </programlisting>\r
1231 \r
1232         <para>See the file <literal>vardemo.php</literal> in this distribution\r
1233         for more examples.</para>\r
1234       </sect2>\r
1235 \r
1236       <sect2 id="xmlrpcval-methods" xreflabel="xmlrpcval methods">\r
1237         <title>Methods</title>\r
1238 \r
1239         <sect3>\r
1240           <title>addScalar</title>\r
1241 \r
1242           <funcsynopsis>\r
1243             <funcprototype>\r
1244               <funcdef><type>int</type><function>addScalar</function></funcdef>\r
1245 \r
1246               <paramdef><type>string</type><parameter>$stringVal</parameter></paramdef>\r
1247             </funcprototype>\r
1248 \r
1249             <funcprototype>\r
1250               <funcdef><type>int</type><function>addScalar</function></funcdef>\r
1251 \r
1252               <paramdef><type>mixed</type><parameter>$scalarVal</parameter></paramdef>\r
1253 \r
1254               <paramdef><type>string</type><parameter>$scalartyp</parameter></paramdef>\r
1255             </funcprototype>\r
1256           </funcsynopsis>\r
1257 \r
1258           <para>If <parameter>$val</parameter> is an empty\r
1259           <classname>xmlrpcval</classname> this method makes it a scalar\r
1260           value, and sets that value.</para>\r
1261 \r
1262           <para>If <parameter>$val</parameter> is already a scalar value, then\r
1263           no more scalars can be added and <literal>0</literal> is\r
1264           returned.</para>\r
1265 \r
1266           <para>If <parameter>$val</parameter> is an xmlrpcval of type array,\r
1267           the php value <parameter>$scalarval</parameter> is added as its last\r
1268           element.</para>\r
1269 \r
1270           <para>If all went OK, <literal>1</literal> is returned, otherwise\r
1271           <literal>0</literal>.</para>\r
1272         </sect3>\r
1273 \r
1274         <sect3>\r
1275           <title>addArray</title>\r
1276 \r
1277           <funcsynopsis>\r
1278             <funcprototype>\r
1279               <funcdef><type>int</type><function>addArray</function></funcdef>\r
1280 \r
1281               <paramdef><type>array</type><parameter>$arrayVal</parameter></paramdef>\r
1282             </funcprototype>\r
1283           </funcsynopsis>\r
1284 \r
1285           <para>The argument is a simple (numerically indexed) array. The\r
1286           elements of the array <emphasis>must be\r
1287           <classname>xmlrpcval</classname> objects\r
1288           themselves</emphasis>.</para>\r
1289 \r
1290           <para>Turns an empty <classname>xmlrpcval</classname> into an\r
1291           <classname>array</classname> with contents as specified by\r
1292           <parameter>$arrayVal</parameter>.</para>\r
1293 \r
1294           <para>If <parameter>$val</parameter> is an xmlrpcval of type array,\r
1295           the elements of <parameter>$arrayVal</parameter> are appended to the\r
1296           existing ones.</para>\r
1297 \r
1298           <para>See the fourth constructor form for more information.</para>\r
1299 \r
1300           <para>If all went OK, <literal>1</literal> is returned, otherwise\r
1301           <literal>0</literal>.</para>\r
1302         </sect3>\r
1303 \r
1304         <sect3>\r
1305           <title>addStruct</title>\r
1306 \r
1307           <funcsynopsis>\r
1308             <funcprototype>\r
1309               <funcdef><type>int</type><function>addStruct</function></funcdef>\r
1310 \r
1311               <paramdef><type>array</type><parameter>$assocArrayVal</parameter></paramdef>\r
1312             </funcprototype>\r
1313           </funcsynopsis>\r
1314 \r
1315           <para>The argument is an associative array. The elements of the\r
1316           array <emphasis>must be <classname>xmlrpcval</classname> objects\r
1317           themselves</emphasis>.</para>\r
1318 \r
1319           <para>Turns an empty <classname>xmlrpcval</classname> into a\r
1320           <classname>struct</classname> with contents as specified by\r
1321           <parameter>$assocArrayVal</parameter>.</para>\r
1322 \r
1323           <para>If <parameter>$val</parameter> is an xmlrpcval of type struct,\r
1324           the elements of <parameter>$arrayVal</parameter> are merged with the\r
1325           existing ones.</para>\r
1326 \r
1327           <para>See the fourth constructor form for more information.</para>\r
1328 \r
1329           <para>If all went OK, <literal>1</literal> is returned, otherwise\r
1330           <literal>0</literal>.</para>\r
1331         </sect3>\r
1332 \r
1333         <sect3>\r
1334           <title>kindOf</title>\r
1335 \r
1336           <funcsynopsis>\r
1337             <funcprototype>\r
1338               <funcdef><type>string</type><function>kindOf</function></funcdef>\r
1339 \r
1340               <void />\r
1341             </funcprototype>\r
1342           </funcsynopsis>\r
1343 \r
1344           <para>Returns a string containing "struct", "array" or "scalar"\r
1345           describing the base type of the value. If it returns "undef" it\r
1346           means that the value hasn't been initialised.</para>\r
1347         </sect3>\r
1348 \r
1349         <sect3>\r
1350           <title>serialize</title>\r
1351 \r
1352           <funcsynopsis>\r
1353             <funcprototype>\r
1354               <funcdef><type>string</type><function>serialize</function></funcdef>\r
1355 \r
1356               <void />\r
1357             </funcprototype>\r
1358           </funcsynopsis>\r
1359 \r
1360           <para>Returns a string containing the XML-RPC representation of this\r
1361           value.</para>\r
1362         </sect3>\r
1363 \r
1364         <sect3>\r
1365           <title>scalarVal</title>\r
1366 \r
1367           <funcsynopsis>\r
1368             <funcprototype>\r
1369               <funcdef><type>mixed</type><function>scalarVal</function></funcdef>\r
1370 \r
1371               <void />\r
1372             </funcprototype>\r
1373           </funcsynopsis>\r
1374 \r
1375           <para>If <function>$val-&gt;kindOf() == "scalar"</function>, this\r
1376           method returns the actual PHP-language value of the scalar (base 64\r
1377           decoding is automatically handled here).</para>\r
1378         </sect3>\r
1379 \r
1380         <sect3>\r
1381           <title>scalarTyp</title>\r
1382 \r
1383           <funcsynopsis>\r
1384             <funcprototype>\r
1385               <funcdef><type>string</type><function>scalarTyp</function></funcdef>\r
1386 \r
1387               <void />\r
1388             </funcprototype>\r
1389           </funcsynopsis>\r
1390 \r
1391           <para>If <function>$val-&gt;kindOf() == "scalar"</function>, this\r
1392           method returns a string denoting the type of the scalar. As\r
1393           mentioned before, <literal>i4</literal> is always coerced to\r
1394           <literal>int</literal>.</para>\r
1395         </sect3>\r
1396 \r
1397         <sect3>\r
1398           <title>arrayMem</title>\r
1399 \r
1400           <funcsynopsis>\r
1401             <funcprototype>\r
1402               <funcdef><type>xmlrpcval</type><function>arrayMem</function></funcdef>\r
1403 \r
1404               <paramdef><type>int</type><parameter>$n</parameter></paramdef>\r
1405             </funcprototype>\r
1406           </funcsynopsis>\r
1407 \r
1408           <para>If <function>$val-&gt;kindOf() == "array"</function>, returns\r
1409           the <parameter>$n</parameter>th element in the array represented by\r
1410           the value <parameter>$val</parameter>. The value returned is an\r
1411           <classname>xmlrpcval</classname> object.</para>\r
1412 \r
1413           <para><programlisting language="php">\r
1414 // iterating over values of an array object\r
1415 for ($i = 0; $i &lt; $val-&gt;arraySize(); $i++)\r
1416 {\r
1417   $v = $val-&gt;arrayMem($i);\r
1418   echo "Element $i of the array is of type ".$v-&gt;kindOf();\r
1419 }\r
1420 </programlisting></para>\r
1421         </sect3>\r
1422 \r
1423         <sect3>\r
1424           <title>arraySize</title>\r
1425 \r
1426           <funcsynopsis>\r
1427             <funcprototype>\r
1428               <funcdef><type>int</type><function>arraySize</function></funcdef>\r
1429 \r
1430               <void />\r
1431             </funcprototype>\r
1432           </funcsynopsis>\r
1433 \r
1434           <para>If <parameter>$val</parameter> is an\r
1435           <classname>array</classname>, returns the number of elements in that\r
1436           array.</para>\r
1437         </sect3>\r
1438 \r
1439         <sect3>\r
1440           <title>structMem</title>\r
1441 \r
1442           <funcsynopsis>\r
1443             <funcprototype>\r
1444               <funcdef><type>xmlrpcval</type><function>structMem</function></funcdef>\r
1445 \r
1446               <paramdef><type>string</type><parameter>$memberName</parameter></paramdef>\r
1447             </funcprototype>\r
1448           </funcsynopsis>\r
1449 \r
1450           <para>If <function>$val-&gt;kindOf() == "struct"</function>, returns\r
1451           the element called <parameter>$memberName</parameter> from the\r
1452           struct represented by the value <parameter>$val</parameter>. The\r
1453           value returned is an <classname>xmlrpcval</classname> object.</para>\r
1454         </sect3>\r
1455 \r
1456         <sect3>\r
1457           <title>structEach</title>\r
1458 \r
1459           <funcsynopsis>\r
1460             <funcprototype>\r
1461               <funcdef><type>array</type><function>structEach</function></funcdef>\r
1462 \r
1463               <void />\r
1464             </funcprototype>\r
1465           </funcsynopsis>\r
1466 \r
1467           <para>Returns the next (key, value) pair from the struct, when\r
1468           <parameter>$val</parameter> is a struct.\r
1469           <parameter>$value</parameter> is an xmlrpcval itself. See also <xref\r
1470           linkend="structreset" />.</para>\r
1471 \r
1472           <para><programlisting language="php">\r
1473 // iterating over all values of a struct object\r
1474 $val-&gt;structreset();\r
1475 while (list($key, $v) = $val-&gt;structEach())\r
1476 {\r
1477   echo "Element $key of the struct is of type ".$v-&gt;kindOf();\r
1478 }\r
1479 </programlisting></para>\r
1480         </sect3>\r
1481 \r
1482         <sect3 id="structreset" xreflabel="structreset()">\r
1483           <title>structReset</title>\r
1484 \r
1485           <funcsynopsis>\r
1486             <funcprototype>\r
1487               <funcdef><type>void</type><function>structReset</function></funcdef>\r
1488 \r
1489               <void />\r
1490             </funcprototype>\r
1491           </funcsynopsis>\r
1492 \r
1493           <para>Resets the internal pointer for\r
1494           <function>structEach()</function> to the beginning of the struct,\r
1495           where <parameter>$val</parameter> is a struct.</para>\r
1496         </sect3>\r
1497 \r
1498         <sect3 id="structmemexists" xreflabel="structmemexists()">\r
1499           <title>structMemExists</title>\r
1500 \r
1501           <funcsynopsis>\r
1502             <funcprototype>\r
1503               <funcdef><type>bool</type><function>structMemExsists</function></funcdef>\r
1504 \r
1505               <paramdef><type>string</type><parameter>$memberName</parameter></paramdef>\r
1506             </funcprototype>\r
1507           </funcsynopsis>\r
1508 \r
1509           <para>Returns <constant>TRUE</constant> or\r
1510           <constant>FALSE</constant> depending on whether a member of the\r
1511           given name exists in the struct.</para>\r
1512         </sect3>\r
1513       </sect2>\r
1514     </sect1>\r
1515 \r
1516     <sect1 id="xmlrpcmsg" xreflabel="xmlrpcmsg">\r
1517       <title>xmlrpcmsg</title>\r
1518 \r
1519       <para>This class provides a representation for a request to an XML-RPC\r
1520       server. A client sends an <classname>xmlrpcmsg</classname> to a server,\r
1521       and receives back an <classname>xmlrpcresp</classname> (see <xref\r
1522       linkend="xmlrpc-client-send" />).</para>\r
1523 \r
1524       <sect2>\r
1525         <title>Creation</title>\r
1526 \r
1527         <para>The constructor takes the following forms:</para>\r
1528 \r
1529         <funcsynopsis>\r
1530           <funcprototype>\r
1531             <funcdef><type>xmlrpcmsg</type>new\r
1532             <function>xmlrpcmsg</function></funcdef>\r
1533 \r
1534             <paramdef><type>string</type><parameter>$methodName</parameter></paramdef>\r
1535 \r
1536             <paramdef><type>array</type><parameter>$parameterArray</parameter><initializer>null</initializer></paramdef>\r
1537           </funcprototype>\r
1538         </funcsynopsis>\r
1539 \r
1540         <para>Where <parameter>methodName</parameter> is a string indicating\r
1541         the name of the method you wish to invoke, and\r
1542         <parameter>parameterArray</parameter> is a simple php\r
1543         <classname>Array</classname> of <classname>xmlrpcval</classname>\r
1544         objects. Here's an example message to the <emphasis>US state\r
1545         name</emphasis> server:</para>\r
1546 \r
1547         <programlisting language="php">\r
1548 $msg = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23, "int")));\r
1549 </programlisting>\r
1550 \r
1551         <para>This example requests the name of state number 23. For more\r
1552         information on <classname>xmlrpcval</classname> objects, see <xref\r
1553         linkend="xmlrpcval" />.</para>\r
1554 \r
1555         <para>Note that the <parameter>parameterArray</parameter> parameter is\r
1556         optional and can be omitted for methods that take no input parameters\r
1557         or if you plan to add parameters one by one.</para>\r
1558       </sect2>\r
1559 \r
1560       <sect2>\r
1561         <title>Methods</title>\r
1562 \r
1563         <sect3>\r
1564           <title>addParam</title>\r
1565 \r
1566           <funcsynopsis>\r
1567             <funcprototype>\r
1568               <funcdef><type>bool</type><function>addParam</function></funcdef>\r
1569 \r
1570               <paramdef><type>xmlrpcval</type><parameter>$xmlrpcVal</parameter></paramdef>\r
1571             </funcprototype>\r
1572           </funcsynopsis>\r
1573 \r
1574           <para>Adds the <classname>xmlrpcval</classname>\r
1575           <parameter>xmlrpcVal</parameter> to the parameter list for this\r
1576           method call. Returns TRUE or FALSE on error.</para>\r
1577         </sect3>\r
1578 \r
1579         <sect3>\r
1580           <title>getNumParams</title>\r
1581 \r
1582           <funcsynopsis>\r
1583             <funcprototype>\r
1584               <funcdef><type>int</type><function>getNumParams</function></funcdef>\r
1585 \r
1586               <void />\r
1587             </funcprototype>\r
1588           </funcsynopsis>\r
1589 \r
1590           <para>Returns the number of parameters attached to this\r
1591           message.</para>\r
1592         </sect3>\r
1593 \r
1594         <sect3>\r
1595           <title>getParam</title>\r
1596 \r
1597           <funcsynopsis>\r
1598             <funcprototype>\r
1599               <funcdef><type>xmlrpcval</type><function>getParam</function></funcdef>\r
1600 \r
1601               <paramdef><type>int</type><parameter>$n</parameter></paramdef>\r
1602             </funcprototype>\r
1603           </funcsynopsis>\r
1604 \r
1605           <para>Gets the <parameter>n</parameter>th parameter in the message\r
1606           (with the index zero-based). Use this method in server\r
1607           implementations to retrieve the values sent by the client.</para>\r
1608         </sect3>\r
1609 \r
1610         <sect3>\r
1611           <title>method</title>\r
1612 \r
1613           <funcsynopsis>\r
1614             <funcprototype>\r
1615               <funcdef><type>string</type><function>method</function></funcdef>\r
1616 \r
1617               <void />\r
1618             </funcprototype>\r
1619 \r
1620             <funcprototype>\r
1621               <funcdef><type>string</type><function>method</function></funcdef>\r
1622 \r
1623               <paramdef><type>string</type><parameter>$methName</parameter></paramdef>\r
1624             </funcprototype>\r
1625           </funcsynopsis>\r
1626 \r
1627           <para>Gets or sets the method contained in the XML-RPC\r
1628           message.</para>\r
1629         </sect3>\r
1630 \r
1631         <sect3>\r
1632           <title>parseResponse</title>\r
1633 \r
1634           <funcsynopsis>\r
1635             <funcprototype>\r
1636               <funcdef><type>xmlrpcresp</type><function>parseResponse</function></funcdef>\r
1637 \r
1638               <paramdef><type>string</type><parameter>$xmlString</parameter></paramdef>\r
1639             </funcprototype>\r
1640           </funcsynopsis>\r
1641 \r
1642           <para>Given an incoming XML-RPC server response contained in the\r
1643           string <parameter>$xmlString</parameter>, this method constructs an\r
1644           <classname>xmlrpcresp</classname> response object and returns it,\r
1645           setting error codes as appropriate (see <xref\r
1646           linkend="xmlrpc-client-send" />).</para>\r
1647 \r
1648           <para>This method processes any HTTP/MIME headers it finds.</para>\r
1649         </sect3>\r
1650 \r
1651         <sect3>\r
1652           <title>parseResponseFile</title>\r
1653 \r
1654           <funcsynopsis>\r
1655             <funcprototype>\r
1656               <funcdef><type>xmlrpcresp</type><function>parseResponseFile</function></funcdef>\r
1657 \r
1658               <paramdef><type>file handle\r
1659               resource</type><parameter>$fileHandle</parameter></paramdef>\r
1660             </funcprototype>\r
1661           </funcsynopsis>\r
1662 \r
1663           <para>Given an incoming XML-RPC server response on the open file\r
1664           handle <parameter>fileHandle</parameter>, this method reads all the\r
1665           data it finds and passes it to\r
1666           <function>parseResponse.</function></para>\r
1667 \r
1668           <para>This method is useful to construct responses from pre-prepared\r
1669           files (see files <literal>demo1.txt, demo2.txt, demo3.txt</literal>\r
1670           in this distribution). It processes any HTTP headers it finds, and\r
1671           does not close the file handle.</para>\r
1672         </sect3>\r
1673 \r
1674         <sect3>\r
1675           <title>serialize</title>\r
1676 \r
1677           <funcsynopsis>\r
1678             <funcprototype>\r
1679               <funcdef><type>string\r
1680               </type><function>serialize</function></funcdef>\r
1681 \r
1682               <void />\r
1683             </funcprototype>\r
1684           </funcsynopsis>\r
1685 \r
1686           <para>Returns the an XML string representing the XML-RPC\r
1687           message.</para>\r
1688         </sect3>\r
1689       </sect2>\r
1690     </sect1>\r
1691 \r
1692     <sect1 id="xmlrpc-client" xreflabel="xmlrpc_client">\r
1693       <title>xmlrpc_client</title>\r
1694 \r
1695       <para>This is the basic class used to represent a client of an XML-RPC\r
1696       server.</para>\r
1697 \r
1698       <sect2>\r
1699         <title>Creation</title>\r
1700 \r
1701         <para>The constructor accepts one of two possible syntaxes:</para>\r
1702 \r
1703         <funcsynopsis>\r
1704           <funcprototype>\r
1705             <funcdef><type>xmlrpc_client</type>new\r
1706             <function>xmlrpc_client</function></funcdef>\r
1707 \r
1708             <paramdef><type>string</type><parameter>$server_url</parameter></paramdef>\r
1709           </funcprototype>\r
1710 \r
1711           <funcprototype>\r
1712             <funcdef><type>xmlrpc_client</type>new\r
1713             <function>xmlrpc_client</function></funcdef>\r
1714 \r
1715             <paramdef><type>string</type><parameter>$server_path</parameter></paramdef>\r
1716 \r
1717             <paramdef><type>string</type><parameter>$server_hostname</parameter></paramdef>\r
1718 \r
1719             <paramdef><type>int</type><parameter>$server_port</parameter><initializer>80</initializer></paramdef>\r
1720 \r
1721             <paramdef><type>string</type><parameter>$transport</parameter><initializer>'http'</initializer></paramdef>\r
1722           </funcprototype>\r
1723         </funcsynopsis>\r
1724 \r
1725         <para>Here are a couple of usage examples of the first form:</para>\r
1726 \r
1727         <programlisting language="php">\r
1728 $client = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");\r
1729 $another_client = new xmlrpc_client("https://james:bond@secret.service.com:4443/xmlrpcserver?agent=007");\r
1730 </programlisting>\r
1731 \r
1732         <para>The second syntax does not allow to express a username and\r
1733         password to be used for basic HTTP authorization as in the second\r
1734         example above, but instead it allows to choose whether xmlrpc calls\r
1735         will be made using the HTTP 1.0 or 1.1 protocol.</para>\r
1736 \r
1737         <para>Here's another example client set up to query Userland's XML-RPC\r
1738         server at <emphasis>betty.userland.com</emphasis>:</para>\r
1739 \r
1740         <programlisting language="php">\r
1741 $client = new xmlrpc_client("/RPC2", "betty.userland.com", 80);\r
1742 </programlisting>\r
1743 \r
1744         <para>The <parameter>server_port</parameter> parameter is optional,\r
1745         and if omitted will default to 80 when using HTTP and 443 when using\r
1746         HTTPS (see the <xref linkend="xmlrpc-client-send" /> method\r
1747         below).</para>\r
1748 \r
1749         <para>The <parameter>transport</parameter> parameter is optional, and\r
1750         if omitted will default to 'http'. Allowed values are either\r
1751         '<symbol>http'</symbol>, '<symbol>https</symbol>' or\r
1752         '<symbol>http11'</symbol>. Its value can be overridden with every call\r
1753         to the <methodname>send</methodname> method. See the\r
1754         <methodname>send</methodname> method below for more details about the\r
1755         meaning of the different values.</para>\r
1756       </sect2>\r
1757 \r
1758       <sect2>\r
1759         <title>Methods</title>\r
1760 \r
1761         <para>This class supports the following methods.</para>\r
1762 \r
1763         <sect3 id="xmlrpc-client-send" xreflabel="xmlrpc_client-&gt;send">\r
1764           <title>send</title>\r
1765 \r
1766           <para>This method takes the forms:</para>\r
1767 \r
1768           <funcsynopsis>\r
1769             <funcprototype>\r
1770               <funcdef><type>xmlrpcresp</type><function>send</function></funcdef>\r
1771 \r
1772               <paramdef><type>xmlrpcmsg</type><parameter>$xmlrpc_message</parameter></paramdef>\r
1773 \r
1774               <paramdef><type>int</type><parameter>$timeout</parameter></paramdef>\r
1775 \r
1776               <paramdef><type>string</type><parameter>$transport</parameter></paramdef>\r
1777             </funcprototype>\r
1778 \r
1779             <funcprototype>\r
1780               <funcdef><type>array</type><function>send</function></funcdef>\r
1781 \r
1782               <paramdef><type>array</type><parameter>$xmlrpc_messages</parameter></paramdef>\r
1783 \r
1784               <paramdef><type>int</type><parameter>$timeout</parameter></paramdef>\r
1785 \r
1786               <paramdef><type>string</type><parameter>$transport</parameter></paramdef>\r
1787             </funcprototype>\r
1788 \r
1789             <funcprototype>\r
1790               <funcdef><type>xmlrpcresp</type><function>send</function></funcdef>\r
1791 \r
1792               <paramdef><type>string</type><parameter>$xml_payload</parameter></paramdef>\r
1793 \r
1794               <paramdef><type>int</type><parameter>$timeout</parameter></paramdef>\r
1795 \r
1796               <paramdef><type>string</type><parameter>$transport</parameter></paramdef>\r
1797             </funcprototype>\r
1798           </funcsynopsis>\r
1799 \r
1800           <para>Where <parameter>xmlrpc_message</parameter> is an instance of\r
1801           <classname>xmlrpcmsg</classname> (see <xref linkend="xmlrpcmsg" />),\r
1802           and <parameter>response</parameter> is an instance of\r
1803           <classname>xmlrpcresp</classname> (see <xref\r
1804           linkend="xmlrpcresp" />).</para>\r
1805 \r
1806           <para><parameter>If xmlrpc_messages</parameter> is an array of\r
1807           message instances, <code>responses</code> will be an array of\r
1808           response instances. The client will try to make use of a single\r
1809           <code>system.multicall</code> xml-rpc method call to forward to the\r
1810           server all the messages in a single HTTP round trip, unless\r
1811           <code>$client-&gt;no_multicall</code> has been previously set to\r
1812           <code>TRUE</code> (see the multicall method below), in which case\r
1813           many consecutive xmlrpc requests will be sent.</para>\r
1814 \r
1815           <para>The third syntax allows to build by hand (or any other means)\r
1816           a complete xmlrpc request message, and send it to the server.\r
1817           <parameter>xml_payload</parameter> should be a string containing the\r
1818           complete xml representation of the request. It is e.g. useful when,\r
1819           for maximal speed of execution, the request is serialized into a\r
1820           string using the native php xmlrpc functions (see <ulink\r
1821           url="http://www.php.net/xmlrpc">the php manual on\r
1822           xmlrpc</ulink>).</para>\r
1823 \r
1824           <para>The <parameter>timeout</parameter> is optional, and will be\r
1825           set to <literal>0</literal> (wait for platform-specific predefined\r
1826           timeout) if omitted. This timeout value is passed to\r
1827           <function>fsockopen()</function>. It is also used for detecting\r
1828           server timeouts during communication (i.e. if the server does not\r
1829           send anything to the client for <parameter>timeout</parameter>\r
1830           seconds, the connection will be closed).</para>\r
1831 \r
1832           <para>The <parameter>transport</parameter> parameter is optional,\r
1833           and if omitted will default to the transport set using instance\r
1834           creator or 'http' if omitted. The only other valid values are\r
1835           'https', which will use an SSL HTTP connection to connect to the\r
1836           remote server, and 'http11'. Note that your PHP must have the "curl"\r
1837           extension compiled in order to use both these features. Note that\r
1838           when using SSL you should normally set your port number to 443,\r
1839           unless the SSL server you are contacting runs at any other\r
1840           port.</para>\r
1841 \r
1842           <warning>\r
1843             <para>PHP 4.0.6 has a bug which prevents SSL working.</para>\r
1844           </warning>\r
1845 \r
1846           <para>In addition to low-level errors, the XML-RPC server you were\r
1847           querying may return an error in the\r
1848           <classname>xmlrpcresp</classname> object. See <xref\r
1849           linkend="xmlrpcresp" /> for details of how to handle these\r
1850           errors.</para>\r
1851         </sect3>\r
1852 \r
1853         <sect3 id="multicall" xreflabel="xmlrpc_client-&gt;multicall">\r
1854           <title>multiCall</title>\r
1855 \r
1856           <para>This method takes the form:</para>\r
1857 \r
1858           <funcsynopsis>\r
1859             <funcprototype>\r
1860               <funcdef><type>array</type><function>multiCall</function></funcdef>\r
1861 \r
1862               <paramdef><type>array</type><parameter>$messages</parameter></paramdef>\r
1863 \r
1864               <paramdef><type>int</type><parameter>$timeout</parameter></paramdef>\r
1865 \r
1866               <paramdef><type>string</type><parameter>$transport</parameter></paramdef>\r
1867 \r
1868               <paramdef><type>bool</type><parameter>$fallback</parameter></paramdef>\r
1869             </funcprototype>\r
1870           </funcsynopsis>\r
1871 \r
1872           <para>This method is used to boxcar many method calls in a single\r
1873           xml-rpc request. It will try first to make use of the\r
1874           <code>system.multicall</code> xml-rpc method call, and fall back to\r
1875           executing many separate requests if the server returns any\r
1876           error.</para>\r
1877 \r
1878           <para><parameter>msgs</parameter> is an array of\r
1879           <classname>xmlrpcmsg</classname> objects (see <xref\r
1880           linkend="xmlrpcmsg" />), and <parameter>response</parameter> is an\r
1881           array of <classname>xmlrpcresp</classname> objects (see <xref\r
1882           linkend="xmlrpcresp" />).</para>\r
1883 \r
1884           <para>The <parameter>timeout</parameter> and\r
1885           <parameter>transport</parameter> parameters are optional, and behave\r
1886           as in the <methodname>send</methodname> method above.</para>\r
1887 \r
1888           <para>The <parameter>fallback</parameter> parameter is optional, and\r
1889           defaults to <constant>TRUE</constant>. When set to\r
1890           <constant>FALSE</constant> it will prevent the client to try using\r
1891           many single method calls in case of failure of the first multicall\r
1892           request. It should be set only when the server is known to support\r
1893           the multicall extension.</para>\r
1894         </sect3>\r
1895 \r
1896         <sect3>\r
1897           <title>setAcceptedCompression</title>\r
1898 \r
1899           <funcsynopsis>\r
1900             <funcprototype>\r
1901               <funcdef><type>void</type><function>setAcceptedCompression</function></funcdef>\r
1902 \r
1903               <paramdef><type>string</type><parameter>$compressionmethod</parameter></paramdef>\r
1904             </funcprototype>\r
1905           </funcsynopsis>\r
1906 \r
1907           <para>This method defines whether the client will accept compressed\r
1908           xml payload forming the bodies of the xmlrpc responses received from\r
1909           servers. Note that enabling reception of compressed responses merely\r
1910           adds some standard http headers to xmlrpc requests. It is up to the\r
1911           xmlrpc server to return compressed responses when receiving such\r
1912           requests. Allowed values for\r
1913           <parameter>compressionmethod</parameter> are: 'gzip', 'deflate',\r
1914           'any' or null (with any meaning either gzip or deflate).</para>\r
1915 \r
1916           <para>This requires the "zlib" extension to be enabled in your php\r
1917           install. If it is, by default <classname>xmlrpc_client</classname>\r
1918           instances will enable reception of compressed content.</para>\r
1919         </sect3>\r
1920 \r
1921         <sect3>\r
1922           <title>setCaCertificate</title>\r
1923 \r
1924           <funcsynopsis>\r
1925             <funcprototype>\r
1926               <funcdef><type>void</type><function>setCaCertificate</function></funcdef>\r
1927 \r
1928               <paramdef><type>string</type><parameter>$certificate</parameter></paramdef>\r
1929 \r
1930               <paramdef><type>bool</type><parameter>$is_dir</parameter></paramdef>\r
1931             </funcprototype>\r
1932           </funcsynopsis>\r
1933 \r
1934           <para>This method sets an optional certificate to be used in\r
1935           SSL-enabled communication to validate a remote server with (when the\r
1936           <parameter>server_method</parameter> is set to 'https' in the\r
1937           client's construction or in the send method and\r
1938           <methodname>SetSSLVerifypeer</methodname> has been set to\r
1939           <constant>TRUE</constant>).</para>\r
1940 \r
1941           <para>The <parameter>certificate</parameter> parameter must be the\r
1942           filename of a PEM formatted certificate, or a directory containing\r
1943           multiple certificate files. The <parameter>is_dir</parameter>\r
1944           parameter defaults to <constant>FALSE</constant>, set it to\r
1945           <constant>TRUE</constant> to specify that\r
1946           <parameter>certificate</parameter> indicates a directory instead of\r
1947           a single file.</para>\r
1948 \r
1949           <para>This requires the "curl" extension to be compiled into your\r
1950           installation of PHP. For more details see the man page for the\r
1951           <function>curl_setopt</function> function.</para>\r
1952         </sect3>\r
1953 \r
1954         <sect3>\r
1955           <title>setCertificate</title>\r
1956 \r
1957           <funcsynopsis>\r
1958             <funcprototype>\r
1959               <funcdef><type>void</type><function>setCertificate</function></funcdef>\r
1960 \r
1961               <paramdef><type>string</type><parameter>$certificate</parameter></paramdef>\r
1962 \r
1963               <paramdef><type>string</type><parameter>$passphrase</parameter></paramdef>\r
1964             </funcprototype>\r
1965           </funcsynopsis>\r
1966 \r
1967           <para>This method sets the optional certificate and passphrase used\r
1968           in SSL-enabled communication with a remote server (when the\r
1969           <parameter>server_method</parameter> is set to 'https' in the\r
1970           client's construction or in the send method).</para>\r
1971 \r
1972           <para>The <parameter>certificate</parameter> parameter must be the\r
1973           filename of a PEM formatted certificate. The\r
1974           <parameter>passphrase</parameter> parameter must contain the\r
1975           password required to use the certificate.</para>\r
1976 \r
1977           <para>This requires the "curl" extension to be compiled into your\r
1978           installation of PHP. For more details see the man page for the\r
1979           <function>curl_setopt</function> function.</para>\r
1980 \r
1981           <para>Note: to retrieve information about the client certificate on\r
1982           the server side, you will need to look into the environment\r
1983           variables which are set up by the webserver. Different webservers\r
1984           will typically set up different variables.</para>\r
1985         </sect3>\r
1986 \r
1987         <sect3>\r
1988           <title>setCookie</title>\r
1989 \r
1990           <funcsynopsis>\r
1991             <funcprototype>\r
1992               <funcdef><type>void</type><function>setCookie</function></funcdef>\r
1993 \r
1994               <paramdef><type>string</type><parameter>$name</parameter></paramdef>\r
1995 \r
1996               <paramdef><type>string</type><parameter>$value</parameter></paramdef>\r
1997 \r
1998               <paramdef><type>string</type><parameter>$path</parameter></paramdef>\r
1999 \r
2000               <paramdef><type>string</type><parameter>$domain</parameter></paramdef>\r
2001 \r
2002               <paramdef><type>int</type><parameter>$port</parameter></paramdef>\r
2003             </funcprototype>\r
2004           </funcsynopsis>\r
2005 \r
2006           <para>This method sets a cookie that will be sent to the xmlrpc\r
2007           server along with every further request (useful e.g. for keeping\r
2008           session info outside of the xml-rpc payload).</para>\r
2009 \r
2010           <para><parameter>$value</parameter> is optional, and defaults to\r
2011           null.</para>\r
2012 \r
2013           <para><parameter>$path, $domain and $port</parameter> are optional,\r
2014           and will be omitted from the cookie header if unspecified. Note that\r
2015           setting any of these values will turn the cookie into a 'version 1'\r
2016           cookie, that might not be fully supported by the server (see RFC2965\r
2017           for more details).</para>\r
2018         </sect3>\r
2019 \r
2020         <sect3>\r
2021           <title>setCredentials</title>\r
2022 \r
2023           <funcsynopsis>\r
2024             <funcprototype>\r
2025               <funcdef><type>void</type><function>setCredentials</function></funcdef>\r
2026 \r
2027               <paramdef><type>string</type><parameter>$username</parameter></paramdef>\r
2028 \r
2029               <paramdef><type>string</type><parameter>$password</parameter></paramdef>\r
2030 \r
2031               <paramdef><type>int</type><parameter>$authtype</parameter></paramdef>\r
2032             </funcprototype>\r
2033           </funcsynopsis>\r
2034 \r
2035           <para>This method sets the username and password for authorizing the\r
2036           client to a server. With the default (HTTP) transport, this\r
2037           information is used for HTTP Basic authorization. Note that username\r
2038           and password can also be set using the class constructor. With HTTP\r
2039           1.1 and HTTPS transport, NTLM and Digest authentication protocols\r
2040           are also supported. To enable them use the constants\r
2041           <constant>CURLAUTH_DIGEST</constant> and\r
2042           <constant>CURLAUTH_NTLM</constant> as values for the authtype\r
2043           parameter.</para>\r
2044         </sect3>\r
2045 \r
2046         <sect3>\r
2047           <title>setDebug</title>\r
2048 \r
2049           <funcsynopsis>\r
2050             <funcprototype>\r
2051               <funcdef><type>void</type><function>setDebug</function></funcdef>\r
2052 \r
2053               <paramdef><type>int</type><parameter>$debugLvl</parameter></paramdef>\r
2054             </funcprototype>\r
2055           </funcsynopsis>\r
2056 \r
2057           <para><parameter>debugLvl</parameter> is either <literal>0,\r
2058           1</literal> or 2 depending on whether you require the client to\r
2059           print debugging information to the browser. The default is not to\r
2060           output this information (0).</para>\r
2061 \r
2062           <para>The debugging information at level 1includes the raw data\r
2063           returned from the XML-RPC server it was querying (including bot HTTP\r
2064           headers and the full XML payload), and the PHP value the client\r
2065           attempts to create to represent the value returned by the server. At\r
2066           level2, the complete payload of the xmlrpc request is also printed,\r
2067           before being sent t the server.</para>\r
2068 \r
2069           <para>This option can be very useful when debugging servers as it\r
2070           allows you to see exactly what the client sends and the server\r
2071           returns.</para>\r
2072         </sect3>\r
2073 \r
2074         <sect3>\r
2075           <title>setKey</title>\r
2076 \r
2077           <funcsynopsis>\r
2078             <funcprototype>\r
2079               <funcdef><type>void</type><function>setKey</function></funcdef>\r
2080 \r
2081               <paramdef><type>int</type><parameter>$key</parameter></paramdef>\r
2082 \r
2083               <paramdef><type>int</type><parameter>$keypass</parameter></paramdef>\r
2084             </funcprototype>\r
2085           </funcsynopsis>\r
2086 \r
2087           <para>This method sets the optional certificate key and passphrase\r
2088           used in SSL-enabled communication with a remote server (when the\r
2089           <parameter>transport</parameter> is set to 'https' in the client's\r
2090           construction or in the send method).</para>\r
2091 \r
2092           <para>This requires the "curl" extension to be compiled into your\r
2093           installation of PHP. For more details see the man page for the\r
2094           <function>curl_setopt</function> function.</para>\r
2095         </sect3>\r
2096 \r
2097         <sect3>\r
2098           <title>setProxy</title>\r
2099 \r
2100           <funcsynopsis>\r
2101             <funcprototype>\r
2102               <funcdef><type>void</type><function>setProxy</function></funcdef>\r
2103 \r
2104               <paramdef><type>string</type><parameter>$proxyhost</parameter></paramdef>\r
2105 \r
2106               <paramdef><type>int</type><parameter>$proxyport</parameter></paramdef>\r
2107 \r
2108               <paramdef><type>string</type><parameter>$proxyusername</parameter></paramdef>\r
2109 \r
2110               <paramdef><type>string</type><parameter>$proxypassword</parameter></paramdef>\r
2111 \r
2112               <paramdef><type>int</type><parameter>$authtype</parameter></paramdef>\r
2113             </funcprototype>\r
2114           </funcsynopsis>\r
2115 \r
2116           <para>This method enables calling servers via an HTTP proxy. The\r
2117           <parameter>proxyusername</parameter>,<parameter>\r
2118           proxypassword</parameter> and <parameter>authtype</parameter>\r
2119           parameters are optional. <parameter>Authtype</parameter> defaults to\r
2120           <constant>CURLAUTH_BASIC</constant> (Basic authentication protocol);\r
2121           the only other valid value is the constant\r
2122           <constant>CURLAUTH_NTLM</constant>, and has effect only when the\r
2123           client uses the HTTP 1.1 protocol.</para>\r
2124 \r
2125           <para>NB: CURL versions before 7.11.10 cannot use a proxy to\r
2126           communicate with https servers.</para>\r
2127         </sect3>\r
2128 \r
2129         <sect3>\r
2130           <title>setRequestCompression</title>\r
2131 \r
2132           <funcsynopsis>\r
2133             <funcprototype>\r
2134               <funcdef><type>void</type><function>setRequestCompression</function></funcdef>\r
2135 \r
2136               <paramdef><type>string</type><parameter>$compressionmethod</parameter></paramdef>\r
2137             </funcprototype>\r
2138           </funcsynopsis>\r
2139 \r
2140           <para>This method defines whether the xml payload forming the\r
2141           request body will be sent to the server in compressed format, as per\r
2142           the HTTP specification. This is particularly useful for large\r
2143           request parameters and over slow network connections. Allowed values\r
2144           for <parameter>compressionmethod</parameter> are: 'gzip', 'deflate',\r
2145           'any' or null (with any meaning either gzip or deflate). Note that\r
2146           there is no automatic fallback mechanism in place for errors due to\r
2147           servers not supporting receiving compressed request bodies, so make\r
2148           sure that the particular server you are querying does accept\r
2149           compressed requests before turning it on.</para>\r
2150 \r
2151           <para>This requires the "zlib" extension to be enabled in your php\r
2152           install.</para>\r
2153         </sect3>\r
2154 \r
2155         <sect3>\r
2156           <title>setSSLVerifyHost</title>\r
2157 \r
2158           <funcsynopsis>\r
2159             <funcprototype>\r
2160               <funcdef><type>void</type><function>setSSLVerifyHost</function></funcdef>\r
2161 \r
2162               <paramdef><type>int</type><parameter>$i</parameter></paramdef>\r
2163             </funcprototype>\r
2164           </funcsynopsis>\r
2165 \r
2166           <para>This method defines whether connections made to XML-RPC\r
2167           backends via HTTPS should verify the remote host's SSL certificate's\r
2168           common name (CN). By default, only the existence of a CN is checked.\r
2169           <parameter><parameter>$i</parameter></parameter> should be an\r
2170           integer value; 0 to not check the CN at all, 1 to merely check for\r
2171           its existence, and 2 to check that the CN on the certificate matches\r
2172           the hostname that is being connected to.</para>\r
2173         </sect3>\r
2174 \r
2175         <sect3>\r
2176           <title>setSSLVerifyPeer</title>\r
2177 \r
2178           <funcsynopsis>\r
2179             <funcprototype>\r
2180               <funcdef><type>void</type><function>setSSLVerifyPeer</function></funcdef>\r
2181 \r
2182               <paramdef><type>bool</type><parameter>$i</parameter></paramdef>\r
2183             </funcprototype>\r
2184           </funcsynopsis>\r
2185 \r
2186           <para>This method defines whether connections made to XML-RPC\r
2187           backends via HTTPS should verify the remote host's SSL certificate,\r
2188           and cause the connection to fail if the cert verification fails.\r
2189           <parameter><parameter>$i</parameter></parameter> should be a boolean\r
2190           value. Default value: <constant>TRUE</constant>. To specify custom\r
2191           SSL certificates to validate the server with, use the\r
2192           <methodname>setCaCertificate</methodname> method.</para>\r
2193         </sect3>\r
2194       </sect2>\r
2195 \r
2196       <sect2>\r
2197         <title>Variables</title>\r
2198 \r
2199         <para>NB: direct manipulation of these variables is only recommended\r
2200         for advanced users.</para>\r
2201 \r
2202         <sect3>\r
2203           <title>no_multicall</title>\r
2204 \r
2205           <para>This member variable determines whether the multicall() method\r
2206           will try to take advantage of the system.multicall xmlrpc method to\r
2207           dispatch to the server an array of requests in a single http\r
2208           roundtrip or simply execute many consecutive http calls. Defaults to\r
2209           FALSE, but it will be enabled automatically on the first failure of\r
2210           execution of system.multicall.</para>\r
2211         </sect3>\r
2212 \r
2213         <sect3>\r
2214           <title>request_charset_encoding</title>\r
2215 \r
2216           <para>This is the charset encoding that will be used for serializing\r
2217           request sent by the client.</para>\r
2218 \r
2219           <para>If defaults to NULL, which means using US-ASCII and encoding\r
2220           all characters outside of the ASCII range using their xml character\r
2221           entity representation (this has the benefit that line end characters\r
2222           will not be mangled in the transfer, a CR-LF will be preserved as\r
2223           well as a singe LF).</para>\r
2224 \r
2225           <para>Valid values are 'US-ASCII', 'UTF-8' and 'ISO-8859-1'</para>\r
2226         </sect3>\r
2227 \r
2228         <sect3 id="return-type" xreflabel="return_type">\r
2229           <title>return_type</title>\r
2230 \r
2231           <para>This member variable determines whether the value returned\r
2232           inside an xmlrpcresp object as results of calls to the send() and\r
2233           multicall() methods will be an xmlrpcval object, a plain php value\r
2234           or a raw xml string. Allowed values are 'xmlrpcvals' (the default),\r
2235           'phpvals' and 'xml'. To allow the user to differentiate between a\r
2236           correct and a faulty response, fault responses will be returned as\r
2237           xmlrpcresp objects in any case. Note that the 'phpvals' setting will\r
2238           yield faster execution times, but some of the information from the\r
2239           original response will be lost. It will be e.g. impossible to tell\r
2240           whether a particular php string value was sent by the server as an\r
2241           xmlrpc string or base64 value.</para>\r
2242 \r
2243           <para>Example usage:</para>\r
2244 \r
2245           <programlisting language="php">\r
2246 $client = new xmlrpc_client("phpxmlrpc.sourceforge.net/server");\r
2247 $client-&gt;return_type = 'phpvals';\r
2248 $message = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23, "int")));\r
2249 $resp = $client-&gt;send($message);\r
2250 if ($resp-&gt;faultCode()) echo 'KO. Error: '.$resp-&gt;faultString(); else echo 'OK: got '.$resp-&gt;value();\r
2251 </programlisting>\r
2252 \r
2253           <para>For more details about usage of the 'xml' value, see Appendix\r
2254           A.</para>\r
2255         </sect3>\r
2256       </sect2>\r
2257     </sect1>\r
2258 \r
2259     <sect1 id="xmlrpcresp" xreflabel="xmlrpcresp">\r
2260       <title>xmlrpcresp</title>\r
2261 \r
2262       <para>This class is used to contain responses to XML-RPC requests. A\r
2263       server method handler will construct an\r
2264       <classname>xmlrpcresp</classname> and pass it as a return value. This\r
2265       same value will be returned by the result of an invocation of the\r
2266       <function>send</function> method of the\r
2267       <classname>xmlrpc_client</classname> class.</para>\r
2268 \r
2269       <sect2>\r
2270         <title>Creation</title>\r
2271 \r
2272         <funcsynopsis>\r
2273           <funcprototype>\r
2274             <funcdef><type>xmlrpcresp</type>new\r
2275             <function>xmlrpcresp</function></funcdef>\r
2276 \r
2277             <paramdef><type>xmlrpcval</type><parameter>$xmlrpcval</parameter></paramdef>\r
2278           </funcprototype>\r
2279 \r
2280           <funcprototype>\r
2281             <funcdef><type>xmlrpcresp</type>new\r
2282             <function>xmlrpcresp</function></funcdef>\r
2283 \r
2284             <paramdef><parameter>0</parameter></paramdef>\r
2285 \r
2286             <paramdef><type>int</type><parameter>$errcode</parameter></paramdef>\r
2287 \r
2288             <paramdef><type>string</type><parameter>$err_string</parameter></paramdef>\r
2289           </funcprototype>\r
2290         </funcsynopsis>\r
2291 \r
2292         <para>The first syntax is used when execution has happened without\r
2293         difficulty: <parameter>$xmlrpcval</parameter> is an\r
2294         <classname>xmlrpcval</classname> value with the result of the method\r
2295         execution contained in it. Alternatively it can be a string containing\r
2296         the xml serialization of the single xml-rpc value result of method\r
2297         execution.</para>\r
2298 \r
2299         <para>The second type of constructor is used in case of failure.\r
2300         <parameter>errcode</parameter> and <parameter>err_string</parameter>\r
2301         are used to provide indication of what has gone wrong. See <xref\r
2302         linkend="xmlrpc-server" /> for more information on passing error\r
2303         codes.</para>\r
2304       </sect2>\r
2305 \r
2306       <sect2>\r
2307         <title>Methods</title>\r
2308 \r
2309         <sect3>\r
2310           <title>faultCode</title>\r
2311 \r
2312           <funcsynopsis>\r
2313             <funcprototype>\r
2314               <funcdef><type>int</type><function>faultCode</function></funcdef>\r
2315 \r
2316               <void />\r
2317             </funcprototype>\r
2318           </funcsynopsis>\r
2319 \r
2320           <para>Returns the integer fault code return from the XML-RPC\r
2321           response. A zero value indicates success, any other value indicates\r
2322           a failure response.</para>\r
2323         </sect3>\r
2324 \r
2325         <sect3>\r
2326           <title>faultString</title>\r
2327 \r
2328           <funcsynopsis>\r
2329             <funcprototype>\r
2330               <funcdef><type>string</type><function>faultString</function></funcdef>\r
2331 \r
2332               <void />\r
2333             </funcprototype>\r
2334           </funcsynopsis>\r
2335 \r
2336           <para>Returns the human readable explanation of the fault indicated\r
2337           by <function>$resp-&gt;faultCode</function>().</para>\r
2338         </sect3>\r
2339 \r
2340         <sect3>\r
2341           <title>value</title>\r
2342 \r
2343           <funcsynopsis>\r
2344             <funcprototype>\r
2345               <funcdef><type>xmlrpcval</type><function>value</function></funcdef>\r
2346 \r
2347               <void />\r
2348             </funcprototype>\r
2349           </funcsynopsis>\r
2350 \r
2351           <para>Returns an <classname>xmlrpcval</classname> object containing\r
2352           the return value sent by the server. If the response's\r
2353           <function>faultCode</function> is non-zero then the value returned\r
2354           by this method should not be used (it may not even be an\r
2355           object).</para>\r
2356 \r
2357           <para>Note: if the xmlrpcresp instance in question has been created\r
2358           by an <classname>xmlrpc_client</classname> object whose\r
2359           <varname>return_type</varname> was set to 'phpvals', then a plain\r
2360           php value will be returned instead of an\r
2361           <classname>xmlrpcval</classname> object. If the\r
2362           <varname>return_type</varname> was set to 'xml', an xml string will\r
2363           be returned (see the return_type member var above for more\r
2364           details).</para>\r
2365         </sect3>\r
2366 \r
2367         <sect3>\r
2368           <title>serialize</title>\r
2369 \r
2370           <funcsynopsis>\r
2371             <funcprototype>\r
2372               <funcdef><type>string</type><function>serialize</function></funcdef>\r
2373 \r
2374               <void />\r
2375             </funcprototype>\r
2376           </funcsynopsis>\r
2377 \r
2378           <para>Returns an XML string representation of the response (xml\r
2379           prologue not included).</para>\r
2380         </sect3>\r
2381       </sect2>\r
2382     </sect1>\r
2383 \r
2384     <sect1 id="xmlrpc-server" xreflabel="xmlrpc_server">\r
2385       <title>xmlrpc_server</title>\r
2386 \r
2387       <para>The implementation of this class has been kept as simple to use as\r
2388       possible. The constructor for the server basically does all the work.\r
2389       Here's a minimal example:</para>\r
2390 \r
2391       <programlisting language="php">\r
2392   function foo ($xmlrpcmsg) {\r
2393     ...\r
2394     return new xmlrpcresp($some_xmlrpc_val);\r
2395   }\r
2396 \r
2397   class bar {\r
2398     function foobar($xmlrpcmsg) {\r
2399       ...\r
2400       return new xmlrpcresp($some_xmlrpc_val);\r
2401     }\r
2402   }\r
2403 \r
2404   $s = new xmlrpc_server(\r
2405     array(\r
2406       "examples.myFunc1" =&gt; array("function" =&gt; "foo"),\r
2407       "examples.myFunc2" =&gt; array("function" =&gt; "bar::foobar"),\r
2408     ));\r
2409 </programlisting>\r
2410 \r
2411       <para>This performs everything you need to do with a server. The single\r
2412       constructor argument is an associative array from xmlrpc method names to\r
2413       php function names. The incoming request is parsed and dispatched to the\r
2414       relevant php function, which is responsible for returning a\r
2415       <classname>xmlrpcresp</classname> object, that will be serialized back\r
2416       to the caller.</para>\r
2417 \r
2418       <sect2>\r
2419         <title>Method handler functions</title>\r
2420 \r
2421         <para>Both php functions and class methods can be registered as xmlrpc\r
2422         method handlers.</para>\r
2423 \r
2424         <para>The synopsis of a method handler function is:</para>\r
2425 \r
2426         <para><synopsis>xmlrpcresp $resp = function (xmlrpcmsg $msg)</synopsis></para>\r
2427 \r
2428         <para>No text should be echoed 'to screen' by the handler function, or\r
2429         it will break the xml response sent back to the client. This applies\r
2430         also to error and warning messages that PHP prints to screen unless\r
2431         the appropriate parameters have been set in the php.in file. Another\r
2432         way to prevent echoing of errors inside the response and facilitate\r
2433         debugging is to use the server SetDebug method with debug level 3 (see\r
2434         below).</para>\r
2435 \r
2436         <para>Note that if you implement a method with a name prefixed by\r
2437         <code>system.</code> the handler function will be invoked by the\r
2438         server with two parameters, the first being the server itself and the\r
2439         second being the <classname>xmlrpcmsg</classname> object.</para>\r
2440 \r
2441         <para>The same php function can be registered as handler of multiple\r
2442         xmlrpc methods.</para>\r
2443 \r
2444         <para>Here is a more detailed example of what the handler function\r
2445         <function>foo</function> may do:</para>\r
2446 \r
2447         <programlisting language="php">\r
2448   function foo ($xmlrpcmsg) {\r
2449     global $xmlrpcerruser; // import user errcode base value\r
2450 \r
2451     $meth = $xmlrpcmsg-&gt;method(); // retrieve method name\r
2452     $par = $xmlrpcmsg-&gt;getParam(0); // retrieve value of first parameter - assumes at least one param received\r
2453     $val = $par-&gt;scalarval(); // decode value of first parameter - assumes it is a scalar value\r
2454 \r
2455     ...\r
2456 \r
2457     if ($err) {\r
2458       // this is an error condition\r
2459       return new xmlrpcresp(0, $xmlrpcerruser+1, // user error 1\r
2460         "There's a problem, Captain");\r
2461     } else {\r
2462       // this is a successful value being returned\r
2463       return new xmlrpcresp(new xmlrpcval("All's fine!", "string"));\r
2464     }\r
2465   }\r
2466 </programlisting>\r
2467 \r
2468         <para>See <filename>server.php</filename> in this distribution for\r
2469         more examples of how to do this.</para>\r
2470 \r
2471         <para>Since release 2.0RC3 there is a new, even simpler way of\r
2472         registering php functions with the server. See section 5.7\r
2473         below</para>\r
2474       </sect2>\r
2475 \r
2476       <sect2>\r
2477         <title>The dispatch map</title>\r
2478 \r
2479         <para>The first argument to the <function>xmlrpc_server</function>\r
2480         constructor is an array, called the <emphasis>dispatch map</emphasis>.\r
2481         In this array is the information the server needs to service the\r
2482         XML-RPC methods you define.</para>\r
2483 \r
2484         <para>The dispatch map takes the form of an associative array of\r
2485         associative arrays: the outer array has one entry for each method, the\r
2486         key being the method name. The corresponding value is another\r
2487         associative array, which can have the following members:</para>\r
2488 \r
2489         <itemizedlist>\r
2490           <listitem>\r
2491             <para><function><literal>function</literal></function> - this\r
2492             entry is mandatory. It must be either a name of a function in the\r
2493             global scope which services the XML-RPC method, or an array\r
2494             containing an instance of an object and a static method name (for\r
2495             static class methods the 'class::method' syntax is also\r
2496             supported).</para>\r
2497           </listitem>\r
2498 \r
2499           <listitem>\r
2500             <para><function><literal>signature</literal></function> - this\r
2501             entry is an array containing the possible signatures (see <xref\r
2502             linkend="signatures" />) for the method. If this entry is present\r
2503             then the server will check that the correct number and type of\r
2504             parameters have been sent for this method before dispatching\r
2505             it.</para>\r
2506           </listitem>\r
2507 \r
2508           <listitem>\r
2509             <para><function><literal>docstring</literal></function> - this\r
2510             entry is a string containing documentation for the method. The\r
2511             documentation may contain HTML markup.</para>\r
2512           </listitem>\r
2513 \r
2514           <listitem>\r
2515             <para><literal>signature_docs</literal> - this entry can be used\r
2516             to provide documentation for the single parameters. It must match\r
2517             in structure the 'signature' member. By default, only the\r
2518             <classname>documenting_xmlrpc_server</classname> class in the\r
2519             extras package will take advantage of this, since the\r
2520             "system.methodHelp" protocol does not support documenting method\r
2521             parameters individually.</para>\r
2522           </listitem>\r
2523         </itemizedlist>\r
2524 \r
2525         <para>Look at the <filename>server.php</filename> example in the\r
2526         distribution to see what a dispatch map looks like.</para>\r
2527       </sect2>\r
2528 \r
2529       <sect2 id="signatures" xreflabel="Signatures">\r
2530         <title>Method signatures</title>\r
2531 \r
2532         <para>A signature is a description of a method's return type and its\r
2533         parameter types. A method may have more than one signature.</para>\r
2534 \r
2535         <para>Within a server's dispatch map, each method has an array of\r
2536         possible signatures. Each signature is an array of types. The first\r
2537         entry is the return type. For instance, the method <programlisting\r
2538         language="php">string examples.getStateName(int)\r
2539 </programlisting> has the signature <programlisting language="php">array($xmlrpcString, $xmlrpcInt)\r
2540 </programlisting> and, assuming that it is the only possible signature for the\r
2541         method, it might be used like this in server creation: <programlisting\r
2542         language="php">\r
2543 $findstate_sig = array(array($xmlrpcString, $xmlrpcInt));\r
2544 \r
2545 $findstate_doc = 'When passed an integer between 1 and 51 returns the\r
2546 name of a US state, where the integer is the index of that state name\r
2547 in an alphabetic order.';\r
2548 \r
2549 $s = new xmlrpc_server( array(\r
2550   "examples.getStateName" =&gt; array(\r
2551     "function" =&gt; "findstate",\r
2552     "signature" =&gt; $findstate_sig,\r
2553     "docstring" =&gt; $findstate_doc\r
2554   )));\r
2555 </programlisting></para>\r
2556 \r
2557         <para>Note that method signatures do not allow to check nested\r
2558         parameters, e.g. the number, names and types of the members of a\r
2559         struct param cannot be validated.</para>\r
2560 \r
2561         <para>If a method that you want to expose has a definite number of\r
2562         parameters, but each of those parameters could reasonably be of\r
2563         multiple types, the array of acceptable signatures will easily grow\r
2564         into a combinatorial explosion. To avoid such a situation, the lib\r
2565         defines the global var <varname>$xmlrpcValue</varname>, which can be\r
2566         used in method signatures as a placeholder for 'any xmlrpc\r
2567         type':</para>\r
2568 \r
2569         <para><programlisting language="php">\r
2570 $echoback_sig = array(array($xmlrpcValue, $xmlrpcValue));\r
2571 \r
2572 $findstate_doc = 'Echoes back to the client the received value, regardless of its type';\r
2573 \r
2574 $s = new xmlrpc_server( array(\r
2575   "echoBack" =&gt; array(\r
2576     "function" =&gt; "echoback",\r
2577     "signature" =&gt; $echoback_sig, // this sig guarantees that the method handler will be called with one and only one parameter\r
2578     "docstring" =&gt; $echoback_doc\r
2579   )));\r
2580 </programlisting></para>\r
2581 \r
2582         <para>Methods <methodname>system.listMethods</methodname>,\r
2583         <methodname>system.methodHelp</methodname>,\r
2584         <methodname>system.methodSignature</methodname> and\r
2585         <methodname>system.multicall</methodname> are already defined by the\r
2586         server, and should not be reimplemented (see Reserved Methods\r
2587         below).</para>\r
2588       </sect2>\r
2589 \r
2590       <sect2>\r
2591         <title>Delaying the server response</title>\r
2592 \r
2593         <para>You may want to construct the server, but for some reason not\r
2594         fulfill the request immediately (security verification, for instance).\r
2595         If you omit to pass to the constructor the dispatch map or pass it a\r
2596         second argument of <literal>0</literal> this will have the desired\r
2597         effect. You can then use the <function>service()</function> method of\r
2598         the server class to service the request. For example:</para>\r
2599 \r
2600         <programlisting language="php">\r
2601 $s = new xmlrpc_server($myDispMap, 0); // second parameter = 0 prevents automatic servicing of request\r
2602 \r
2603 // ... some code that does other stuff here\r
2604 \r
2605 $s-&gt;service();\r
2606 </programlisting>\r
2607 \r
2608         <para>Note that the <methodname>service</methodname> method will print\r
2609         the complete result payload to screen and send appropriate HTTP\r
2610         headers back to the client, but also return the response object. This\r
2611         permits further manipulation of the response.</para>\r
2612 \r
2613         <para>To prevent the server from sending HTTP headers back to the\r
2614         client, you can pass a second parameter with a value of\r
2615         <literal>TRUE</literal> to the <methodname>service</methodname>\r
2616         method. In this case, the response payload will be returned instead of\r
2617         the response object.</para>\r
2618 \r
2619         <para>Xmlrpc requests retrieved by other means than HTTP POST bodies\r
2620         can also be processed. For example:</para>\r
2621 \r
2622         <programlisting language="php">\r
2623 $s = new xmlrpc_server(); // not passing a dispatch map prevents automatic servicing of request\r
2624 \r
2625 // ... some code that does other stuff here, including setting dispatch map into server object\r
2626 \r
2627 $resp = $s-&gt;service($xmlrpc_request_body, true); // parse a variable instead of POST body, retrieve response payload\r
2628 \r
2629 // ... some code that does other stuff with xml response $resp here\r
2630 </programlisting>\r
2631       </sect2>\r
2632 \r
2633       <sect2>\r
2634         <title>Modifying the server behaviour</title>\r
2635 \r
2636         <para>A couple of methods / class variables are available to modify\r
2637         the behaviour of the server. The only way to take advantage of their\r
2638         existence is by usage of a delayed server response (see above)</para>\r
2639 \r
2640         <sect3>\r
2641           <title>setDebug()</title>\r
2642 \r
2643           <para>This function controls weather the server is going to echo\r
2644           debugging messages back to the client as comments in response body.\r
2645           Valid values: 0,1,2,3, with 1 being the default. At level 0, no\r
2646           debug info is returned to the client. At level 2, the complete\r
2647           client request is added to the response, as part of the xml\r
2648           comments. At level 3, a new PHP error handler is set when executing\r
2649           user functions exposed as server methods, and all non-fatal errors\r
2650           are trapped and added as comments into the response.</para>\r
2651         </sect3>\r
2652 \r
2653         <sect3>\r
2654           <title>allow_system_funcs</title>\r
2655 \r
2656           <para>Default_value: TRUE. When set to FALSE, disables support for\r
2657           <methodname>System.xxx</methodname> functions in the server. It\r
2658           might be useful e.g. if you do not wish the server to respond to\r
2659           requests to <methodname>System.ListMethods</methodname>.</para>\r
2660         </sect3>\r
2661 \r
2662         <sect3>\r
2663           <title>compress_response</title>\r
2664 \r
2665           <para>When set to TRUE, enables the server to take advantage of HTTP\r
2666           compression, otherwise disables it. Responses will be transparently\r
2667           compressed, but only when an xmlrpc-client declares its support for\r
2668           compression in the HTTP headers of the request.</para>\r
2669 \r
2670           <para>Note that the ZLIB php extension must be installed for this to\r
2671           work. If it is, <varname>compress_response</varname> will default to\r
2672           TRUE.</para>\r
2673         </sect3>\r
2674 \r
2675         <sect3>\r
2676           <title>response_charset_encoding</title>\r
2677 \r
2678           <para>Charset encoding to be used for response (only affects string\r
2679           values).</para>\r
2680 \r
2681           <para>If it can, the server will convert the generated response from\r
2682           internal_encoding to the intended one.</para>\r
2683 \r
2684           <para>Valid values are: a supported xml encoding (only UTF-8 and\r
2685           ISO-8859-1 at present, unless mbstring is enabled), null (leave\r
2686           charset unspecified in response and convert output stream to\r
2687           US_ASCII), 'default' (use xmlrpc library default as specified in\r
2688           xmlrpc.inc, convert output stream if needed), or 'auto' (use\r
2689           client-specified charset encoding or same as request if request\r
2690           headers do not specify it (unless request is US-ASCII: then use\r
2691           library default anyway).</para>\r
2692         </sect3>\r
2693       </sect2>\r
2694 \r
2695       <sect2>\r
2696         <title>Fault reporting</title>\r
2697 \r
2698         <para>Fault codes for your servers should start at the value indicated\r
2699         by the global <literal>$xmlrpcerruser</literal> + 1.</para>\r
2700 \r
2701         <para>Standard errors returned by the server include:</para>\r
2702 \r
2703         <variablelist>\r
2704           <varlistentry>\r
2705             <term><literal>1</literal> <phrase>Unknown method</phrase></term>\r
2706 \r
2707             <listitem>\r
2708               <para>Returned if the server was asked to dispatch a method it\r
2709               didn't know about</para>\r
2710             </listitem>\r
2711           </varlistentry>\r
2712 \r
2713           <varlistentry>\r
2714             <term><literal>2</literal> <phrase>Invalid return\r
2715             payload</phrase></term>\r
2716 \r
2717             <listitem>\r
2718               <para>This error is actually generated by the client, not\r
2719               server, code, but signifies that a server returned something it\r
2720               couldn't understand. A more detailed error report is sometimes\r
2721               added onto the end of the phrase above.</para>\r
2722             </listitem>\r
2723           </varlistentry>\r
2724 \r
2725           <varlistentry>\r
2726             <term><literal>3</literal> <phrase>Incorrect\r
2727             parameters</phrase></term>\r
2728 \r
2729             <listitem>\r
2730               <para>This error is generated when the server has signature(s)\r
2731               defined for a method, and the parameters passed by the client do\r
2732               not match any of signatures.</para>\r
2733             </listitem>\r
2734           </varlistentry>\r
2735 \r
2736           <varlistentry>\r
2737             <term><literal>4</literal> <phrase>Can't introspect: method\r
2738             unknown</phrase></term>\r
2739 \r
2740             <listitem>\r
2741               <para>This error is generated by the builtin\r
2742               <function>system.*</function> methods when any kind of\r
2743               introspection is attempted on a method undefined by the\r
2744               server.</para>\r
2745             </listitem>\r
2746           </varlistentry>\r
2747 \r
2748           <varlistentry>\r
2749             <term><literal>5</literal> <phrase>Didn't receive 200 OK from\r
2750             remote server</phrase></term>\r
2751 \r
2752             <listitem>\r
2753               <para>This error is generated by the client when a remote server\r
2754               doesn't return HTTP/1.1 200 OK in response to a request. A more\r
2755               detailed error report is added onto the end of the phrase\r
2756               above.</para>\r
2757             </listitem>\r
2758           </varlistentry>\r
2759 \r
2760           <varlistentry>\r
2761             <term><literal>6</literal> <phrase>No data received from\r
2762             server</phrase></term>\r
2763 \r
2764             <listitem>\r
2765               <para>This error is generated by the client when a remote server\r
2766               returns HTTP/1.1 200 OK in response to a request, but no\r
2767               response body follows the HTTP headers.</para>\r
2768             </listitem>\r
2769           </varlistentry>\r
2770 \r
2771           <varlistentry>\r
2772             <term><literal>7</literal> <phrase>No SSL support compiled\r
2773             in</phrase></term>\r
2774 \r
2775             <listitem>\r
2776               <para>This error is generated by the client when trying to send\r
2777               a request with HTTPS and the CURL extension is not available to\r
2778               PHP.</para>\r
2779             </listitem>\r
2780           </varlistentry>\r
2781 \r
2782           <varlistentry>\r
2783             <term><literal>8</literal> <phrase>CURL error</phrase></term>\r
2784 \r
2785             <listitem>\r
2786               <para>This error is generated by the client when trying to send\r
2787               a request with HTTPS and the HTTPS communication fails.</para>\r
2788             </listitem>\r
2789           </varlistentry>\r
2790 \r
2791           <varlistentry>\r
2792             <term><literal>9-14</literal> <phrase>multicall\r
2793             errors</phrase></term>\r
2794 \r
2795             <listitem>\r
2796               <para>These errors are generated by the server when something\r
2797               fails inside a system.multicall request.</para>\r
2798             </listitem>\r
2799           </varlistentry>\r
2800 \r
2801           <varlistentry>\r
2802             <term><literal>100-</literal> <phrase>XML parse\r
2803             errors</phrase></term>\r
2804 \r
2805             <listitem>\r
2806               <para>Returns 100 plus the XML parser error code for the fault\r
2807               that occurred. The <function>faultString</function> returned\r
2808               explains where the parse error was in the incoming XML\r
2809               stream.</para>\r
2810             </listitem>\r
2811           </varlistentry>\r
2812         </variablelist>\r
2813       </sect2>\r
2814 \r
2815       <sect2>\r
2816         <title>'New style' servers</title>\r
2817 \r
2818         <para>In the same spirit of simplification that inspired the\r
2819         <varname>xmlrpc_client::return_type</varname> class variable, a new\r
2820         class variable has been added to the server class:\r
2821         <varname>functions_parameters_type</varname>. When set to 'phpvals',\r
2822         the functions registered in the server dispatch map will be called\r
2823         with plain php values as parameters, instead of a single xmlrpcmsg\r
2824         instance parameter. The return value of those functions is expected to\r
2825         be a plain php value, too. An example is worth a thousand\r
2826         words:<programlisting language="php">\r
2827   function foo($usr_id, $out_lang='en') {\r
2828     global $xmlrpcerruser;\r
2829 \r
2830     ...\r
2831 \r
2832     if ($someErrorCondition)\r
2833       return new xmlrpcresp(0, $xmlrpcerruser+1, 'DOH!');\r
2834     else\r
2835       return array(\r
2836         'name' =&gt; 'Joe',\r
2837         'age' =&gt; 27,\r
2838         'picture' =&gt; new xmlrpcval(file_get_contents($picOfTheGuy), 'base64')\r
2839       );\r
2840   }\r
2841 \r
2842   $s = new xmlrpc_server(\r
2843     array(\r
2844       "examples.myFunc" =&gt; array(\r
2845         "function" =&gt; "bar::foobar",\r
2846         "signature" =&gt; array(\r
2847           array($xmlrpcString, $xmlrpcInt),\r
2848           array($xmlrpcString, $xmlrpcInt, $xmlrpcString)\r
2849         )\r
2850       )\r
2851     ), false);\r
2852   $s-&gt;functions_parameters_type = 'phpvals';\r
2853   $s-&gt;service();\r
2854 </programlisting>There are a few things to keep in mind when using this\r
2855         simplified syntax:</para>\r
2856 \r
2857         <para>to return an xmlrpc error, the method handler function must\r
2858         return an instance of xmlrpcresp. There is no other way for the server\r
2859         to know when an error response should be served to the client;</para>\r
2860 \r
2861         <para>to return a base64 value, the method handler function must\r
2862         encode it on its own, creating an instance of an xmlrpcval\r
2863         object;</para>\r
2864 \r
2865         <para>the method handler function cannot determine the name of the\r
2866         xmlrpc method it is serving, unlike standard handler functions that\r
2867         can retrieve it from the message object;</para>\r
2868 \r
2869         <para>when receiving nested parameters, the method handler function\r
2870         has no way to distinguish a php string that was sent as base64 value\r
2871         from one that was sent as a string value;</para>\r
2872 \r
2873         <para>this has a direct consequence on the support of\r
2874         system.multicall: a method whose signature contains datetime or base64\r
2875         values will not be available to multicall calls;</para>\r
2876 \r
2877         <para>last but not least, the direct parsing of xml to php values is\r
2878         much faster than using xmlrpcvals, and allows the library to handle\r
2879         much bigger messages without allocating all available server memory or\r
2880         smashing PHP recursive call stack.</para>\r
2881       </sect2>\r
2882     </sect1>\r
2883   </chapter>\r
2884 \r
2885   <chapter id="globalvars">\r
2886     <title>Global variables</title>\r
2887 \r
2888     <para>Many global variables are defined in the xmlrpc.inc file. Some of\r
2889     those are meant to be used as constants (and modifying their value might\r
2890     cause unpredictable behaviour), while some others can be modified in your\r
2891     php scripts to alter the behaviour of the xml-rpc client and\r
2892     server.</para>\r
2893 \r
2894     <sect1>\r
2895       <title>"Constant" variables</title>\r
2896 \r
2897       <sect2>\r
2898         <title>$xmlrpcerruser</title>\r
2899 \r
2900         <para><fieldsynopsis>\r
2901             <varname>$xmlrpcerruser</varname>\r
2902 \r
2903             <initializer>800</initializer>\r
2904           </fieldsynopsis>The minimum value for errors reported by user\r
2905         implemented XML-RPC servers. Error numbers lower than that are\r
2906         reserved for library usage.</para>\r
2907       </sect2>\r
2908 \r
2909       <sect2>\r
2910         <title>$xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble,\r
2911         $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray,\r
2912         $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull</title>\r
2913 \r
2914         <para>For convenience the strings representing the XML-RPC types have\r
2915         been encoded as global variables:<programlisting language="php">\r
2916 $xmlrpcI4="i4";\r
2917 $xmlrpcInt="int";\r
2918 $xmlrpcBoolean="boolean";\r
2919 $xmlrpcDouble="double";\r
2920 $xmlrpcString="string";\r
2921 $xmlrpcDateTime="dateTime.iso8601";\r
2922 $xmlrpcBase64="base64";\r
2923 $xmlrpcArray="array";\r
2924 $xmlrpcStruct="struct";\r
2925 $xmlrpcValue="undefined";\r
2926 $xmlrpcNull="null";\r
2927 </programlisting></para>\r
2928       </sect2>\r
2929 \r
2930       <sect2>\r
2931         <title>$xmlrpcTypes, $xmlrpc_valid_parents, $xmlrpcerr, $xmlrpcstr,\r
2932         $xmlrpcerrxml, $xmlrpc_backslash, $_xh, $xml_iso88591_Entities,\r
2933         $xmlEntities, $xmlrpcs_capabilities</title>\r
2934 \r
2935         <para>Reserved for internal usage.</para>\r
2936       </sect2>\r
2937     </sect1>\r
2938 \r
2939     <sect1>\r
2940       <title>Variables whose value can be modified</title>\r
2941 \r
2942       <sect2 id="xmlrpc-defencoding" xreflabel="xmlrpc_defencoding">\r
2943         <title xreflabel="">xmlrpc_defencoding</title>\r
2944 \r
2945         <fieldsynopsis>\r
2946           <varname>$xmlrpc_defencoding</varname>\r
2947 \r
2948           <initializer>"UTF8"</initializer>\r
2949         </fieldsynopsis>\r
2950 \r
2951         <para>This variable defines the character set encoding that will be\r
2952         used by the xml-rpc client and server to decode the received messages,\r
2953         when a specific charset declaration is not found (in the messages sent\r
2954         non-ascii chars are always encoded using character references, so that\r
2955         the produced xml is valid regardless of the charset encoding\r
2956         assumed).</para>\r
2957 \r
2958         <para>Allowed values: <literal>"UTF8"</literal>,\r
2959         <literal>"ISO-8859-1"</literal>, <literal>"ASCII".</literal></para>\r
2960 \r
2961         <para>Note that the appropriate RFC actually mandates that XML\r
2962         received over HTTP without indication of charset encoding be treated\r
2963         as US-ASCII, but many servers and clients 'in the wild' violate the\r
2964         standard, and assume the default encoding is UTF-8.</para>\r
2965       </sect2>\r
2966 \r
2967       <sect2>\r
2968         <title>xmlrpc_internalencoding</title>\r
2969 \r
2970         <para><fieldsynopsis>\r
2971             <varname>$xmlrpc_internalencoding</varname>\r
2972 \r
2973             <initializer>"ISO-8859-1"</initializer>\r
2974           </fieldsynopsis>This variable defines the character set encoding\r
2975         that the library uses to transparently encode into valid XML the\r
2976         xml-rpc values created by the user and to re-encode the received\r
2977         xml-rpc values when it passes them to the PHP application. It only\r
2978         affects xml-rpc values of string type. It is a separate value from\r
2979         xmlrpc_defencoding, allowing e.g. to send/receive xml messages encoded\r
2980         on-the-wire in US-ASCII and process them as UTF-8. It defaults to the\r
2981         character set used internally by PHP (unless you are running an\r
2982         MBString-enabled installation), so you should change it only in\r
2983         special situations, if e.g. the string values exchanged in the xml-rpc\r
2984         messages are directly inserted into / fetched from a database\r
2985         configured to return UTF8 encoded strings to PHP. Example\r
2986         usage:</para>\r
2987 \r
2988         <para><programlisting language="php">\r
2989 &lt;?php\r
2990 \r
2991 include('xmlrpc.inc');\r
2992 $xmlrpc_internalencoding = 'UTF-8'; // this has to be set after the inclusion above\r
2993 $v = new xmlrpcval('κόÏ\83με'); // This xmlrpc value will be correctly serialized as the greek word 'kosme'\r
2994 </programlisting></para>\r
2995       </sect2>\r
2996 \r
2997       <sect2>\r
2998         <title>xmlrpcName</title>\r
2999 \r
3000         <para><fieldsynopsis>\r
3001             <varname>$xmlrpcName</varname>\r
3002 \r
3003             <initializer>"XML-RPC for PHP"</initializer>\r
3004           </fieldsynopsis>The string representation of the name of the XML-RPC\r
3005         for PHP library. It is used by the client for building the User-Agent\r
3006         HTTP header that is sent with every request to the server. You can\r
3007         change its value if you need to customize the User-Agent\r
3008         string.</para>\r
3009       </sect2>\r
3010 \r
3011       <sect2>\r
3012         <title>xmlrpcVersion</title>\r
3013 \r
3014         <para><fieldsynopsis>\r
3015             <varname>$xmlrpcVersion</varname>\r
3016 \r
3017             <initializer>"2.2"</initializer>\r
3018           </fieldsynopsis>The string representation of the version number of\r
3019         the XML-RPC for PHP library in use. It is used by the client for\r
3020         building the User-Agent HTTP header that is sent with every request to\r
3021         the server. You can change its value if you need to customize the\r
3022         User-Agent string.</para>\r
3023       </sect2>\r
3024 \r
3025       <sect2>\r
3026         <title>xmlrpc_null_extension</title>\r
3027 \r
3028         <para>When set to <constant>TRUE</constant>, the lib will enable\r
3029         support for the &lt;NIL/&gt; xmlrpc value, as per the extension to the\r
3030         standard proposed here. This means that &lt;NIL/&gt; tags will be\r
3031         parsed as valid xmlrpc, and the corresponding xmlrpcvals will return\r
3032         "null" for <methodname>scalarTyp()</methodname>.</para>\r
3033       </sect2>\r
3034     </sect1>\r
3035   </chapter>\r
3036 \r
3037   <chapter id="helpers">\r
3038     <title>Helper functions</title>\r
3039 \r
3040     <para>XML-RPC for PHP contains some helper functions which you can use to\r
3041     make processing of XML-RPC requests easier.</para>\r
3042 \r
3043     <sect1>\r
3044       <title>Date functions</title>\r
3045 \r
3046       <para>The XML-RPC specification has this to say on dates:</para>\r
3047 \r
3048       <blockquote>\r
3049         <para id="wrap_xmlrpc_method">Don't assume a timezone. It should be\r
3050         specified by the server in its documentation what assumptions it makes\r
3051         about timezones.</para>\r
3052       </blockquote>\r
3053 \r
3054       <para>Unfortunately, this means that date processing isn't\r
3055       straightforward. Although XML-RPC uses ISO 8601 format dates, it doesn't\r
3056       use the timezone specifier.</para>\r
3057 \r
3058       <para>We strongly recommend that in every case where you pass dates in\r
3059       XML-RPC calls, you use UTC (GMT) as your timezone. Most computer\r
3060       languages include routines for handling GMT times natively, and you\r
3061       won't have to translate between timezones.</para>\r
3062 \r
3063       <para>For more information about dates, see <ulink\r
3064       url="http://www.uic.edu/year2000/datefmt.html">ISO 8601: The Right\r
3065       Format for Dates</ulink>, which has a handy link to a PDF of the ISO\r
3066       8601 specification. Note that XML-RPC uses exactly one of the available\r
3067       representations: CCYYMMDDTHH:MM:SS.</para>\r
3068 \r
3069       <sect2 id="iso8601encode" xreflabel="iso8601_encode()">\r
3070         <title>iso8601_encode</title>\r
3071 \r
3072         <funcsynopsis>\r
3073           <funcprototype>\r
3074             <funcdef><type>string</type><function>iso8601_encode</function></funcdef>\r
3075 \r
3076             <paramdef><type>string</type><parameter>$time_t</parameter></paramdef>\r
3077 \r
3078             <paramdef\r
3079             choice="opt"><type>int</type><parameter>$utc</parameter><initializer>0</initializer></paramdef>\r
3080           </funcprototype>\r
3081         </funcsynopsis>\r
3082 \r
3083         <para>Returns an ISO 8601 formatted date generated from the UNIX\r
3084         timestamp <parameter>$time_t</parameter>, as returned by the PHP\r
3085         function <function>time()</function>.</para>\r
3086 \r
3087         <para>The argument <parameter>$utc</parameter> can be omitted, in\r
3088         which case it defaults to <literal>0</literal>. If it is set to\r
3089         <literal>1</literal>, then the function corrects the time passed in\r
3090         for UTC. Example: if you're in the GMT-6:00 timezone and set\r
3091         <parameter>$utc</parameter>, you will receive a date representation\r
3092         six hours ahead of your local time.</para>\r
3093 \r
3094         <para>The included demo program <filename>vardemo.php</filename>\r
3095         includes a demonstration of this function.</para>\r
3096       </sect2>\r
3097 \r
3098       <sect2 id="iso8601decode" xreflabel="iso8601_decode()">\r
3099         <title>iso8601_decode</title>\r
3100 \r
3101         <funcsynopsis>\r
3102           <funcprototype>\r
3103             <funcdef><type>int</type><function>iso8601_decode</function></funcdef>\r
3104 \r
3105             <paramdef><type>string</type><parameter>$isoString</parameter></paramdef>\r
3106 \r
3107             <paramdef><type>int</type><parameter>$utc</parameter><initializer>0</initializer></paramdef>\r
3108           </funcprototype>\r
3109         </funcsynopsis>\r
3110 \r
3111         <para>Returns a UNIX timestamp from an ISO 8601 encoded time and date\r
3112         string passed in. If <parameter>$utc</parameter> is\r
3113         <literal>1</literal> then <parameter>$isoString</parameter> is assumed\r
3114         to be in the UTC timezone, and thus the result is also UTC: otherwise,\r
3115         the timezone is assumed to be your local timezone and you receive a\r
3116         local timestamp.</para>\r
3117       </sect2>\r
3118     </sect1>\r
3119 \r
3120     <sect1 id="arrayuse">\r
3121       <title>Easy use with nested PHP values</title>\r
3122 \r
3123       <para>Dan Libby was kind enough to contribute two helper functions that\r
3124       make it easier to translate to and from PHP values. This makes it easier\r
3125       to deal with complex structures. At the moment support is limited to\r
3126       <type>int</type>, <type>double</type>, <type>string</type>,\r
3127       <type>array</type>, <type>datetime</type> and <type>struct</type>\r
3128       datatypes; note also that all PHP arrays are encoded as structs, except\r
3129       arrays whose keys are integer numbers starting with 0 and incremented by\r
3130       1.</para>\r
3131 \r
3132       <para>These functions reside in <filename>xmlrpc.inc</filename>.</para>\r
3133 \r
3134       <sect2 id="phpxmlrpcdecode">\r
3135         <title>php_xmlrpc_decode</title>\r
3136 \r
3137         <funcsynopsis>\r
3138           <funcprototype>\r
3139             <funcdef><type>mixed</type><function>php_xmlrpc_decode</function></funcdef>\r
3140 \r
3141             <paramdef><type>xmlrpcval</type><parameter>$xmlrpc_val</parameter></paramdef>\r
3142 \r
3143             <paramdef><type>array</type><parameter>$options</parameter></paramdef>\r
3144           </funcprototype>\r
3145 \r
3146           <funcprototype>\r
3147             <funcdef><type>array</type><function>php_xmlrpc_decode</function></funcdef>\r
3148 \r
3149             <paramdef><type>xmlrpcmsg</type><parameter>$xmlrpcmsg_val</parameter></paramdef>\r
3150 \r
3151             <paramdef><type>string</type><parameter>$options</parameter></paramdef>\r
3152           </funcprototype>\r
3153         </funcsynopsis>\r
3154 \r
3155         <para>Returns a native PHP value corresponding to the values found in\r
3156         the <type>xmlrpcval</type> <parameter>$xmlrpc_val</parameter>,\r
3157         translated into PHP types. Base-64 and datetime values are\r
3158         automatically decoded to strings.</para>\r
3159 \r
3160         <para>In the second form, returns an array containing the parameters\r
3161         of the given\r
3162         <parameter><classname>xmlrpcmsg</classname>_val</parameter>, decoded\r
3163         to php types.</para>\r
3164 \r
3165         <para>The <parameter>options</parameter> parameter is optional. If\r
3166         specified, it must consist of an array of options to be enabled in the\r
3167         decoding process. At the moment the only valid option is\r
3168         <symbol>decode_php_objs</symbol>. When it is set, php objects that\r
3169         have been converted to xml-rpc structs using the\r
3170         <function>php_xmlrpc_encode</function> function and a corresponding\r
3171         encoding option will be converted back into object values instead of\r
3172         arrays (provided that the class definition is available at\r
3173         reconstruction time).</para>\r
3174 \r
3175         <para><emphasis><emphasis>WARNING</emphasis>:</emphasis> please take\r
3176         extreme care before enabling the <symbol>decode_php_objs</symbol>\r
3177         option: when php objects are rebuilt from the received xml, their\r
3178         constructor function will be silently invoked. This means that you are\r
3179         allowing the remote end to trigger execution of uncontrolled PHP code\r
3180         on your server, opening the door to code injection exploits. Only\r
3181         enable this option when you have complete trust of the remote\r
3182         server/client.</para>\r
3183 \r
3184         <para>Example:<programlisting language="php">\r
3185 // wrapper to expose an existing php function as xmlrpc method handler\r
3186 function foo_wrapper($m)\r
3187 {\r
3188   $params = php_xmlrpc_decode($m);\r
3189   $retval = call_user_func_array('foo', $params);\r
3190   return new xmlrpcresp(new xmlrpcval($retval)); // foo return value will be serialized as string\r
3191 }\r
3192 \r
3193 $s = new xmlrpc_server(array(\r
3194    "examples.myFunc1" =&gt; array(\r
3195      "function" =&gt; "foo_wrapper",\r
3196      "signatures" =&gt; ...\r
3197   )));\r
3198 </programlisting></para>\r
3199       </sect2>\r
3200 \r
3201       <sect2 id="phpxmlrpcencode">\r
3202         <title>php_xmlrpc_encode</title>\r
3203 \r
3204         <funcsynopsis>\r
3205           <funcprototype>\r
3206             <funcdef><type>xmlrpcval</type><function>php_xmlrpc_encode</function></funcdef>\r
3207 \r
3208             <paramdef><type>mixed</type><parameter>$phpval</parameter></paramdef>\r
3209 \r
3210             <paramdef><type>array</type><parameter>$options</parameter></paramdef>\r
3211           </funcprototype>\r
3212         </funcsynopsis>\r
3213 \r
3214         <para>Returns an <type>xmlrpcval</type> object populated with the PHP\r
3215         values in <parameter>$phpval</parameter>. Works recursively on arrays\r
3216         and objects, encoding numerically indexed php arrays into array-type\r
3217         xmlrpcval objects and non numerically indexed php arrays into\r
3218         struct-type xmlrpcval objects. Php objects are encoded into\r
3219         struct-type xmlrpcvals, excepted for php values that are already\r
3220         instances of the xmlrpcval class or descendants thereof, which will\r
3221         not be further encoded. Note that there's no support for encoding php\r
3222         values into base-64 values. Encoding of date-times is optionally\r
3223         carried on on php strings with the correct format.</para>\r
3224 \r
3225         <para>The <parameter>options</parameter> parameter is optional. If\r
3226         specified, it must consist of an array of options to be enabled in the\r
3227         encoding process. At the moment the only valid options are\r
3228         <symbol>encode_php_objs</symbol> and\r
3229         <symbol>auto_dates</symbol>.</para>\r
3230 \r
3231         <para>The first will enable the creation of 'particular' xmlrpcval\r
3232         objects out of php objects, that add a "php_class" xml attribute to\r
3233         their serialized representation. This attribute allows the function\r
3234         php_xmlrpc_decode to rebuild the native php objects (provided that the\r
3235         same class definition exists on both sides of the\r
3236         communication)</para>\r
3237 \r
3238         <para>Example:<programlisting language="php">\r
3239 // the easy way to build a complex xml-rpc struct, showing nested base64 value and datetime values\r
3240 $val = php_xmlrpc_encode(array(\r
3241   'first struct_element: an int' =&gt; 666,\r
3242   'second: an array' =&gt; array ('apple', 'orange', 'banana'),\r
3243   'third: a base64 element' =&gt; new xmlrpcval('hello world', 'base64'),\r
3244   'fourth: a datetime' =&gt; '20060107T01:53:00'\r
3245   ), array('auto_dates'));\r
3246 </programlisting></para>\r
3247       </sect2>\r
3248 \r
3249       <sect2>\r
3250         <title>php_xmlrpc_decode_xml</title>\r
3251 \r
3252         <funcsynopsis>\r
3253           <funcprototype>\r
3254             <funcdef><type>xmlrpcval | xmlrpcresp |\r
3255             xmlrpcmsg</type><function>php_xmlrpc_decode_xml</function></funcdef>\r
3256 \r
3257             <paramdef><type>string</type><parameter>$xml</parameter></paramdef>\r
3258 \r
3259             <paramdef><type>array</type><parameter>$options</parameter></paramdef>\r
3260           </funcprototype>\r
3261         </funcsynopsis>\r
3262 \r
3263         <para>Decodes the xml representation of either an xmlrpc request,\r
3264         response or single value, returning the corresponding php-xmlrpc\r
3265         object, or <literal>FALSE</literal> in case of an error.</para>\r
3266 \r
3267         <para>The <parameter>options</parameter> parameter is optional. If\r
3268         specified, it must consist of an array of options to be enabled in the\r
3269         decoding process. At the moment, no option is supported.</para>\r
3270 \r
3271         <para>Example:<programlisting language="php">\r
3272 $text = '&lt;value&gt;&lt;array&gt;&lt;data&gt;&lt;value&gt;Hello world&lt;/value&gt;&lt;/data&gt;&lt;/array&gt;&lt;/value&gt;';\r
3273 $val = php_xmlrpc_decode_xml($text);\r
3274 if ($val) echo 'Found a value of type '.$val-&gt;kindOf(); else echo 'Found invalid xml';\r
3275 </programlisting></para>\r
3276       </sect2>\r
3277     </sect1>\r
3278 \r
3279     <sect1>\r
3280       <title>Automatic conversion of php functions into xmlrpc methods (and\r
3281       vice versa)</title>\r
3282 \r
3283       <para>For the extremely lazy coder, helper functions have been added\r
3284       that allow to convert a php function into an xmlrpc method, and a\r
3285       remotely exposed xmlrpc method into a local php function - or a set of\r
3286       methods into a php class. Note that these comes with many caveat.</para>\r
3287 \r
3288       <sect2>\r
3289         <title>wrap_xmlrpc_method</title>\r
3290 \r
3291         <funcsynopsis>\r
3292           <funcprototype>\r
3293             <funcdef><type>string</type><function>wrap_xmlrpc_method</function></funcdef>\r
3294 \r
3295             <paramdef>$client</paramdef>\r
3296 \r
3297             <paramdef>$methodname</paramdef>\r
3298 \r
3299             <paramdef>$extra_options</paramdef>\r
3300           </funcprototype>\r
3301 \r
3302           <funcprototype>\r
3303             <funcdef><type>string</type><function>wrap_xmlrpc_method</function></funcdef>\r
3304 \r
3305             <paramdef>$client</paramdef>\r
3306 \r
3307             <paramdef>$methodname</paramdef>\r
3308 \r
3309             <paramdef>$signum</paramdef>\r
3310 \r
3311             <paramdef>$timeout</paramdef>\r
3312 \r
3313             <paramdef>$protocol</paramdef>\r
3314 \r
3315             <paramdef>$funcname</paramdef>\r
3316           </funcprototype>\r
3317         </funcsynopsis>\r
3318 \r
3319         <para>Given an xmlrpc server and a method name, creates a php wrapper\r
3320         function that will call the remote method and return results using\r
3321         native php types for both params and results. The generated php\r
3322         function will return an xmlrpcresp object for failed xmlrpc\r
3323         calls.</para>\r
3324 \r
3325         <para>The second syntax is deprecated, and is listed here only for\r
3326         backward compatibility.</para>\r
3327 \r
3328         <para>The server must support the\r
3329         <methodname>system.methodSignature</methodname> xmlrpc method call for\r
3330         this function to work.</para>\r
3331 \r
3332         <para>The <parameter>client</parameter> param must be a valid\r
3333         xmlrpc_client object, previously created with the address of the\r
3334         target xmlrpc server, and to which the preferred communication options\r
3335         have been set.</para>\r
3336 \r
3337         <para>The optional parameters can be passed as array key,value pairs\r
3338         in the <parameter>extra_options</parameter> param.</para>\r
3339 \r
3340         <para>The <parameter>signum</parameter> optional param has the purpose\r
3341         of indicating which method signature to use, if the given server\r
3342         method has multiple signatures (defaults to 0).</para>\r
3343 \r
3344         <para>The <parameter>timeout</parameter> and\r
3345         <parameter>protocol</parameter> optional params are the same as in the\r
3346         <methodname>xmlrpc_client::send()</methodname> method.</para>\r
3347 \r
3348         <para>If set, the optional <parameter>new_function_name</parameter>\r
3349         parameter indicates which name should be used for the generated\r
3350         function. In case it is not set the function name will be\r
3351         auto-generated.</para>\r
3352 \r
3353         <para>If the <literal>return_source</literal> optional parameter is\r
3354         set, the function will return the php source code to build the wrapper\r
3355         function, instead of evaluating it (useful to save the code and use it\r
3356         later as stand-alone xmlrpc client).</para>\r
3357 \r
3358         <para>If the <literal>encode_php_objs</literal> optional parameter is\r
3359         set, instances of php objects later passed as parameters to the newly\r
3360         created function will receive a 'special' treatment that allows the\r
3361         server to rebuild them as php objects instead of simple arrays. Note\r
3362         that this entails using a "slightly augmented" version of the xmlrpc\r
3363         protocol (ie. using element attributes), which might not be understood\r
3364         by xmlrpc servers implemented using other libraries.</para>\r
3365 \r
3366         <para>If the <literal>decode_php_objs</literal> optional parameter is\r
3367         set, instances of php objects that have been appropriately encoded by\r
3368         the server using a coordinate option will be deserialized as php\r
3369         objects instead of simple arrays (the same class definition should be\r
3370         present server side and client side).</para>\r
3371 \r
3372         <para><emphasis>Note that this might pose a security risk</emphasis>,\r
3373         since in order to rebuild the object instances their constructor\r
3374         method has to be invoked, and this means that the remote server can\r
3375         trigger execution of unforeseen php code on the client: not really a\r
3376         code injection, but almost. Please enable this option only when you\r
3377         trust the remote server.</para>\r
3378 \r
3379         <para>In case of an error during generation of the wrapper function,\r
3380         FALSE is returned, otherwise the name (or source code) of the new\r
3381         function.</para>\r
3382 \r
3383         <para>Known limitations: server must support\r
3384         <methodname>system.methodsignature</methodname> for the wanted xmlrpc\r
3385         method; for methods that expose multiple signatures, only one can be\r
3386         picked; for remote calls with nested xmlrpc params, the caller of the\r
3387         generated php function has to encode on its own the params passed to\r
3388         the php function if these are structs or arrays whose (sub)members\r
3389         include values of type base64.</para>\r
3390 \r
3391         <para>Note: calling the generated php function 'might' be slow: a new\r
3392         xmlrpc client is created on every invocation and an xmlrpc-connection\r
3393         opened+closed. An extra 'debug' param is appended to the parameter\r
3394         list of the generated php function, useful for debugging\r
3395         purposes.</para>\r
3396 \r
3397         <para>Example usage:</para>\r
3398 \r
3399         <programlisting language="php">\r
3400 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');\r
3401 \r
3402 $function = wrap_xmlrpc_method($client, 'examples.getStateName');\r
3403 \r
3404 if (!$function)\r
3405   die('Cannot introspect remote method');\r
3406 else {\r
3407   $stateno = 15;\r
3408   $statename = $function($a);\r
3409   if (is_a($statename, 'xmlrpcresp')) // call failed\r
3410   {\r
3411     echo 'Call failed: '.$statename-&gt;faultCode().'. Calling again with debug on';\r
3412     $function($a, true);\r
3413   }\r
3414   else\r
3415     echo "OK, state nr. $stateno is $statename";\r
3416 }\r
3417 </programlisting>\r
3418       </sect2>\r
3419 \r
3420       <sect2 id="wrap_php_function">\r
3421         <title>wrap_php_function</title>\r
3422 \r
3423         <funcsynopsis>\r
3424           <funcprototype>\r
3425             <funcdef><type>array</type><function>wrap_php_function</function></funcdef>\r
3426 \r
3427             <paramdef><type>string</type><parameter>$funcname</parameter></paramdef>\r
3428 \r
3429             <paramdef><type>string</type><parameter>$wrapper_function_name</parameter></paramdef>\r
3430 \r
3431             <paramdef><type>array</type><parameter>$extra_options</parameter></paramdef>\r
3432           </funcprototype>\r
3433         </funcsynopsis>\r
3434 \r
3435         <para>Given a user-defined PHP function, create a PHP 'wrapper'\r
3436         function that can be exposed as xmlrpc method from an xmlrpc_server\r
3437         object and called from remote clients, and return the appropriate\r
3438         definition to be added to a server's dispatch map.</para>\r
3439 \r
3440         <para>The optional <parameter>$wrapper_function_name</parameter>\r
3441         specifies the name that will be used for the auto-generated\r
3442         function.</para>\r
3443 \r
3444         <para>Since php is a typeless language, to infer types of input and\r
3445         output parameters, it relies on parsing the javadoc-style comment\r
3446         block associated with the given function. Usage of xmlrpc native types\r
3447         (such as datetime.dateTime.iso8601 and base64) in the docblock @param\r
3448         tag is also allowed, if you need the php function to receive/send data\r
3449         in that particular format (note that base64 encoding/decoding is\r
3450         transparently carried out by the lib, while datetime vals are passed\r
3451         around as strings).</para>\r
3452 \r
3453         <para>Known limitations: requires PHP 5.0.3 +; only works for\r
3454         user-defined functions, not for PHP internal functions (reflection\r
3455         does not support retrieving number/type of params for those); the\r
3456         wrapped php function will not be able to programmatically return an\r
3457         xmlrpc error response.</para>\r
3458 \r
3459         <para>If the <literal>return_source</literal> optional parameter is\r
3460         set, the function will return the php source code to build the wrapper\r
3461         function, instead of evaluating it (useful to save the code and use it\r
3462         later in a stand-alone xmlrpc server). It will be in the stored in the\r
3463         <literal>source</literal> member of the returned array.</para>\r
3464 \r
3465         <para>If the <literal>suppress_warnings</literal> optional parameter\r
3466         is set, any runtime warning generated while processing the\r
3467         user-defined php function will be catched and not be printed in the\r
3468         generated xml response.</para>\r
3469 \r
3470         <para>If the <parameter>extra_options</parameter> array contains the\r
3471         <literal>encode_php_objs</literal> value, wrapped functions returning\r
3472         php objects will generate "special" xmlrpc responses: when the xmlrpc\r
3473         decoding of those responses is carried out by this same lib, using the\r
3474         appropriate param in php_xmlrpc_decode(), the objects will be\r
3475         rebuilt.</para>\r
3476 \r
3477         <para>In short: php objects can be serialized, too (except for their\r
3478         resource members), using this function. Other libs might choke on the\r
3479         very same xml that will be generated in this case (i.e. it has a\r
3480         nonstandard attribute on struct element tags)</para>\r
3481 \r
3482         <para>If the <literal>decode_php_objs</literal> optional parameter is\r
3483         set, instances of php objects that have been appropriately encoded by\r
3484         the client using a coordinate option will be deserialized and passed\r
3485         to the user function as php objects instead of simple arrays (the same\r
3486         class definition should be present server side and client\r
3487         side).</para>\r
3488 \r
3489         <para><emphasis>Note that this might pose a security risk</emphasis>,\r
3490         since in order to rebuild the object instances their constructor\r
3491         method has to be invoked, and this means that the remote client can\r
3492         trigger execution of unforeseen php code on the server: not really a\r
3493         code injection, but almost. Please enable this option only when you\r
3494         trust the remote clients.</para>\r
3495 \r
3496         <para>Example usage:</para>\r
3497 \r
3498         <para><programlisting language="php">/**\r
3499 * State name from state number decoder. NB: do NOT remove this comment block.\r
3500 * @param integer $stateno the state number\r
3501 * @return string the name of the state (or error description)\r
3502 */\r
3503 function findstate($stateno)\r
3504 {\r
3505   global $stateNames;\r
3506   if (isset($stateNames[$stateno-1]))\r
3507   {\r
3508     return $stateNames[$stateno-1];\r
3509   }\r
3510   else\r
3511   {\r
3512     return "I don't have a state for the index '" . $stateno . "'";\r
3513   }\r
3514 }\r
3515 \r
3516 // wrap php function, build xmlrpc server\r
3517 $methods = array();\r
3518 $findstate_sig = wrap_php_function('findstate');\r
3519 if ($findstate_sig)\r
3520   $methods['examples.getStateName'] = $findstate_sig;\r
3521 $srv = new xmlrpc_server($methods);\r
3522 </programlisting></para>\r
3523       </sect2>\r
3524     </sect1>\r
3525 \r
3526     <sect1 id="deprecated">\r
3527       <title>Functions removed from the library</title>\r
3528 \r
3529       <para>The following two functions have been deprecated in version 1.1 of\r
3530       the library, and removed in version 2, in order to avoid conflicts with\r
3531       the EPI xml-rpc library, which also defines two functions with the same\r
3532       names.</para>\r
3533 \r
3534       <para>To ease the transition to the new naming scheme and avoid breaking\r
3535       existing implementations, the following scheme has been adopted:\r
3536       <itemizedlist>\r
3537           <listitem>\r
3538             <para>If EPI-XMLRPC is not active in the current PHP installation,\r
3539             the constant <literal>XMLRPC_EPI_ENABLED</literal> will be set to\r
3540             <literal>'0'</literal></para>\r
3541           </listitem>\r
3542 \r
3543           <listitem>\r
3544             <para>If EPI-XMLRPC is active in the current PHP installation, the\r
3545             constant <literal>XMLRPC_EPI_ENABLED</literal> will be set to\r
3546             <literal>'1'</literal></para>\r
3547           </listitem>\r
3548         </itemizedlist></para>\r
3549 \r
3550       <para>The following documentation is kept for historical\r
3551       reference:</para>\r
3552 \r
3553       <sect2 id="xmlrpcdecode">\r
3554         <title>xmlrpc_decode</title>\r
3555 \r
3556         <funcsynopsis>\r
3557           <funcprototype>\r
3558             <funcdef><type>mixed</type><function>xmlrpc_decode</function></funcdef>\r
3559 \r
3560             <paramdef><type>xmlrpcval</type><parameter>$xmlrpc_val</parameter></paramdef>\r
3561           </funcprototype>\r
3562         </funcsynopsis>\r
3563 \r
3564         <para>Alias for php_xmlrpc_decode.</para>\r
3565       </sect2>\r
3566 \r
3567       <sect2 id="xmlrpcencode">\r
3568         <title>xmlrpc_encode</title>\r
3569 \r
3570         <funcsynopsis>\r
3571           <funcprototype>\r
3572             <funcdef><type>xmlrpcval</type><function>xmlrpc_encode</function></funcdef>\r
3573 \r
3574             <paramdef><type>mixed</type><parameter>$phpval</parameter></paramdef>\r
3575           </funcprototype>\r
3576         </funcsynopsis>\r
3577 \r
3578         <para>Alias for php_xmlrpc_encode.</para>\r
3579       </sect2>\r
3580     </sect1>\r
3581 \r
3582     <sect1 id="debugging">\r
3583       <title>Debugging aids</title>\r
3584 \r
3585       <sect2>\r
3586         <title>xmlrpc_debugmsg</title>\r
3587 \r
3588         <funcsynopsis>\r
3589           <funcprototype>\r
3590             <funcdef><type>void</type><function>xmlrpc_debugmsg</function></funcdef>\r
3591 \r
3592             <paramdef><type>string</type><parameter>$debugstring</parameter></paramdef>\r
3593           </funcprototype>\r
3594         </funcsynopsis>\r
3595 \r
3596         <para>Sends the contents of <parameter>$debugstring</parameter> in XML\r
3597         comments in the server return payload. If a PHP client has debugging\r
3598         turned on, the user will be able to see server debug\r
3599         information.</para>\r
3600 \r
3601         <para>Use this function in your methods so you can pass back\r
3602         diagnostic information. It is only available from\r
3603         <filename>xmlrpcs.inc</filename>.</para>\r
3604       </sect2>\r
3605     </sect1>\r
3606   </chapter>\r
3607 \r
3608   <chapter id="reserved" xreflabel="Reserved methods">\r
3609     <title>Reserved methods</title>\r
3610 \r
3611     <para>In order to extend the functionality offered by XML-RPC servers\r
3612     without impacting on the protocol, reserved methods are supported in this\r
3613     release.</para>\r
3614 \r
3615     <para>All methods starting with <function>system.</function> are\r
3616     considered reserved by the server. PHP for XML-RPC itself provides four\r
3617     special methods, detailed in this chapter.</para>\r
3618 \r
3619     <para>Note that all server objects will automatically respond to clients\r
3620     querying these methods, unless the property\r
3621     <property>allow_system_funcs</property> has been set to\r
3622     <constant>false</constant> before calling the\r
3623     <methodname>service()</methodname> method. This might pose a security risk\r
3624     if the server is exposed to public access, e.g. on the internet.</para>\r
3625 \r
3626     <sect1>\r
3627       <title>system.getCapabilities</title>\r
3628 \r
3629       <para></para>\r
3630     </sect1>\r
3631 \r
3632     <sect1>\r
3633       <title>system.listMethods</title>\r
3634 \r
3635       <para>This method may be used to enumerate the methods implemented by\r
3636       the XML-RPC server.</para>\r
3637 \r
3638       <para>The <function>system.listMethods</function> method requires no\r
3639       parameters. It returns an array of strings, each of which is the name of\r
3640       a method implemented by the server.</para>\r
3641     </sect1>\r
3642 \r
3643     <sect1 id="sysmethodsig">\r
3644       <title>system.methodSignature</title>\r
3645 \r
3646       <para>This method takes one parameter, the name of a method implemented\r
3647       by the XML-RPC server.</para>\r
3648 \r
3649       <para>It returns an array of possible signatures for this method. A\r
3650       signature is an array of types. The first of these types is the return\r
3651       type of the method, the rest are parameters.</para>\r
3652 \r
3653       <para>Multiple signatures (i.e. overloading) are permitted: this is the\r
3654       reason that an array of signatures are returned by this method.</para>\r
3655 \r
3656       <para>Signatures themselves are restricted to the top level parameters\r
3657       expected by a method. For instance if a method expects one array of\r
3658       structs as a parameter, and it returns a string, its signature is simply\r
3659       "string, array". If it expects three integers, its signature is "string,\r
3660       int, int, int".</para>\r
3661 \r
3662       <para>For parameters that can be of more than one type, the "undefined"\r
3663       string is supported.</para>\r
3664 \r
3665       <para>If no signature is defined for the method, a not-array value is\r
3666       returned. Therefore this is the way to test for a non-signature, if\r
3667       <parameter>$resp</parameter> below is the response object from a method\r
3668       call to <function>system.methodSignature</function>:</para>\r
3669 \r
3670       <programlisting language="php">\r
3671 $v = $resp-&gt;value();\r
3672 if ($v-&gt;kindOf() != "array") {\r
3673   // then the method did not have a signature defined\r
3674 }\r
3675 </programlisting>\r
3676 \r
3677       <para>See the <filename>introspect.php</filename> demo included in this\r
3678       distribution for an example of using this method.</para>\r
3679     </sect1>\r
3680 \r
3681     <sect1 id="sysmethhelp">\r
3682       <title>system.methodHelp</title>\r
3683 \r
3684       <para>This method takes one parameter, the name of a method implemented\r
3685       by the XML-RPC server.</para>\r
3686 \r
3687       <para>It returns a documentation string describing the use of that\r
3688       method. If no such string is available, an empty string is\r
3689       returned.</para>\r
3690 \r
3691       <para>The documentation string may contain HTML markup.</para>\r
3692     </sect1>\r
3693 \r
3694     <sect1>\r
3695       <title>system.multicall</title>\r
3696 \r
3697       <para>This method takes one parameter, an array of 'request' struct\r
3698       types. Each request struct must contain a\r
3699       <parameter>methodName</parameter> member of type string and a\r
3700       <parameter>params</parameter> member of type array, and corresponds to\r
3701       the invocation of the corresponding method.</para>\r
3702 \r
3703       <para>It returns a response of type array, with each value of the array\r
3704       being either an error struct (containing the faultCode and faultString\r
3705       members) or the successful response value of the corresponding single\r
3706       method call.</para>\r
3707     </sect1>\r
3708   </chapter>\r
3709 \r
3710   <chapter id="examples" xreflabel="Examples">\r
3711     <title>Examples</title>\r
3712 \r
3713     <para>The best examples are to be found in the sample files included with\r
3714     the distribution. Some are included here.</para>\r
3715 \r
3716     <sect1 id="statename">\r
3717       <title>XML-RPC client: state name query</title>\r
3718 \r
3719       <para>Code to get the corresponding state name from a number (1-50) from\r
3720       the demo server available on SourceForge</para>\r
3721 \r
3722       <programlisting language="php">\r
3723   $m = new xmlrpcmsg('examples.getStateName',\r
3724     array(new xmlrpcval($HTTP_POST_VARS["stateno"], "int")));\r
3725   $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);\r
3726   $r = $c-&gt;send($m);\r
3727   if (!$r-&gt;faultCode()) {\r
3728       $v = $r-&gt;value();\r
3729       print "State number " . htmlentities($HTTP_POST_VARS["stateno"]) . " is " .\r
3730         htmlentities($v-&gt;scalarval()) . "&lt;BR&gt;";\r
3731       print "&lt;HR&gt;I got this value back&lt;BR&gt;&lt;PRE&gt;" .\r
3732         htmlentities($r-&gt;serialize()) . "&lt;/PRE&gt;&lt;HR&gt;\n";\r
3733   } else {\r
3734       print "Fault &lt;BR&gt;";\r
3735       print "Code: " . htmlentities($r-&gt;faultCode()) . "&lt;BR&gt;" .\r
3736             "Reason: '" . htmlentities($r-&gt;faultString()) . "'&lt;BR&gt;";\r
3737   }\r
3738 </programlisting>\r
3739     </sect1>\r
3740 \r
3741     <sect1>\r
3742       <title>Executing a multicall call</title>\r
3743 \r
3744       <para>To be documented...</para>\r
3745     </sect1>\r
3746   </chapter>\r
3747 \r
3748   <chapter id="faq">\r
3749     <title>Frequently Asked Questions</title>\r
3750 \r
3751     <sect1>\r
3752       <title>How to send custom XML as payload of a method call</title>\r
3753 \r
3754       <para>Unfortunately, at the time the XML-RPC spec was designed, support\r
3755       for namespaces in XML was not as ubiquitous as it is now. As a\r
3756       consequence, no support was provided in the protocol for embedding XML\r
3757       elements from other namespaces into an xmlrpc request.</para>\r
3758 \r
3759       <para>To send an XML "chunk" as payload of a method call or response,\r
3760       two options are available: either send the complete XML block as a\r
3761       string xmlrpc value, or as a base64 value. Since the '&lt;' character in\r
3762       string values is encoded as '&amp;lt;' in the xml payload of the method\r
3763       call, the XML string will not break the surrounding xmlrpc, unless\r
3764       characters outside of the assumed character set are used. The second\r
3765       method has the added benefits of working independently of the charset\r
3766       encoding used for the xml to be transmitted, and preserving exactly\r
3767       whitespace, whilst incurring in some extra message length and cpu load\r
3768       (for carrying out the base64 encoding/decoding).</para>\r
3769     </sect1>\r
3770 \r
3771     <sect1>\r
3772       <title>Is there any limitation on the size of the requests / responses\r
3773       that can be successfully sent?</title>\r
3774 \r
3775       <para>Yes. But I have no hard figure to give; it most likely will depend\r
3776       on the version of PHP in usage and its configuration.</para>\r
3777 \r
3778       <para>Keep in mind that this library is not optimized for speed nor for\r
3779       memory usage. Better alternatives exist when there are strict\r
3780       requirements on throughput or resource usage, such as the php native\r
3781       xmlrpc extension (see the PHP manual for more information).</para>\r
3782 \r
3783       <para>Keep in mind also that HTTP is probably not the best choice in\r
3784       such a situation, and XML is a deadly enemy. CSV formatted data over\r
3785       socket would be much more efficient.</para>\r
3786 \r
3787       <para>If you really need to move a massive amount of data around, and\r
3788       you are crazy enough to do it using phpxmlrpc, your best bet is to\r
3789       bypass usage of the xmlrpcval objects, at least in the decoding phase,\r
3790       and have the server (or client) object return to the calling function\r
3791       directly php values (see <varname>xmlrpc_client::return_type</varname>\r
3792       and <varname>xmlrpc_server::functions_parameters_type</varname> for more\r
3793       details).</para>\r
3794     </sect1>\r
3795 \r
3796     <sect1>\r
3797       <title>My server (client) returns an error whenever the client (server)\r
3798       returns accented characters</title>\r
3799 \r
3800       <para>To be documented...</para>\r
3801     </sect1>\r
3802 \r
3803     <sect1>\r
3804       <title>My php error log is getting full of "deprecated" errors on\r
3805       different lines of xmlrpc.inc and xmlrpcs.inc</title>\r
3806 \r
3807       <para>This happens when the PHP in usage is version 5, and the error\r
3808       reporting level is set to include <constant>E_STRICT</constant> errors.\r
3809       Since the main development platform of the library remains (for the time\r
3810       being) PHP 4, there are no plans to fix this asap. The best workaround\r
3811       is to set the error reporting level to <constant>E_ALL ^\r
3812       E_STRICT</constant>.</para>\r
3813     </sect1>\r
3814 \r
3815     <sect1>\r
3816       <title>How to enable long-lasting method calls</title>\r
3817 \r
3818       <para>To be documented...</para>\r
3819     </sect1>\r
3820 \r
3821     <sect1>\r
3822       <title>My client returns "XML-RPC Fault #2: Invalid return payload:\r
3823       enable debugging to examine incoming payload": what should I do?</title>\r
3824 \r
3825       <para>The response you are seeing is a default error response that the\r
3826       client object returns to the php application when the server did not\r
3827       respond to the call with a valid xmlrpc response.</para>\r
3828 \r
3829       <para>The most likely cause is that you are not using the correct URL\r
3830       when creating the client object, or you do not have appropriate access\r
3831       rights to the web page you are requesting, or some other common http\r
3832       misconfiguration.</para>\r
3833 \r
3834       <para>To find out what the server is really returning to your client,\r
3835       you have to enable the debug mode of the client, using\r
3836       $client-&gt;setdebug(1);</para>\r
3837     </sect1>\r
3838 \r
3839     <sect1>\r
3840       <title>How can I save to a file the xml of the xmlrpc responses received\r
3841       from servers?</title>\r
3842 \r
3843       <para>If what you need is to save the responses received from the server\r
3844       as xml, you have two options:</para>\r
3845 \r
3846       <para>1- use the serialize() method on the response object.</para>\r
3847 \r
3848       <programlisting language="php">\r
3849 $resp = $client-&gt;send($msg);\r
3850 if (!$resp-&gt;faultCode())\r
3851   $data_to_be_saved = $resp-&gt;serialize();\r
3852 </programlisting>\r
3853 \r
3854       <para>Note that this will not be 100% accurate, since the xml generated\r
3855       by the response object can be different from the xml received,\r
3856       especially if there is some character set conversion involved, or such\r
3857       (eg. if you receive an empty string tag as &lt;string/&gt;, serialize()\r
3858       will output &lt;string&gt;&lt;/string&gt;), or if the server sent back\r
3859       as response something invalid (in which case the xml generated client\r
3860       side using serialize() will correspond to the error response generated\r
3861       internally by the lib).</para>\r
3862 \r
3863       <para>2 - set the client object to return the raw xml received instead\r
3864       of the decoded objects:</para>\r
3865 \r
3866       <programlisting language="php">\r
3867 $client = new xmlrpc_client($url);\r
3868 $client-&gt;return_type = 'xml';\r
3869 $resp = $client-&gt;send($msg);\r
3870 if (!$resp-&gt;faultCode())\r
3871   $data_to_be_saved = $resp-&gt;value();\r
3872 </programlisting>\r
3873 \r
3874       <para>Note that using this method the xml response response will not be\r
3875       parsed at all by the library, only the http communication protocol will\r
3876       be checked. This means that xmlrpc responses sent by the server that\r
3877       would have generated an error response on the client (eg. malformed xml,\r
3878       responses that have faultcode set, etc...) now will not be flagged as\r
3879       invalid, and you might end up saving not valid xml but random\r
3880       junk...</para>\r
3881     </sect1>\r
3882 \r
3883     <sect1>\r
3884       <title>Can I use the ms windows character set?</title>\r
3885 \r
3886       <para>If the data your application is using comes from a Microsoft\r
3887       application, there are some chances that the character set used to\r
3888       encode it is CP1252 (the same might apply to data received from an\r
3889       external xmlrpc server/client, but it is quite rare to find xmlrpc\r
3890       toolkits that encode to CP1252 instead of UTF8). It is a character set\r
3891       which is "almost" compatible with ISO 8859-1, but for a few extra\r
3892       characters.</para>\r
3893 \r
3894       <para>PHP-XMLRPC only supports the ISO 8859-1 and UTF8 character sets.\r
3895       The net result of this situation is that those extra characters will not\r
3896       be properly encoded, and will be received at the other end of the\r
3897       XML-RPC tranmission as "garbled data". Unfortunately the library cannot\r
3898       provide real support for CP1252 because of limitations in the PHP 4 xml\r
3899       parser. Luckily, we tried our best to support this character set anyway,\r
3900       and, since version 2.2.1, there is some form of support, left commented\r
3901       in the code.</para>\r
3902 \r
3903       <para>To properly encode outgoing data that is natively in CP1252, you\r
3904       will have to uncomment all relative code in the file\r
3905       <filename>xmlrpc.inc</filename> (you can search for the string "1252"),\r
3906       then set <code>$GLOBALS['xmlrpc_internalencoding']='CP1252';</code>\r
3907       Please note that all incoming data will then be fed to your application\r
3908       as UTF-8 to avoid any potentail data loss.</para>\r
3909     </sect1>\r
3910 \r
3911     <sect1>\r
3912       <title>Does the library support using cookies / http sessions?</title>\r
3913 \r
3914       <para>In short: yes, but a little coding is needed to make it\r
3915       happen.</para>\r
3916 \r
3917       <para>The code below uses sessions to e.g. let the client store a value\r
3918       on the server and retrieve it later.</para>\r
3919 \r
3920       <para><programlisting>\r
3921 $resp = $client-&gt;send(new xmlrpcmsg('registervalue', array(new xmlrpcval('foo'), new xmlrpcval('bar'))));\r
3922 if (!$resp-&gt;faultCode())\r
3923 {\r
3924   $cookies = $resp-&gt;cookies();\r
3925   if (array_key_exists('PHPSESSID', $cookies)) // nb: make sure to use the correct session cookie name\r
3926   {\r
3927     $session_id = $cookies['PHPSESSID']['value'];\r
3928 \r
3929     // do some other stuff here...\r
3930 \r
3931     $client-&gt;setcookie('PHPSESSID', $session_id);\r
3932     $val = $client-&gt;send(new xmlrpcmsg('getvalue', array(new xmlrpcval('foo')));\r
3933   }\r
3934 }\r
3935 </programlisting>Server-side sessions are handled normally like in any other\r
3936       php application. Please see the php manual for more information about\r
3937       sessions.</para>\r
3938 \r
3939       <para>NB: unlike web browsers, not all xmlrpc clients support usage of\r
3940       http cookies. If you have troubles with sessions and control only the\r
3941       server side of the communication, please check with the makers of the\r
3942       xmlrpc client in use.</para>\r
3943     </sect1>\r
3944   </chapter>\r
3945 \r
3946   <appendix id="integration">\r
3947     <title>Integration with the PHP xmlrpc extension</title>\r
3948 \r
3949     <para>To be documented more...</para>\r
3950 \r
3951     <para>In short: for the fastest execution possible, you can enable the php\r
3952     native xmlrpc extension, and use it in conjunction with phpxmlrpc. The\r
3953     following code snippet gives an example of such integration</para>\r
3954 \r
3955     <programlisting language="php">\r
3956 /*** client side ***/\r
3957 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');\r
3958 \r
3959 // tell the client to return raw xml as response value\r
3960 $c-&gt;return_type = 'xml';\r
3961 \r
3962 // let the native xmlrpc extension take care of encoding request parameters\r
3963 $r = $c-&gt;send(xmlrpc_encode_request('examples.getStateName', $_POST['stateno']));\r
3964 \r
3965 if ($r-&gt;faultCode())\r
3966   // HTTP transport error\r
3967   echo 'Got error '.$r-&gt;faultCode();\r
3968 else\r
3969 {\r
3970   // HTTP request OK, but XML returned from server not parsed yet\r
3971   $v = xmlrpc_decode($r-&gt;value());\r
3972   // check if we got a valid xmlrpc response from server\r
3973   if ($v === NULL)\r
3974     echo 'Got invalid response';\r
3975   else\r
3976   // check if server sent a fault response\r
3977   if (xmlrpc_is_fault($v))\r
3978     echo 'Got xmlrpc fault '.$v['faultCode'];\r
3979   else\r
3980     echo'Got response: '.htmlentities($v);\r
3981 }\r
3982 </programlisting>\r
3983   </appendix>\r
3984 \r
3985   <appendix id="substitution">\r
3986     <title>Substitution of the PHP xmlrpc extension</title>\r
3987 \r
3988     <para>Yet another interesting situation is when you are using a ready-made\r
3989     php application, that provides support for the XMLRPC protocol via the\r
3990     native php xmlrpc extension, but the extension is not available on your\r
3991     php install (e.g. because of shared hosting constraints).</para>\r
3992 \r
3993     <para>Since version 2.1, the PHP-XMLRPC library provides a compatibility\r
3994     layer that aims to be 100% compliant with the xmlrpc extension API. This\r
3995     means that any code written to run on the extension should obtain the\r
3996     exact same results, albeit using more resources and a longer processing\r
3997     time, using the PHP-XMLRPC library and the extension compatibility module.\r
3998     The module is part of the EXTRAS package, available as a separate download\r
3999     from the sourceforge.net website, since version 0.2</para>\r
4000   </appendix>\r
4001 \r
4002   <appendix id="enough">\r
4003     <title>'Enough of xmlrpcvals!': new style library usage</title>\r
4004 \r
4005     <para>To be documented...</para>\r
4006 \r
4007     <para>In the meantime, see docs about xmlrpc_client::return_type and\r
4008     xmlrpc_server::functions_parameters_types, as well as php_xmlrpc_encode,\r
4009     php_xmlrpc_decode and php_xmlrpc_decode_xml</para>\r
4010   </appendix>\r
4011 \r
4012   <appendix id="debugger">\r
4013     <title>Usage of the debugger</title>\r
4014 \r
4015     <para>A webservice debugger is included in the library to help during\r
4016     development and testing.</para>\r
4017 \r
4018     <para>The interface should be self-explicative enough to need little\r
4019     documentation.</para>\r
4020 \r
4021     <para><graphic align="center" fileref="debugger.gif"\r
4022     format="GIF" /></para>\r
4023 \r
4024     <para>The most useful feature of the debugger is without doubt the "Show\r
4025     debug info" option. It allows to have a screen dump of the complete http\r
4026     communication between client and server, including the http headers as\r
4027     well as the request and response payloads, and is invaluable when\r
4028     troubleshooting problems with charset encoding, authentication or http\r
4029     compression.</para>\r
4030 \r
4031     <para>The debugger can take advantage of the JSONRPC library extension, to\r
4032     allow debugging of JSON-RPC webservices, and of the JS-XMLRPC library\r
4033     visual editor to allow easy mouse-driven construction of the payload for\r
4034     remote methods. Both components have to be downloaded separately from the\r
4035     sourceforge.net web pages and copied to the debugger directory to enable\r
4036     the extra functionality:</para>\r
4037 \r
4038     <para><itemizedlist>\r
4039         <listitem>\r
4040           <para>to enable jsonrpc functionality, download the PHP-XMLRPC\r
4041           EXTRAS package, and copy the file <filename>jsonrpc.inc</filename>\r
4042           either to the same directory as the debugger or somewhere in your\r
4043           php include path</para>\r
4044         </listitem>\r
4045       </itemizedlist><itemizedlist>\r
4046         <listitem>\r
4047           <para>to enable the visual value editing dialog, download the\r
4048           JS-XMLRPC library, and copy somewhere in the web root files\r
4049           <filename>visualeditor.php</filename>,\r
4050           <filename>visualeditor.css</filename> and the folders\r
4051           <filename>yui</filename> and <filename>img</filename>. Then edit the\r
4052           debugger file <filename>controller.php</filename> and set\r
4053           appropriately the variable <varname>$editorpath</varname>.</para>\r
4054         </listitem>\r
4055       </itemizedlist></para>\r
4056   </appendix>\r
4057 </book>\r
4058 <!-- Keep this comment at the end of the file\r
4059 Local variables:\r
4060 mode: sgml\r
4061 sgml-omittag:nil\r
4062 sgml-shorttag:t\r
4063 sgml-minimize-attributes:nil\r
4064 sgml-always-quote-attributes:t\r
4065 sgml-indent-step:2\r
4066 sgml-indent-data:t\r
4067 sgml-parent-document:nil\r
4068 sgml-exposed-tags:nil\r
4069 sgml-local-catalogs:nil\r
4070 sgml-local-ecat-files:nil\r
4071 sgml-namecase-general:t\r
4072 sgml-general-insert-case:lower\r
4073 End:\r
4074 -->\r