907f00b5b2f0611f68548e8fe51780e448bc6a59
[plcapi.git] / doc / manual / phpxmlrpc_manual.adoc
1 = XML-RPC for PHP
2 :revision: 4.0.0
3 :keywords: xml, rpc, xmlrpc, webservices, http
4 :toc: left
5 :imagesdir: images
6 :source-highlighter: highlightjs
7
8
9 [preface]
10 == Introduction
11
12 XML-RPC is a format devised by link:$$http://www.userland.com/$$[Userland Software] for achieving
13     remote procedure call via XML using HTTP as the transport. XML-RPC has its
14     own web site, link:$$http://www.xmlrpc.com/$$[www.xmlrpc.com]
15
16 This collection of PHP classes provides a framework for writing
17     XML-RPC clients and servers in PHP.
18
19 Main goals of the project are ease of use, flexibility and
20     completeness.
21
22 The original author is Edd Dumbill of link:$$http://usefulinc.com/$$[Useful Information Company]. As of the
23     1.0 stable release, the project was opened to wider involvement and moved
24     to link:$$http://phpxmlrpc.sourceforge.net/$$[SourceForge]; later, to link:$$https://github.com/gggeek/phpxmlrpc$$[Github]
25
26 A list of XML-RPC implementations for other languages such as Perl
27     and Python can be found on the link:$$http://www.xmlrpc.com/$$[www.xmlrpc.com] site.
28
29 === Acknowledgements
30
31 Daniel E. Baumann
32
33 James Bercegay
34
35 Leon Blackwell
36
37 Stephane Bortzmeyer
38
39 Daniel Convissor
40
41 Geoffrey T. Dairiki
42
43 Stefan Esser
44
45 James Flemer
46
47 Ernst de Haan
48
49 Tom Knight
50
51 Axel Kollmorgen
52
53 Peter Kocks
54
55 Daniel Krippner
56
57 {empty}S. Kuip
58
59 {empty}A. Lambert
60
61 Frederic Lecointre
62
63 Dan Libby
64
65 Arnaud Limbourg
66
67 Ernest MacDougal Campbell III
68
69 Lukasz Mach
70
71 Kjartan Mannes
72
73 Ben Margolin
74
75 Nicolay Mausz
76
77 Justin Miller
78
79 Jan Pfeifer
80
81 Giancarlo Pinerolo
82
83 Peter Russel
84
85 Jean-Jacques Sarton
86
87 Viliam Simko
88
89 Idan Sofer
90
91 Douglas Squirrel
92
93 Heiko Stübner
94
95 Anatoly Techtonik
96
97 Tommaso Trani
98
99 Eric van der Vlist
100
101 Christian Wenz
102
103 Jim Winstead
104
105 Przemyslaw Wroblewski
106
107 Bruno Zanetti Melotti
108
109
110 [[requirements]]
111 == System Requirements
112
113 The library has been designed with goals of scalability and backward
114     compatibility. As such, it supports a wide range of PHP installs. Note
115     that not all features of the lib are available in every
116     configuration.
117
118 The __minimum supported__ PHP version is
119     5.3.
120
121 If you wish to use HTTPS or HTTP 1.1 to communicate with remote
122     servers, you need the "curl" extension compiled into your PHP
123     installation.
124
125 The "xmlrpc" native extension is not required to be compiled into
126     your PHP installation, but if it is, there will be no interference with
127     the operation of this library.
128
129
130 [[manifest]]
131 == Files in the distribution
132
133 lib/xmlrpc.inc::
134    the XML-RPC classes. include() this in
135           your PHP files to use the classes.
136
137 lib/xmlrpcs.inc::
138    the XML-RPC server class. include() this
139           in addition to xmlrpc.inc to get server functionality
140
141 lib/xmlrpc_wrappers.php::
142    helper functions to "automagically" convert plain php
143           functions to xmlrpc services and vice versa
144
145 demo/server/proxy.php::
146    a sample server implementing xmlrpc proxy
147           functionality.
148
149 demo/server/server.php::
150    a sample server hosting various demo functions, as well as a
151           full suite of functions used for interoperability testing. It is
152           used by testsuite.php (see below) for unit testing the library, and
153           is not to be copied literally into your production servers
154
155 demo/client/client.php, demo/client/agesort.php,
156         demo/client/which.php::
157    client code to exercise some of the functions in server.php,
158           including the interopEchoTests.whichToolkit
159           method.
160
161 demo/client/wrap.php::
162    client code to illustrate 'wrapping' of remote methods into
163           php functions.
164
165 demo/client/introspect.php::
166    client code to illustrate usage of introspection capabilities
167           offered by server.php.
168
169 demo/client/mail.php::
170    client code to illustrate usage of an xmlrpc-to-email gateway
171           using Dave Winer's XML-RPC server at userland.com.
172
173 demo/client/zopetest.php::
174    example client code that queries an xmlrpc server built in
175           Zope.
176
177 demo/vardemo.php::
178    examples of how to construct xmlrpcval types
179
180 demo/demo1.xml, demo/demo2.xml, demo/demo3.xml::
181    XML-RPC responses captured in a file for testing purposes (you
182           can use these to test the
183           xmlrpcmsg->parseResponse() method).
184
185 demo/server/discuss.php,
186         demo/client/comment.php::
187    Software used in the PHP chapter of <<jellyfish>> to provide a comment server and allow the
188           attachment of comments to stories from Meerkat's data store.
189
190 test/testsuite.php, test/parse_args.php::
191    A unit test suite for this software package. If you do
192           development on this software, please consider submitting tests for
193           this suite.
194
195 test/benchmark.php::
196    A (very limited) benchmarking suite for this software package.
197           If you do development on this software, please consider submitting
198           benchmarks for this suite.
199
200 test/phpunit.php, test/PHPUnit/*.php::
201    An (incomplete) version PEAR's unit test framework for PHP.
202           The complete package can be found at link:$$http://pear.php.net/package/PHPUnit$$[http://pear.php.net/package/PHPUnit]
203
204 test/verify_compat.php::
205    Script designed to help the user to verify the level of
206           compatibility of the library with the current php install
207
208 extras/test.pl, extras/test.py::
209    Perl and Python programs to exercise server.php to test that
210           some of the methods work.
211
212 extras/workspace.testPhpServer.fttb::
213    Frontier scripts to exercise the demo server. Thanks to Dave
214           Winer for permission to include these. See link:$$http://www.xmlrpc.com/discuss/msgReader$853$$[Dave's announcement of these.]
215
216 extras/rsakey.pem::
217    A test certificate key for the SSL support, which can be used
218           to generate dummy certificates. It has the passphrase "test."
219
220
221 [[bugs]]
222
223 == Known bugs and limitations
224
225 This started out as a bare framework. Many "nice" bits haven't been
226     put in yet. Specifically, very little type validation or coercion has been
227     put in. PHP being a loosely-typed language, this is going to have to be
228     done explicitly (in other words: you can call a lot of library functions
229     passing them arguments of the wrong type and receive an error message only
230     much further down the code, where it will be difficult to
231     understand).
232
233 dateTime.iso8601 is supported opaquely. It can't be done natively as
234     the XML-RPC specification explicitly forbids passing of timezone
235     specifiers in ISO8601 format dates. You can, however, use the <<iso8601encode>> and <<iso8601decode>> functions
236     to do the encoding and decoding for you.
237
238 Very little HTTP response checking is performed (e.g. HTTP redirects
239     are not followed and the Content-Length HTTP header, mandated by the
240     xml-rpc spec, is not validated); cookie support still involves quite a bit
241     of coding on the part of the user.
242
243 If a specific character set encoding other than US-ASCII, ISO-8859-1
244     or UTF-8 is received in the HTTP header or XML prologue of xml-rpc request
245     or response messages then it will be ignored for the moment, and the
246     content will be parsed as if it had been encoded using the charset defined
247     by <<xmlrpc-defencoding>>
248
249 Support for receiving from servers version 1 cookies (i.e.
250     conforming to RFC 2965) is quite incomplete, and might cause unforeseen
251     errors.
252
253
254 [[support]]
255
256 == Support
257
258
259 === Online Support
260
261 XML-RPC for PHP is offered "as-is" without any warranty or
262       commitment to support. However, informal advice and help is available
263       via the XML-RPC for PHP website and mailing list and from
264       XML-RPC.com.
265
266 * The __XML-RPC for PHP__ development is hosted
267           on link:$$https://github.com/gggeek/phpxmlrpc$$[github.com/gggeek/phpxmlrpc].
268           Bugs, feature requests and patches can be posted to the link:$$https://github.com/gggeek/phpxmlrpc/issues$$[project's website].
269
270 * The __PHP XML-RPC interest mailing list__ is
271           run by the author. More details link:$$http://lists.gnomehack.com/mailman/listinfo/phpxmlrpc$$[can be found here].
272
273 * For more general XML-RPC questions, there is a Yahoo! Groups
274           link:$$http://groups.yahoo.com/group/xml-rpc/$$[XML-RPC mailing list].
275
276 * The link:$$http://www.xmlrpc.com/discuss$$[XML-RPC.com] discussion
277           group is a useful place to get help with using XML-RPC. This group
278           is also gatewayed into the Yahoo! Groups mailing list.
279
280 [[jellyfish]]
281
282 === The Jellyfish Book
283
284 image::progxmlrpc.s.gif[The Jellyfish Book]
285 Together with Simon St.Laurent and Joe
286       Johnston, Edd Dumbill wrote a book on XML-RPC for O'Reilly and
287       Associates on XML-RPC. It features a rather fetching jellyfish on the
288       cover.
289
290 Complete details of the book are link:$$http://www.oreilly.com/catalog/progxmlrpc/$$[available from O'Reilly's web site.]
291
292 Edd is responsible for the chapter on PHP, which includes a worked
293       example of creating a forum server, and hooking it up the O'Reilly's
294       link:$$http://meerkat.oreillynet.com/$$[Meerkat] service in
295       order to allow commenting on news stories from around the Web.
296
297 If you've benefited from the effort that has been put into writing
298       this software, then please consider buying the book!
299
300
301 [[apidocs]]
302
303 == Class documentation
304
305 [[xmlrpcval]]
306
307 === xmlrpcval
308
309 This is where a lot of the hard work gets done. This class enables
310       the creation and encapsulation of values for XML-RPC.
311
312 Ensure you've read the XML-RPC spec at link:$$http://www.xmlrpc.com/stories/storyReader$7$$[http://www.xmlrpc.com/stories/storyReader$7]
313       before reading on as it will make things clearer.
314
315 The xmlrpcval class can store arbitrarily
316       complicated values using the following types: ++i4 int boolean string double dateTime.iso8601 base64 array struct++
317       ++null++. You should refer to the link:$$http://www.xmlrpc.com/spec$$[spec] for more information on
318       what each of these types mean.
319
320 ==== Notes on types
321
322 ===== int
323
324 The type i4 is accepted as a synonym
325           for int when creating xmlrpcval objects. The
326           xml parsing code will always convert i4 to
327           int: int is regarded
328           by this implementation as the canonical name for this type.
329
330 ===== base64
331
332 Base 64 encoding is performed transparently to the caller when
333           using this type. Decoding is also transparent. Therefore you ought
334           to consider it as a "binary" data type, for use when you want to
335           pass data that is not 7-bit clean.
336
337 ===== boolean
338
339 The php values ++true++ and
340           ++1++ map to ++true++. All other
341           values (including the empty string) are converted to
342           ++false++.
343
344 ===== string
345
346 Characters &lt;, &gt;, ', ", &amp;, are encoded using their
347           entity reference as &amp;lt; &amp;gt; &amp;apos; &amp;quot; and
348           &amp;amp; All other characters outside of the ASCII range are
349           encoded using their character reference representation (e.g.
350           &amp;#200 for é). The XML-RPC spec recommends only encoding
351           ++&lt; &amp;++ but this implementation goes further,
352           for reasons explained by link:$$http://www.w3.org/TR/REC-xml#syntax$$[the XML 1.0 recommendation]. In particular, using character reference
353           representation has the advantage of producing XML that is valid
354           independently of the charset encoding assumed.
355
356 ===== null
357
358 There is no support for encoding ++null++
359           values in the XML-RPC spec, but at least a couple of extensions (and
360           many toolkits) do support it. Before using ++null++
361           values in your messages, make sure that the responding party accepts
362           them, and uses the same encoding convention (see ...).
363
364 [[xmlrpcval-creation]]
365
366 ==== Creation
367
368 The constructor is the normal way to create an
369         xmlrpcval. The constructor can take these
370         forms:
371
372 xmlrpcvalnew
373             xmlrpcval xmlrpcvalnew
374             xmlrpcval string $stringVal xmlrpcvalnew
375             xmlrpcval mixed $scalarVal string$scalartyp xmlrpcvalnew
376             xmlrpcval array $arrayVal string $arraytyp The first constructor creates an empty value, which must be
377         altered using the methods addScalar,
378         addArray or addStruct before
379         it can be used.
380
381 The second constructor creates a simple string value.
382
383 The third constructor is used to create a scalar value. The
384         second parameter must be a name of an XML-RPC type. Valid types are:
385         "++int++", "++boolean++",
386         "++string++", "++double++",
387         "++dateTime.iso8601++", "++base64++" or
388         "null".
389
390 Examples:
391
392 [source, php]
393 ----
394
395 $myInt = new xmlrpcval(1267, "int");
396 $myString = new xmlrpcval("Hello, World!", "string");
397 $myBool = new xmlrpcval(1, "boolean");
398 $myString2 = new xmlrpcval(1.24, "string"); // note: this will serialize a php float value as xmlrpc string
399
400 ----
401
402 The fourth constructor form can be used to compose complex
403         XML-RPC values. The first argument is either a simple array in the
404         case of an XML-RPC array or an associative
405         array in the case of a struct. The elements of
406         the array __must be xmlrpcval objects themselves__.
407
408 The second parameter must be either "++array++"
409         or "++struct++".
410
411 Examples:
412
413 [source, php]
414 ----
415
416 $myArray = new xmlrpcval(
417   array(
418     new xmlrpcval("Tom"),
419     new xmlrpcval("Dick"),
420     new xmlrpcval("Harry")
421   ),
422   "array");
423
424 // recursive struct
425 $myStruct = new xmlrpcval(
426   array(
427     "name" => new xmlrpcval("Tom", "string"),
428     "age" => new xmlrpcval(34, "int"),
429     "address" => new xmlrpcval(
430       array(
431         "street" => new xmlrpcval("Fifht Ave", "string"),
432         "city" => new xmlrpcval("NY", "string")
433       ),
434       "struct")
435   ),
436   "struct");
437
438 ----
439
440 See the file ++vardemo.php++ in this distribution
441         for more examples.
442
443 [[xmlrpcval-methods]]
444
445 ==== Methods
446
447 ===== addScalar
448
449 int addScalarstring$stringValintaddScalarmixed$scalarValstring$scalartypIf $val is an empty
450           xmlrpcval this method makes it a scalar
451           value, and sets that value.
452
453 If $val is already a scalar value, then
454           no more scalars can be added and ++0++ is
455           returned.
456
457 If $val is an xmlrpcval of type array,
458           the php value $scalarval is added as its last
459           element.
460
461 If all went OK, ++1++ is returned, otherwise
462           ++0++.
463
464 ===== addArray
465
466 intaddArrayarray$arrayValThe argument is a simple (numerically indexed) array. The
467           elements of the array __must be xmlrpcval objects themselves__.
468
469 Turns an empty xmlrpcval into an
470           array with contents as specified by
471           $arrayVal.
472
473 If $val is an xmlrpcval of type array,
474           the elements of $arrayVal are appended to the
475           existing ones.
476
477 See the fourth constructor form for more information.
478
479 If all went OK, ++1++ is returned, otherwise
480           ++0++.
481
482 ===== addStruct
483
484 int addStructarray$assocArrayValThe argument is an associative array. The elements of the
485           array __must be xmlrpcval objects themselves__.
486
487 Turns an empty xmlrpcval into a
488           struct with contents as specified by
489           $assocArrayVal.
490
491 If $val is an xmlrpcval of type struct,
492           the elements of $arrayVal are merged with the
493           existing ones.
494
495 See the fourth constructor form for more information.
496
497 If all went OK, ++1++ is returned, otherwise
498           ++0++.
499
500 ===== kindOf
501
502 string kindOf Returns a string containing "struct", "array" or "scalar"
503           describing the base type of the value. If it returns "undef" it
504           means that the value hasn't been initialised.
505
506 ===== serialize
507
508 string serialize Returns a string containing the XML-RPC representation of this
509           value.
510
511
512 ===== scalarVal
513
514 mixed scalarVal If $val-&gt;kindOf() == "scalar", this
515           method returns the actual PHP-language value of the scalar (base 64
516           decoding is automatically handled here).
517
518 ===== scalarTyp
519
520 string scalarTyp If $val-&gt;kindOf() == "scalar", this
521           method returns a string denoting the type of the scalar. As
522           mentioned before, ++i4++ is always coerced to
523           ++int++.
524
525 ===== arrayMem
526
527 xmlrpcval arrayMem int $n If $val-&gt;kindOf() == "array", returns
528           the $nth element in the array represented by
529           the value $val. The value returned is an
530           xmlrpcval object.
531
532 [source, php]
533 ----
534
535 // iterating over values of an array object
536 for ($i = 0; $i < $val->arraySize(); $i++)
537 {
538   $v = $val->arrayMem($i);
539   echo "Element $i of the array is of type ".$v->kindOf();
540 }
541
542 ----
543
544 ===== arraySize
545
546 int arraySize If $val is an
547           array, returns the number of elements in that
548           array.
549
550 ===== structMem
551
552 xmlrpcval structMem string $memberName If $val-&gt;kindOf() == "struct", returns
553           the element called $memberName from the
554           struct represented by the value $val. The
555           value returned is an xmlrpcval object.
556
557 ===== structEach
558
559 array structEach Returns the next (key, value) pair from the struct, when
560           $val is a struct.
561           $value is an xmlrpcval itself. See also <<structreset>>.
562
563 [source, php]
564 ----
565
566 // iterating over all values of a struct object
567 $val->structreset();
568 while (list($key, $v) = $val->structEach())
569 {
570   echo "Element $key of the struct is of type ".$v->kindOf();
571 }
572
573 ----
574
575 [[structreset]]
576
577 ===== structReset
578
579 void structReset Resets the internal pointer for
580           structEach() to the beginning of the struct,
581           where $val is a struct.
582
583 [[structmemexists]]
584
585 ===== structMemExists
586
587 bool structMemExsists string $memberName Returns TRUE or
588           FALSE depending on whether a member of the
589           given name exists in the struct.
590
591 [[xmlrpcmsg]]
592
593 === xmlrpcmsg
594
595 This class provides a representation for a request to an XML-RPC
596       server. A client sends an xmlrpcmsg to a server,
597       and receives back an xmlrpcresp (see <<xmlrpc-client-send>>).
598
599 ==== Creation
600
601 The constructor takes the following forms:
602
603 xmlrpcmsgnew
604             xmlrpcmsgstring$methodNamearray$parameterArraynullWhere methodName is a string indicating
605         the name of the method you wish to invoke, and
606         parameterArray is a simple php
607         Array of xmlrpcval
608         objects. Here's an example message to the __US state name__ server:
609
610 [source, php]
611 ----
612
613 $msg = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23, "int")));
614
615 ----
616
617 This example requests the name of state number 23. For more
618         information on xmlrpcval objects, see <<xmlrpcval>>.
619
620 Note that the parameterArray parameter is
621         optional and can be omitted for methods that take no input parameters
622         or if you plan to add parameters one by one.
623
624 ==== Methods
625
626
627 ===== addParam
628
629 bool addParam xmlrpcval $xmlrpcVal Adds the xmlrpcval
630           xmlrpcVal to the parameter list for this
631           method call. Returns TRUE or FALSE on error.
632
633 ===== getNumParams
634
635 int getNumParams Returns the number of parameters attached to this
636           message.
637
638 ===== getParam
639
640 xmlrpcval getParam int $n Gets the nth parameter in the message
641           (with the index zero-based). Use this method in server
642           implementations to retrieve the values sent by the client.
643
644 ===== method
645
646 string method string method string $methNameGets or sets the method contained in the XML-RPC
647           message.
648
649 ===== parseResponse
650
651 xmlrpcresp parseResponsestring $xmlString Given an incoming XML-RPC server response contained in the
652           string $xmlString, this method constructs an
653           xmlrpcresp response object and returns it,
654           setting error codes as appropriate (see <<xmlrpc-client-send>>).
655
656 This method processes any HTTP/MIME headers it finds.
657
658 ===== parseResponseFile
659
660 xmlrpcresp parseResponseFile file handle
661               resource$fileHandleGiven an incoming XML-RPC server response on the open file
662           handle fileHandle, this method reads all the
663           data it finds and passes it to
664           parseResponse.
665
666 This method is useful to construct responses from pre-prepared
667           files (see files ++demo1.xml, demo2.xml, demo3.xml++
668           in this distribution). It processes any HTTP headers it finds, and
669           does not close the file handle.
670
671 ===== serialize
672
673 string
674               serializeReturns the an XML string representing the XML-RPC
675           message.
676
677 [[xmlrpc-client]]
678
679 === xmlrpc_client
680
681 This is the basic class used to represent a client of an XML-RPC
682       server.
683
684 ==== Creation
685
686 The constructor accepts one of two possible syntaxes:
687
688 xmlrpc_clientnew
689             xmlrpc_clientstring$server_urlxmlrpc_clientnew
690             xmlrpc_clientstring$server_pathstring$server_hostnameint$server_port80string$transport'http'Here are a couple of usage examples of the first form:
691
692
693 [source, php]
694 ----
695
696 $client = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");
697 $another_client = new xmlrpc_client("https://james:bond@secret.service.com:443/xmlrpcserver?agent=007");
698
699 ----
700
701 The second syntax does not allow to express a username and
702         password to be used for basic HTTP authorization as in the second
703         example above, but instead it allows to choose whether xmlrpc calls
704         will be made using the HTTP 1.0 or 1.1 protocol.
705
706 Here's another example client set up to query Userland's XML-RPC
707         server at __betty.userland.com__:
708
709 [source, php]
710 ----
711
712 $client = new xmlrpc_client("/RPC2", "betty.userland.com", 80);
713
714 ----
715
716 The server_port parameter is optional,
717         and if omitted will default to 80 when using HTTP and 443 when using
718         HTTPS (see the <<xmlrpc-client-send>> method
719         below).
720
721 The transport parameter is optional, and
722         if omitted will default to 'http'. Allowed values are either
723         'http', 'https' or
724         'http11'. Its value can be overridden with every call
725         to the send method. See the
726         send method below for more details about the
727         meaning of the different values.
728
729
730 ==== Methods
731
732 This class supports the following methods.
733
734 [[xmlrpc-client-send]]
735
736 ===== send
737
738 This method takes the forms:
739
740 xmlrpcresp send xmlrpcmsg $xmlrpc_message int $timeout string $transport array sendarray $xmlrpc_messages int $timeout string $transportxmlrpcrespsendstring$xml_payloadint$timeoutstring$transportWhere xmlrpc_message is an instance of
741           xmlrpcmsg (see <<xmlrpcmsg>>),
742           and response is an instance of
743           xmlrpcresp (see <<xmlrpcresp>>).
744
745 If xmlrpc_messages is an array of
746           message instances, ++responses++ will be an array of
747           response instances. The client will try to make use of a single
748           ++system.multicall++ xml-rpc method call to forward to the
749           server all the messages in a single HTTP round trip, unless
750           ++$$$client-&gt;no_multicall$$++ has been previously set to
751           ++TRUE++ (see the multicall method below), in which case
752           many consecutive xmlrpc requests will be sent.
753
754 The third syntax allows to build by hand (or any other means)
755           a complete xmlrpc request message, and send it to the server.
756           xml_payload should be a string containing the
757           complete xml representation of the request. It is e.g. useful when,
758           for maximal speed of execution, the request is serialized into a
759           string using the native php xmlrpc functions (see link:$$http://www.php.net/xmlrpc$$[the php manual on xmlrpc]).
760
761 The timeout is optional, and will be
762           set to ++0++ (wait for platform-specific predefined
763           timeout) if omitted. This timeout value is passed to
764           fsockopen(). It is also used for detecting
765           server timeouts during communication (i.e. if the server does not
766           send anything to the client for timeout
767           seconds, the connection will be closed).
768
769 The transport parameter is optional,
770           and if omitted will default to the transport set using instance
771           creator or 'http' if omitted. The only other valid values are
772           'https', which will use an SSL HTTP connection to connect to the
773           remote server, and 'http11'. Note that your PHP must have the "curl"
774           extension compiled in order to use both these features. Note that
775           when using SSL you should normally set your port number to 443,
776           unless the SSL server you are contacting runs at any other
777           port.
778
779 In addition to low-level errors, the XML-RPC server you were
780           querying may return an error in the
781           xmlrpcresp object. See <<xmlrpcresp>> for details of how to handle these
782           errors.
783
784 [[multicall]]
785
786 ===== multiCall
787
788 This method takes the form:
789
790 array multiCall array $messages int $timeout string $transport bool $fallback This method is used to boxcar many method calls in a single
791           xml-rpc request. It will try first to make use of the
792           ++system.multicall++ xml-rpc method call, and fall back to
793           executing many separate requests if the server returns any
794           error.
795
796 msgs is an array of
797           xmlrpcmsg objects (see <<xmlrpcmsg>>), and response is an
798           array of xmlrpcresp objects (see <<xmlrpcresp>>).
799
800 The timeout and
801           transport parameters are optional, and behave
802           as in the send method above.
803
804 The fallback parameter is optional, and
805           defaults to TRUE. When set to
806           FALSE it will prevent the client to try using
807           many single method calls in case of failure of the first multicall
808           request. It should be set only when the server is known to support
809           the multicall extension.
810
811 ===== setAcceptedCompression
812
813 void setAcceptedCompression string $compressionmethod This method defines whether the client will accept compressed
814           xml payload forming the bodies of the xmlrpc responses received from
815           servers. Note that enabling reception of compressed responses merely
816           adds some standard http headers to xmlrpc requests. It is up to the
817           xmlrpc server to return compressed responses when receiving such
818           requests. Allowed values for
819           compressionmethod are: 'gzip', 'deflate',
820           'any' or null (with any meaning either gzip or deflate).
821
822 This requires the "zlib" extension to be enabled in your php
823           install. If it is, by default xmlrpc_client
824           instances will enable reception of compressed content.
825
826 ===== setCaCertificate
827
828 voidsetCaCertificatestring$certificatebool$is_dirThis method sets an optional certificate to be used in
829           SSL-enabled communication to validate a remote server with (when the
830           server_method is set to 'https' in the
831           client's construction or in the send method and
832           SetSSLVerifypeer has been set to
833           TRUE).
834
835 The certificate parameter must be the
836           filename of a PEM formatted certificate, or a directory containing
837           multiple certificate files. The is_dir
838           parameter defaults to FALSE, set it to
839           TRUE to specify that
840           certificate indicates a directory instead of
841           a single file.
842
843 This requires the "curl" extension to be compiled into your
844           installation of PHP. For more details see the man page for the
845           curl_setopt function.
846
847
848 ===== setCertificate
849
850 voidsetCertificatestring$certificatestring$passphraseThis method sets the optional certificate and passphrase used
851           in SSL-enabled communication with a remote server (when the
852           server_method is set to 'https' in the
853           client's construction or in the send method).
854
855 The certificate parameter must be the
856           filename of a PEM formatted certificate. The
857           passphrase parameter must contain the
858           password required to use the certificate.
859
860 This requires the "curl" extension to be compiled into your
861           installation of PHP. For more details see the man page for the
862           curl_setopt function.
863
864 Note: to retrieve information about the client certificate on
865           the server side, you will need to look into the environment
866           variables which are set up by the webserver. Different webservers
867           will typically set up different variables.
868
869 ===== setCookie
870
871 void setCookiestring $name string $value string $path string $domain int $portThis method sets a cookie that will be sent to the xmlrpc
872           server along with every further request (useful e.g. for keeping
873           session info outside of the xml-rpc payload).
874
875 $value is optional, and defaults to
876           null.
877
878 $path, $domain and $port are optional,
879           and will be omitted from the cookie header if unspecified. Note that
880           setting any of these values will turn the cookie into a 'version 1'
881           cookie, that might not be fully supported by the server (see RFC2965
882           for more details).
883
884 ===== setCredentials
885
886 voidsetCredentialsstring$usernamestring$passwordint$authtypeThis method sets the username and password for authorizing the
887           client to a server. With the default (HTTP) transport, this
888           information is used for HTTP Basic authorization. Note that username
889           and password can also be set using the class constructor. With HTTP
890           1.1 and HTTPS transport, NTLM and Digest authentication protocols
891           are also supported. To enable them use the constants
892           CURLAUTH_DIGEST and
893           CURLAUTH_NTLM as values for the authtype
894           parameter.
895
896
897 ===== setCurlOptions
898
899 voidsetCurlOptionsarray$optionsThis method allows to directly set any desired
900           option to manipulate the usage of the cURL client (when in cURL
901           mode). It can be used eg. to explicitly bind to an outgoing ip
902           address when the server is multihomed
903
904
905 ===== setDebug
906
907 void setDebugint$debugLvldebugLvl is either ++0, 1++ or 2 depending on whether you require the client to
908           print debugging information to the browser. The default is not to
909           output this information (0).
910
911 The debugging information at level 1includes the raw data
912           returned from the XML-RPC server it was querying (including bot HTTP
913           headers and the full XML payload), and the PHP value the client
914           attempts to create to represent the value returned by the server. At
915           level2, the complete payload of the xmlrpc request is also printed,
916           before being sent t the server.
917
918 This option can be very useful when debugging servers as it
919           allows you to see exactly what the client sends and the server
920           returns.
921
922
923 ===== setKey
924
925 voidsetKeyint$keyint$keypassThis method sets the optional certificate key and passphrase
926           used in SSL-enabled communication with a remote server (when the
927           transport is set to 'https' in the client's
928           construction or in the send method).
929
930 This requires the "curl" extension to be compiled into your
931           installation of PHP. For more details see the man page for the
932           curl_setopt function.
933
934
935 ===== setProxy
936
937 voidsetProxystring$proxyhostint$proxyportstring$proxyusernamestring$proxypasswordint$authtypeThis method enables calling servers via an HTTP proxy. The
938           proxyusername,
939           proxypassword and authtype
940           parameters are optional. Authtype defaults to
941           CURLAUTH_BASIC (Basic authentication protocol);
942           the only other valid value is the constant
943           CURLAUTH_NTLM, and has effect only when the
944           client uses the HTTP 1.1 protocol.
945
946 NB: CURL versions before 7.11.10 cannot use a proxy to
947           communicate with https servers.
948
949
950 ===== setRequestCompression
951
952 voidsetRequestCompressionstring$compressionmethodThis method defines whether the xml payload forming the
953           request body will be sent to the server in compressed format, as per
954           the HTTP specification. This is particularly useful for large
955           request parameters and over slow network connections. Allowed values
956           for compressionmethod are: 'gzip', 'deflate',
957           'any' or null (with any meaning either gzip or deflate). Note that
958           there is no automatic fallback mechanism in place for errors due to
959           servers not supporting receiving compressed request bodies, so make
960           sure that the particular server you are querying does accept
961           compressed requests before turning it on.
962
963 This requires the "zlib" extension to be enabled in your php
964           install.
965
966
967 ===== setSSLVerifyHost
968
969 voidsetSSLVerifyHostint$iThis method defines whether connections made to XML-RPC
970           backends via HTTPS should verify the remote host's SSL certificate's
971           common name (CN). By default, only the existence of a CN is checked.
972           $i should be an
973           integer value; 0 to not check the CN at all, 1 to merely check for
974           its existence, and 2 to check that the CN on the certificate matches
975           the hostname that is being connected to.
976
977
978 ===== setSSLVerifyPeer
979
980 voidsetSSLVerifyPeerbool$iThis method defines whether connections made to XML-RPC
981           backends via HTTPS should verify the remote host's SSL certificate,
982           and cause the connection to fail if the cert verification fails.
983           $i should be a boolean
984           value. Default value: TRUE. To specify custom
985           SSL certificates to validate the server with, use the
986           setCaCertificate method.
987
988
989 ===== setUserAgent
990
991 voidUseragentstring$useragentThis method sets a custom user-agent that will be
992           used by the client in the http headers sent with the request. The
993           default value is built using the library name and version
994           constants.
995
996
997 ==== Variables
998
999 NB: direct manipulation of these variables is only recommended
1000         for advanced users.
1001
1002
1003 ===== no_multicall
1004
1005 This member variable determines whether the multicall() method
1006           will try to take advantage of the system.multicall xmlrpc method to
1007           dispatch to the server an array of requests in a single http
1008           roundtrip or simply execute many consecutive http calls. Defaults to
1009           FALSE, but it will be enabled automatically on the first failure of
1010           execution of system.multicall.
1011
1012
1013 ===== request_charset_encoding
1014
1015 This is the charset encoding that will be used for serializing
1016           request sent by the client.
1017
1018 If defaults to NULL, which means using US-ASCII and encoding
1019           all characters outside of the ASCII range using their xml character
1020           entity representation (this has the benefit that line end characters
1021           will not be mangled in the transfer, a CR-LF will be preserved as
1022           well as a singe LF).
1023
1024 Valid values are 'US-ASCII', 'UTF-8' and 'ISO-8859-1'
1025
1026 [[return-type]]
1027
1028 ===== return_type
1029
1030 This member variable determines whether the value returned
1031           inside an xmlrpcresp object as results of calls to the send() and
1032           multicall() methods will be an xmlrpcval object, a plain php value
1033           or a raw xml string. Allowed values are 'xmlrpcvals' (the default),
1034           'phpvals' and 'xml'. To allow the user to differentiate between a
1035           correct and a faulty response, fault responses will be returned as
1036           xmlrpcresp objects in any case. Note that the 'phpvals' setting will
1037           yield faster execution times, but some of the information from the
1038           original response will be lost. It will be e.g. impossible to tell
1039           whether a particular php string value was sent by the server as an
1040           xmlrpc string or base64 value.
1041
1042 Example usage:
1043
1044
1045 [source, php]
1046 ----
1047
1048 $client = new xmlrpc_client("phpxmlrpc.sourceforge.net/server.php");
1049 $client->return_type = 'phpvals';
1050 $message = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23, "int")));
1051 $resp = $client->send($message);
1052 if ($resp->faultCode()) echo 'KO. Error: '.$resp->faultString(); else echo 'OK: got '.$resp->value();
1053
1054 ----
1055
1056 For more details about usage of the 'xml' value, see Appendix
1057           A.
1058
1059 [[xmlrpcresp]]
1060
1061 === xmlrpcresp
1062
1063 This class is used to contain responses to XML-RPC requests. A
1064       server method handler will construct an
1065       xmlrpcresp and pass it as a return value. This
1066       same value will be returned by the result of an invocation of the
1067       send method of the
1068       xmlrpc_client class.
1069
1070
1071 ==== Creation
1072
1073 xmlrpcrespnew
1074             xmlrpcrespxmlrpcval$xmlrpcvalxmlrpcrespnew
1075             xmlrpcresp0int$errcodestring$err_stringThe first syntax is used when execution has happened without
1076         difficulty: $xmlrpcval is an
1077         xmlrpcval value with the result of the method
1078         execution contained in it. Alternatively it can be a string containing
1079         the xml serialization of the single xml-rpc value result of method
1080         execution.
1081
1082 The second type of constructor is used in case of failure.
1083         errcode and err_string
1084         are used to provide indication of what has gone wrong. See <<xmlrpc-server>> for more information on passing error
1085         codes.
1086
1087
1088 ==== Methods
1089
1090
1091 ===== faultCode
1092
1093 intfaultCodeReturns the integer fault code return from the XML-RPC
1094           response. A zero value indicates success, any other value indicates
1095           a failure response.
1096
1097
1098 ===== faultString
1099
1100 stringfaultStringReturns the human readable explanation of the fault indicated
1101           by $resp-&gt;faultCode().
1102
1103
1104 ===== value
1105
1106 xmlrpcvalvalueReturns an xmlrpcval object containing
1107           the return value sent by the server. If the response's
1108           faultCode is non-zero then the value returned
1109           by this method should not be used (it may not even be an
1110           object).
1111
1112 Note: if the xmlrpcresp instance in question has been created
1113           by an xmlrpc_client object whose
1114           return_type was set to 'phpvals', then a plain
1115           php value will be returned instead of an
1116           xmlrpcval object. If the
1117           return_type was set to 'xml', an xml string will
1118           be returned (see the return_type member var above for more
1119           details).
1120
1121
1122 ===== serialize
1123
1124 stringserializeReturns an XML string representation of the response (xml
1125           prologue not included).
1126
1127 [[xmlrpc-server]]
1128
1129 === xmlrpc_server
1130
1131 The implementation of this class has been kept as simple to use as
1132       possible. The constructor for the server basically does all the work.
1133       Here's a minimal example:
1134
1135
1136 [source, php]
1137 ----
1138
1139   function foo ($xmlrpcmsg) {
1140     ...
1141     return new xmlrpcresp($some_xmlrpc_val);
1142   }
1143
1144   class bar {
1145     function foobar($xmlrpcmsg) {
1146       ...
1147       return new xmlrpcresp($some_xmlrpc_val);
1148     }
1149   }
1150
1151   $s = new xmlrpc_server(
1152     array(
1153       "examples.myFunc1" => array("function" => "foo"),
1154       "examples.myFunc2" => array("function" => "bar::foobar"),
1155     ));
1156
1157 ----
1158
1159 This performs everything you need to do with a server. The single
1160       constructor argument is an associative array from xmlrpc method names to
1161       php function names. The incoming request is parsed and dispatched to the
1162       relevant php function, which is responsible for returning a
1163       xmlrpcresp object, that will be serialized back
1164       to the caller.
1165
1166
1167 ==== Method handler functions
1168
1169 Both php functions and class methods can be registered as xmlrpc
1170         method handlers.
1171
1172 The synopsis of a method handler function is:
1173
1174 xmlrpcresp $resp = function (xmlrpcmsg $msg)
1175
1176 No text should be echoed 'to screen' by the handler function, or
1177         it will break the xml response sent back to the client. This applies
1178         also to error and warning messages that PHP prints to screen unless
1179         the appropriate parameters have been set in the php.in file. Another
1180         way to prevent echoing of errors inside the response and facilitate
1181         debugging is to use the server SetDebug method with debug level 3 (see
1182         ...). Exceptions thrown duting execution of handler functions are
1183         caught by default and a XML-RPC error reponse is generated instead.
1184         This behaviour can be finetuned by usage of the
1185         exception_handling member variable (see
1186         ...).
1187
1188 Note that if you implement a method with a name prefixed by
1189         ++system.++ the handler function will be invoked by the
1190         server with two parameters, the first being the server itself and the
1191         second being the xmlrpcmsg object.
1192
1193 The same php function can be registered as handler of multiple
1194         xmlrpc methods.
1195
1196 Here is a more detailed example of what the handler function
1197         foo may do:
1198
1199
1200 [source, php]
1201 ----
1202
1203   function foo ($xmlrpcmsg) {
1204     global $xmlrpcerruser; // import user errcode base value
1205
1206     $meth = $xmlrpcmsg->method(); // retrieve method name
1207     $par = $xmlrpcmsg->getParam(0); // retrieve value of first parameter - assumes at least one param received
1208     $val = $par->scalarval(); // decode value of first parameter - assumes it is a scalar value
1209
1210     ...
1211
1212     if ($err) {
1213       // this is an error condition
1214       return new xmlrpcresp(0, $xmlrpcerruser+1, // user error 1
1215         "There's a problem, Captain");
1216     } else {
1217       // this is a successful value being returned
1218       return new xmlrpcresp(new xmlrpcval("All's fine!", "string"));
1219     }
1220   }
1221
1222 ----
1223
1224 See __server.php__ in this distribution for
1225         more examples of how to do this.
1226
1227 Since release 2.0RC3 there is a new, even simpler way of
1228         registering php functions with the server. See section 5.7
1229         below
1230
1231
1232 ==== The dispatch map
1233
1234 The first argument to the xmlrpc_server
1235         constructor is an array, called the __dispatch map__.
1236         In this array is the information the server needs to service the
1237         XML-RPC methods you define.
1238
1239 The dispatch map takes the form of an associative array of
1240         associative arrays: the outer array has one entry for each method, the
1241         key being the method name. The corresponding value is another
1242         associative array, which can have the following members:
1243
1244
1245 * ++function++ - this
1246             entry is mandatory. It must be either a name of a function in the
1247             global scope which services the XML-RPC method, or an array
1248             containing an instance of an object and a static method name (for
1249             static class methods the 'class::method' syntax is also
1250             supported).
1251
1252
1253 * ++signature++ - this
1254             entry is an array containing the possible signatures (see <<signatures>>) for the method. If this entry is present
1255             then the server will check that the correct number and type of
1256             parameters have been sent for this method before dispatching
1257             it.
1258
1259
1260 * ++docstring++ - this
1261             entry is a string containing documentation for the method. The
1262             documentation may contain HTML markup.
1263
1264
1265 * ++$$signature_docs$$++ - this entry can be used
1266             to provide documentation for the single parameters. It must match
1267             in structure the 'signature' member. By default, only the
1268             documenting_xmlrpc_server class in the
1269             extras package will take advantage of this, since the
1270             "system.methodHelp" protocol does not support documenting method
1271             parameters individually.
1272
1273
1274 * ++$$parameters_type$$++ - this entry can be used
1275             when the server is working in 'xmlrpcvals' mode (see ...) to
1276             define one or more entries in the dispatch map as being functions
1277             that follow the 'phpvals' calling convention. The only useful
1278             value is currently the string ++phpvals++.
1279
1280 Look at the __server.php__ example in the
1281         distribution to see what a dispatch map looks like.
1282
1283 [[signatures]]
1284
1285 ==== Method signatures
1286
1287 A signature is a description of a method's return type and its
1288         parameter types. A method may have more than one signature.
1289
1290 Within a server's dispatch map, each method has an array of
1291         possible signatures. Each signature is an array of types. The first
1292         entry is the return type. For instance, the method
1293 [source, php]
1294 ----
1295 string examples.getStateName(int)
1296
1297 ----
1298
1299  has the signature
1300 [source, php]
1301 ----
1302 array($xmlrpcString, $xmlrpcInt)
1303
1304 ----
1305
1306  and, assuming that it is the only possible signature for the
1307         method, it might be used like this in server creation:
1308 [source, php]
1309 ----
1310
1311 $findstate_sig = array(array($xmlrpcString, $xmlrpcInt));
1312
1313 $findstate_doc = 'When passed an integer between 1 and 51 returns the
1314 name of a US state, where the integer is the index of that state name
1315 in an alphabetic order.';
1316
1317 $s = new xmlrpc_server( array(
1318   "examples.getStateName" => array(
1319     "function" => "findstate",
1320     "signature" => $findstate_sig,
1321     "docstring" => $findstate_doc
1322   )));
1323
1324 ----
1325
1326
1327
1328 Note that method signatures do not allow to check nested
1329         parameters, e.g. the number, names and types of the members of a
1330         struct param cannot be validated.
1331
1332 If a method that you want to expose has a definite number of
1333         parameters, but each of those parameters could reasonably be of
1334         multiple types, the array of acceptable signatures will easily grow
1335         into a combinatorial explosion. To avoid such a situation, the lib
1336         defines the global var $xmlrpcValue, which can be
1337         used in method signatures as a placeholder for 'any xmlrpc
1338         type':
1339
1340
1341 [source, php]
1342 ----
1343
1344 $echoback_sig = array(array($xmlrpcValue, $xmlrpcValue));
1345
1346 $findstate_doc = 'Echoes back to the client the received value, regardless of its type';
1347
1348 $s = new xmlrpc_server( array(
1349   "echoBack" => array(
1350     "function" => "echoback",
1351     "signature" => $echoback_sig, // this sig guarantees that the method handler will be called with one and only one parameter
1352     "docstring" => $echoback_doc
1353   )));
1354
1355 ----
1356
1357 Methods system.listMethods,
1358         system.methodHelp,
1359         system.methodSignature and
1360         system.multicall are already defined by the
1361         server, and should not be reimplemented (see Reserved Methods
1362         below).
1363
1364
1365 ==== Delaying the server response
1366
1367 You may want to construct the server, but for some reason not
1368         fulfill the request immediately (security verification, for instance).
1369         If you omit to pass to the constructor the dispatch map or pass it a
1370         second argument of ++0++ this will have the desired
1371         effect. You can then use the service() method of
1372         the server class to service the request. For example:
1373
1374
1375 [source, php]
1376 ----
1377
1378 $s = new xmlrpc_server($myDispMap, 0); // second parameter = 0 prevents automatic servicing of request
1379
1380 // ... some code that does other stuff here
1381
1382 $s->service();
1383
1384 ----
1385
1386 Note that the service method will print
1387         the complete result payload to screen and send appropriate HTTP
1388         headers back to the client, but also return the response object. This
1389         permits further manipulation of the response, possibly in combination
1390         with output buffering.
1391
1392 To prevent the server from sending HTTP headers back to the
1393         client, you can pass a second parameter with a value of
1394         ++TRUE++ to the service
1395         method. In this case, the response payload will be returned instead of
1396         the response object.
1397
1398 Xmlrpc requests retrieved by other means than HTTP POST bodies
1399         can also be processed. For example:
1400
1401
1402 [source, php]
1403 ----
1404
1405 $s = new xmlrpc_server(); // not passing a dispatch map prevents automatic servicing of request
1406
1407 // ... some code that does other stuff here, including setting dispatch map into server object
1408
1409 $resp = $s->service($xmlrpc_request_body, true); // parse a variable instead of POST body, retrieve response payload
1410
1411 // ... some code that does other stuff with xml response $resp here
1412
1413 ----
1414
1415
1416 ==== Modifying the server behaviour
1417
1418 A couple of methods / class variables are available to modify
1419         the behaviour of the server. The only way to take advantage of their
1420         existence is by usage of a delayed server response (see above)
1421
1422
1423 ===== setDebug()
1424
1425 This function controls weather the server is going to echo
1426           debugging messages back to the client as comments in response body.
1427           Valid values: 0,1,2,3, with 1 being the default. At level 0, no
1428           debug info is returned to the client. At level 2, the complete
1429           client request is added to the response, as part of the xml
1430           comments. At level 3, a new PHP error handler is set when executing
1431           user functions exposed as server methods, and all non-fatal errors
1432           are trapped and added as comments into the response.
1433
1434
1435 ===== allow_system_funcs
1436
1437 Default_value: TRUE. When set to FALSE, disables support for
1438           System.xxx functions in the server. It
1439           might be useful e.g. if you do not wish the server to respond to
1440           requests to System.ListMethods.
1441
1442
1443 ===== compress_response
1444
1445 When set to TRUE, enables the server to take advantage of HTTP
1446           compression, otherwise disables it. Responses will be transparently
1447           compressed, but only when an xmlrpc-client declares its support for
1448           compression in the HTTP headers of the request.
1449
1450 Note that the ZLIB php extension must be installed for this to
1451           work. If it is, compress_response will default to
1452           TRUE.
1453
1454
1455 ===== exception_handling
1456
1457 This variable controls the behaviour of the server when an
1458           exception is thrown by a method handler php function. Valid values:
1459           0,1,2, with 0 being the default. At level 0, the server catches the
1460           exception and return an 'internal error' xmlrpc response; at 1 it
1461           catches the exceptions and return an xmlrpc response with the error
1462           code and error message corresponding to the exception that was
1463           thron; at 2 = the exception is floated to the upper layers in the
1464           code
1465
1466
1467 ===== response_charset_encoding
1468
1469 Charset encoding to be used for response (only affects string
1470           values).
1471
1472 If it can, the server will convert the generated response from
1473           internal_encoding to the intended one.
1474
1475 Valid values are: a supported xml encoding (only UTF-8 and
1476           ISO-8859-1 at present, unless mbstring is enabled), null (leave
1477           charset unspecified in response and convert output stream to
1478           US_ASCII), 'default' (use xmlrpc library default as specified in
1479           xmlrpc.inc, convert output stream if needed), or 'auto' (use
1480           client-specified charset encoding or same as request if request
1481           headers do not specify it (unless request is US-ASCII: then use
1482           library default anyway).
1483
1484
1485 ==== Fault reporting
1486
1487 Fault codes for your servers should start at the value indicated
1488         by the global ++$xmlrpcerruser++ + 1.
1489
1490 Standard errors returned by the server include:
1491
1492 ++1++ Unknown method:: Returned if the server was asked to dispatch a method it
1493               didn't know about
1494
1495 ++2++ Invalid return payload:: This error is actually generated by the client, not
1496               server, code, but signifies that a server returned something it
1497               couldn't understand. A more detailed error report is sometimes
1498               added onto the end of the phrase above.
1499
1500 ++3++ Incorrect parameters:: This error is generated when the server has signature(s)
1501               defined for a method, and the parameters passed by the client do
1502               not match any of signatures.
1503
1504 ++4++ Can't introspect: method unknown:: This error is generated by the builtin
1505               system.* methods when any kind of
1506               introspection is attempted on a method undefined by the
1507               server.
1508
1509 ++5++ Didn't receive 200 OK from remote server:: This error is generated by the client when a remote server
1510               doesn't return HTTP/1.1 200 OK in response to a request. A more
1511               detailed error report is added onto the end of the phrase
1512               above.
1513
1514 ++6++ No data received from server:: This error is generated by the client when a remote server
1515               returns HTTP/1.1 200 OK in response to a request, but no
1516               response body follows the HTTP headers.
1517
1518 ++7++ No SSL support compiled in:: This error is generated by the client when trying to send
1519               a request with HTTPS and the CURL extension is not available to
1520               PHP.
1521
1522 ++8++ CURL error:: This error is generated by the client when trying to send
1523               a request with HTTPS and the HTTPS communication fails.
1524
1525 ++9-14++ multicall errors:: These errors are generated by the server when something
1526               fails inside a system.multicall request.
1527
1528 ++100-++ XML parse errors:: Returns 100 plus the XML parser error code for the fault
1529               that occurred. The faultString returned
1530               explains where the parse error was in the incoming XML
1531               stream.
1532
1533
1534 ==== 'New style' servers
1535
1536 In the same spirit of simplification that inspired the
1537         xmlrpc_client::return_type class variable, a new
1538         class variable has been added to the server class:
1539         functions_parameters_type. When set to 'phpvals',
1540         the functions registered in the server dispatch map will be called
1541         with plain php values as parameters, instead of a single xmlrpcmsg
1542         instance parameter. The return value of those functions is expected to
1543         be a plain php value, too. An example is worth a thousand
1544         words:
1545 [source, php]
1546 ----
1547
1548   function foo($usr_id, $out_lang='en') {
1549     global $xmlrpcerruser;
1550
1551     ...
1552
1553     if ($someErrorCondition)
1554       return new xmlrpcresp(0, $xmlrpcerruser+1, 'DOH!');
1555     else
1556       return array(
1557         'name' => 'Joe',
1558         'age' => 27,
1559         'picture' => new xmlrpcval(file_get_contents($picOfTheGuy), 'base64')
1560       );
1561   }
1562
1563   $s = new xmlrpc_server(
1564     array(
1565       "examples.myFunc" => array(
1566         "function" => "bar::foobar",
1567         "signature" => array(
1568           array($xmlrpcString, $xmlrpcInt),
1569           array($xmlrpcString, $xmlrpcInt, $xmlrpcString)
1570         )
1571       )
1572     ), false);
1573   $s->functions_parameters_type = 'phpvals';
1574   $s->service();
1575
1576 ----
1577
1578 There are a few things to keep in mind when using this
1579         simplified syntax:
1580
1581 to return an xmlrpc error, the method handler function must
1582         return an instance of xmlrpcresp. The only
1583         other way for the server to know when an error response should be
1584         served to the client is to throw an exception and set the server's
1585         exception_handling memeber var to 1;
1586
1587 to return a base64 value, the method handler function must
1588         encode it on its own, creating an instance of an xmlrpcval
1589         object;
1590
1591 the method handler function cannot determine the name of the
1592         xmlrpc method it is serving, unlike standard handler functions that
1593         can retrieve it from the message object;
1594
1595 when receiving nested parameters, the method handler function
1596         has no way to distinguish a php string that was sent as base64 value
1597         from one that was sent as a string value;
1598
1599 this has a direct consequence on the support of
1600         system.multicall: a method whose signature contains datetime or base64
1601         values will not be available to multicall calls;
1602
1603 last but not least, the direct parsing of xml to php values is
1604         much faster than using xmlrpcvals, and allows the library to handle
1605         much bigger messages without allocating all available server memory or
1606         smashing PHP recursive call stack.
1607
1608
1609 [[globalvars]]
1610
1611 == Global variables
1612
1613 Many global variables are defined in the xmlrpc.inc file. Some of
1614     those are meant to be used as constants (and modifying their value might
1615     cause unpredictable behaviour), while some others can be modified in your
1616     php scripts to alter the behaviour of the xml-rpc client and
1617     server.
1618
1619
1620 === "Constant" variables
1621
1622
1623 ==== $xmlrpcerruser
1624
1625 $xmlrpcerruser800The minimum value for errors reported by user
1626         implemented XML-RPC servers. Error numbers lower than that are
1627         reserved for library usage.
1628
1629
1630 ==== $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull
1631
1632 For convenience the strings representing the XML-RPC types have
1633         been encoded as global variables:
1634 [source, php]
1635 ----
1636
1637 $xmlrpcI4="i4";
1638 $xmlrpcInt="int";
1639 $xmlrpcBoolean="boolean";
1640 $xmlrpcDouble="double";
1641 $xmlrpcString="string";
1642 $xmlrpcDateTime="dateTime.iso8601";
1643 $xmlrpcBase64="base64";
1644 $xmlrpcArray="array";
1645 $xmlrpcStruct="struct";
1646 $xmlrpcValue="undefined";
1647 $xmlrpcNull="null";
1648
1649 ----
1650
1651 ==== $xmlrpcTypes, $xmlrpc_valid_parents, $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_backslash, $_xh, $xml_iso88591_Entities, $xmlEntities, $xmlrpcs_capabilities
1652
1653 Reserved for internal usage.
1654
1655
1656 === Variables whose value can be modified
1657
1658 [[xmlrpc-defencoding]]
1659
1660 ==== xmlrpc_defencoding
1661
1662 $xmlrpc_defencoding"UTF8"This variable defines the character set encoding that will be
1663         used by the xml-rpc client and server to decode the received messages,
1664         when a specific charset declaration is not found (in the messages sent
1665         non-ascii chars are always encoded using character references, so that
1666         the produced xml is valid regardless of the charset encoding
1667         assumed).
1668
1669 Allowed values: ++"UTF8"++,
1670         ++"ISO-8859-1"++, ++"ASCII".++
1671
1672 Note that the appropriate RFC actually mandates that XML
1673         received over HTTP without indication of charset encoding be treated
1674         as US-ASCII, but many servers and clients 'in the wild' violate the
1675         standard, and assume the default encoding is UTF-8.
1676
1677
1678 ==== xmlrpc_internalencoding
1679
1680 $xmlrpc_internalencoding"ISO-8859-1"This variable defines the character set encoding
1681         that the library uses to transparently encode into valid XML the
1682         xml-rpc values created by the user and to re-encode the received
1683         xml-rpc values when it passes them to the PHP application. It only
1684         affects xml-rpc values of string type. It is a separate value from
1685         xmlrpc_defencoding, allowing e.g. to send/receive xml messages encoded
1686         on-the-wire in US-ASCII and process them as UTF-8. It defaults to the
1687         character set used internally by PHP (unless you are running an
1688         MBString-enabled installation), so you should change it only in
1689         special situations, if e.g. the string values exchanged in the xml-rpc
1690         messages are directly inserted into / fetched from a database
1691         configured to return UTF8 encoded strings to PHP. Example
1692         usage:
1693
1694 [source, php]
1695 ----
1696
1697 <?php
1698
1699 include('xmlrpc.inc');
1700 $xmlrpc_internalencoding = 'UTF-8'; // this has to be set after the inclusion above
1701 $v = new xmlrpcval('κόÏ\83με'); // This xmlrpc value will be correctly serialized as the greek word 'kosme'
1702
1703 ----
1704
1705 ==== xmlrpcName
1706
1707 $xmlrpcName"XML-RPC for PHP"The string representation of the name of the XML-RPC
1708         for PHP library. It is used by the client for building the User-Agent
1709         HTTP header that is sent with every request to the server. You can
1710         change its value if you need to customize the User-Agent
1711         string.
1712
1713
1714 ==== xmlrpcVersion
1715
1716 $xmlrpcVersion"2.2"The string representation of the version number of
1717         the XML-RPC for PHP library in use. It is used by the client for
1718         building the User-Agent HTTP header that is sent with every request to
1719         the server. You can change its value if you need to customize the
1720         User-Agent string.
1721
1722
1723 ==== xmlrpc_null_extension
1724
1725 When set to TRUE, the lib will enable
1726         support for the &lt;NIL/&gt; (and &lt;EX:NIL/&gt;) xmlrpc value, as
1727         per the extension to the standard proposed here. This means that
1728         &lt;NIL/&gt; and &lt;EX:NIL/&gt; tags received will be parsed as valid
1729         xmlrpc, and the corresponding xmlrpcvals will return "null" for
1730         scalarTyp().
1731
1732
1733 ==== xmlrpc_null_apache_encoding
1734
1735 When set to ++TRUE++, php NULL values encoded
1736         into xmlrpcval objects get serialized using the
1737         ++&lt;EX:NIL/&gt;++ tag instead of
1738         ++&lt;NIL/&gt;++. Please note that both forms are
1739         always accepted as input regardless of the value of this
1740         variable.
1741
1742
1743 [[helpers]]
1744
1745 == Helper functions
1746
1747 XML-RPC for PHP contains some helper functions which you can use to
1748     make processing of XML-RPC requests easier.
1749
1750
1751 === Date functions
1752
1753 The XML-RPC specification has this to say on dates:
1754
1755 [quote]
1756 ____
1757 [[wrap_xmlrpc_method]]
1758 Don't assume a timezone. It should be
1759         specified by the server in its documentation what assumptions it makes
1760         about timezones.
1761 ____
1762
1763
1764 Unfortunately, this means that date processing isn't
1765       straightforward. Although XML-RPC uses ISO 8601 format dates, it doesn't
1766       use the timezone specifier.
1767
1768 We strongly recommend that in every case where you pass dates in
1769       XML-RPC calls, you use UTC (GMT) as your timezone. Most computer
1770       languages include routines for handling GMT times natively, and you
1771       won't have to translate between timezones.
1772
1773 For more information about dates, see link:$$http://www.uic.edu/year2000/datefmt.html$$[ISO 8601: The Right Format for Dates], which has a handy link to a PDF of the ISO
1774       8601 specification. Note that XML-RPC uses exactly one of the available
1775       representations: CCYYMMDDTHH:MM:SS.
1776
1777 [[iso8601encode]]
1778
1779 ==== iso8601_encode
1780
1781 stringiso8601_encodestring$time_tint$utc0Returns an ISO 8601 formatted date generated from the UNIX
1782         timestamp $time_t, as returned by the PHP
1783         function time().
1784
1785 The argument $utc can be omitted, in
1786         which case it defaults to ++0++. If it is set to
1787         ++1++, then the function corrects the time passed in
1788         for UTC. Example: if you're in the GMT-6:00 timezone and set
1789         $utc, you will receive a date representation
1790         six hours ahead of your local time.
1791
1792 The included demo program __vardemo.php__
1793         includes a demonstration of this function.
1794
1795 [[iso8601decode]]
1796
1797 ==== iso8601_decode
1798
1799 intiso8601_decodestring$isoStringint$utc0Returns a UNIX timestamp from an ISO 8601 encoded time and date
1800         string passed in. If $utc is
1801         ++1++ then $isoString is assumed
1802         to be in the UTC timezone, and thus the result is also UTC: otherwise,
1803         the timezone is assumed to be your local timezone and you receive a
1804         local timestamp.
1805
1806 [[arrayuse]]
1807
1808 === Easy use with nested PHP values
1809
1810 Dan Libby was kind enough to contribute two helper functions that
1811       make it easier to translate to and from PHP values. This makes it easier
1812       to deal with complex structures. At the moment support is limited to
1813       int, double, string,
1814       array, datetime and struct
1815       datatypes; note also that all PHP arrays are encoded as structs, except
1816       arrays whose keys are integer numbers starting with 0 and incremented by
1817       1.
1818
1819 These functions reside in __xmlrpc.inc__.
1820
1821 [[phpxmlrpcdecode]]
1822
1823 ==== php_xmlrpc_decode
1824
1825 mixedphp_xmlrpc_decodexmlrpcval$xmlrpc_valarray$optionsarrayphp_xmlrpc_decodexmlrpcmsg$xmlrpcmsg_valstring$optionsReturns a native PHP value corresponding to the values found in
1826         the xmlrpcval $xmlrpc_val,
1827         translated into PHP types. Base-64 and datetime values are
1828         automatically decoded to strings.
1829
1830 In the second form, returns an array containing the parameters
1831         of the given
1832         xmlrpcmsg_val, decoded
1833         to php types.
1834
1835 The options parameter is optional. If
1836         specified, it must consist of an array of options to be enabled in the
1837         decoding process. At the moment the only valid option are
1838         decode_php_objs and
1839         ++$$dates_as_objects$$++. When the first is set, php
1840         objects that have been converted to xml-rpc structs using the
1841         php_xmlrpc_encode function and a corresponding
1842         encoding option will be converted back into object values instead of
1843         arrays (provided that the class definition is available at
1844         reconstruction time). When the second is set, XML-RPC datetime values
1845         will be converted into native dateTime objects
1846         instead of strings.
1847
1848 ____WARNING__:__ please take
1849         extreme care before enabling the decode_php_objs
1850         option: when php objects are rebuilt from the received xml, their
1851         constructor function will be silently invoked. This means that you are
1852         allowing the remote end to trigger execution of uncontrolled PHP code
1853         on your server, opening the door to code injection exploits. Only
1854         enable this option when you have complete trust of the remote
1855         server/client.
1856
1857 Example:
1858 [source, php]
1859 ----
1860
1861 // wrapper to expose an existing php function as xmlrpc method handler
1862 function foo_wrapper($m)
1863 {
1864   $params = php_xmlrpc_decode($m);
1865   $retval = call_user_func_array('foo', $params);
1866   return new xmlrpcresp(new xmlrpcval($retval)); // foo return value will be serialized as string
1867 }
1868
1869 $s = new xmlrpc_server(array(
1870    "examples.myFunc1" => array(
1871      "function" => "foo_wrapper",
1872      "signatures" => ...
1873   )));
1874
1875 ----
1876
1877 [[phpxmlrpcencode]]
1878
1879 ==== php_xmlrpc_encode
1880
1881 xmlrpcvalphp_xmlrpc_encodemixed$phpvalarray$optionsReturns an xmlrpcval object populated with the PHP
1882         values in $phpval. Works recursively on arrays
1883         and objects, encoding numerically indexed php arrays into array-type
1884         xmlrpcval objects and non numerically indexed php arrays into
1885         struct-type xmlrpcval objects. Php objects are encoded into
1886         struct-type xmlrpcvals, excepted for php values that are already
1887         instances of the xmlrpcval class or descendants thereof, which will
1888         not be further encoded. Note that there's no support for encoding php
1889         values into base-64 values. Encoding of date-times is optionally
1890         carried on on php strings with the correct format.
1891
1892 The options parameter is optional. If
1893         specified, it must consist of an array of options to be enabled in the
1894         encoding process. At the moment the only valid options are
1895         encode_php_objs, ++$$null_extension$$++
1896         and auto_dates.
1897
1898 The first will enable the creation of 'particular' xmlrpcval
1899         objects out of php objects, that add a "php_class" xml attribute to
1900         their serialized representation. This attribute allows the function
1901         php_xmlrpc_decode to rebuild the native php objects (provided that the
1902         same class definition exists on both sides of the communication). The
1903         second allows to encode php ++NULL++ values to the
1904         ++&lt;NIL/&gt;++ (or
1905         ++&lt;EX:NIL/&gt;++, see ...) tag. The last encodes any
1906         string that matches the ISO8601 format into an XML-RPC
1907         datetime.
1908
1909 Example:
1910 [source, php]
1911 ----
1912
1913 // the easy way to build a complex xml-rpc struct, showing nested base64 value and datetime values
1914 $val = php_xmlrpc_encode(array(
1915   'first struct_element: an int' => 666,
1916   'second: an array' => array ('apple', 'orange', 'banana'),
1917   'third: a base64 element' => new xmlrpcval('hello world', 'base64'),
1918   'fourth: a datetime' => '20060107T01:53:00'
1919   ), array('auto_dates'));
1920
1921 ----
1922
1923 ==== php_xmlrpc_decode_xml
1924
1925 xmlrpcval | xmlrpcresp |
1926             xmlrpcmsgphp_xmlrpc_decode_xmlstring$xmlarray$optionsDecodes the xml representation of either an xmlrpc request,
1927         response or single value, returning the corresponding php-xmlrpc
1928         object, or ++FALSE++ in case of an error.
1929
1930 The options parameter is optional. If
1931         specified, it must consist of an array of options to be enabled in the
1932         decoding process. At the moment, no option is supported.
1933
1934 Example:
1935 [source, php]
1936 ----
1937
1938 $text = '<value><array><data><value>Hello world</value></data></array></value>';
1939 $val = php_xmlrpc_decode_xml($text);
1940 if ($val) echo 'Found a value of type '.$val->kindOf(); else echo 'Found invalid xml';
1941
1942 ----
1943
1944 === Automatic conversion of php functions into xmlrpc methods (and vice versa)
1945
1946 For the extremely lazy coder, helper functions have been added
1947       that allow to convert a php function into an xmlrpc method, and a
1948       remotely exposed xmlrpc method into a local php function - or a set of
1949       methods into a php class. Note that these comes with many caveat.
1950
1951
1952 ==== wrap_xmlrpc_method
1953
1954 stringwrap_xmlrpc_method$client$methodname$extra_optionsstringwrap_xmlrpc_method$client$methodname$signum$timeout$protocol$funcnameGiven an xmlrpc server and a method name, creates a php wrapper
1955         function that will call the remote method and return results using
1956         native php types for both params and results. The generated php
1957         function will return an xmlrpcresp object for failed xmlrpc
1958         calls.
1959
1960 The second syntax is deprecated, and is listed here only for
1961         backward compatibility.
1962
1963 The server must support the
1964         system.methodSignature xmlrpc method call for
1965         this function to work.
1966
1967 The client param must be a valid
1968         xmlrpc_client object, previously created with the address of the
1969         target xmlrpc server, and to which the preferred communication options
1970         have been set.
1971
1972 The optional parameters can be passed as array key,value pairs
1973         in the extra_options param.
1974
1975 The signum optional param has the purpose
1976         of indicating which method signature to use, if the given server
1977         method has multiple signatures (defaults to 0).
1978
1979 The timeout and
1980         protocol optional params are the same as in the
1981         xmlrpc_client::send() method.
1982
1983 If set, the optional new_function_name
1984         parameter indicates which name should be used for the generated
1985         function. In case it is not set the function name will be
1986         auto-generated.
1987
1988 If the ++$$return_source$$++ optional parameter is
1989         set, the function will return the php source code to build the wrapper
1990         function, instead of evaluating it (useful to save the code and use it
1991         later as stand-alone xmlrpc client).
1992
1993 If the ++$$encode_php_objs$$++ optional parameter is
1994         set, instances of php objects later passed as parameters to the newly
1995         created function will receive a 'special' treatment that allows the
1996         server to rebuild them as php objects instead of simple arrays. Note
1997         that this entails using a "slightly augmented" version of the xmlrpc
1998         protocol (ie. using element attributes), which might not be understood
1999         by xmlrpc servers implemented using other libraries.
2000
2001 If the ++$$decode_php_objs$$++ optional parameter is
2002         set, instances of php objects that have been appropriately encoded by
2003         the server using a coordinate option will be deserialized as php
2004         objects instead of simple arrays (the same class definition should be
2005         present server side and client side).
2006
2007 __Note that this might pose a security risk__,
2008         since in order to rebuild the object instances their constructor
2009         method has to be invoked, and this means that the remote server can
2010         trigger execution of unforeseen php code on the client: not really a
2011         code injection, but almost. Please enable this option only when you
2012         trust the remote server.
2013
2014 In case of an error during generation of the wrapper function,
2015         FALSE is returned, otherwise the name (or source code) of the new
2016         function.
2017
2018 Known limitations: server must support
2019         system.methodsignature for the wanted xmlrpc
2020         method; for methods that expose multiple signatures, only one can be
2021         picked; for remote calls with nested xmlrpc params, the caller of the
2022         generated php function has to encode on its own the params passed to
2023         the php function if these are structs or arrays whose (sub)members
2024         include values of type base64.
2025
2026 Note: calling the generated php function 'might' be slow: a new
2027         xmlrpc client is created on every invocation and an xmlrpc-connection
2028         opened+closed. An extra 'debug' param is appended to the parameter
2029         list of the generated php function, useful for debugging
2030         purposes.
2031
2032 Example usage:
2033
2034
2035 [source, php]
2036 ----
2037
2038 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');
2039
2040 $function = wrap_xmlrpc_method($client, 'examples.getStateName');
2041
2042 if (!$function)
2043   die('Cannot introspect remote method');
2044 else {
2045   $stateno = 15;
2046   $statename = $function($a);
2047   if (is_a($statename, 'xmlrpcresp')) // call failed
2048   {
2049     echo 'Call failed: '.$statename->faultCode().'. Calling again with debug on';
2050     $function($a, true);
2051   }
2052   else
2053     echo "OK, state nr. $stateno is $statename";
2054 }
2055
2056 ----
2057
2058 [[wrap_php_function]]
2059
2060 ==== wrap_php_function
2061
2062 arraywrap_php_functionstring$funcnamestring$wrapper_function_namearray$extra_optionsGiven a user-defined PHP function, create a PHP 'wrapper'
2063         function that can be exposed as xmlrpc method from an xmlrpc_server
2064         object and called from remote clients, and return the appropriate
2065         definition to be added to a server's dispatch map.
2066
2067 The optional $wrapper_function_name
2068         specifies the name that will be used for the auto-generated
2069         function.
2070
2071 Since php is a typeless language, to infer types of input and
2072         output parameters, it relies on parsing the javadoc-style comment
2073         block associated with the given function. Usage of xmlrpc native types
2074         (such as datetime.dateTime.iso8601 and base64) in the docblock @param
2075         tag is also allowed, if you need the php function to receive/send data
2076         in that particular format (note that base64 encoding/decoding is
2077         transparently carried out by the lib, while datetime vals are passed
2078         around as strings).
2079
2080 Known limitations: only works for
2081         user-defined functions, not for PHP internal functions (reflection
2082         does not support retrieving number/type of params for those); the
2083         wrapped php function will not be able to programmatically return an
2084         xmlrpc error response.
2085
2086 If the ++$$return_source$$++ optional parameter is
2087         set, the function will return the php source code to build the wrapper
2088         function, instead of evaluating it (useful to save the code and use it
2089         later in a stand-alone xmlrpc server). It will be in the stored in the
2090         ++source++ member of the returned array.
2091
2092 If the ++$$suppress_warnings$$++ optional parameter
2093         is set, any runtime warning generated while processing the
2094         user-defined php function will be catched and not be printed in the
2095         generated xml response.
2096
2097 If the extra_options array contains the
2098         ++$$encode_php_objs$$++ value, wrapped functions returning
2099         php objects will generate "special" xmlrpc responses: when the xmlrpc
2100         decoding of those responses is carried out by this same lib, using the
2101         appropriate param in php_xmlrpc_decode(), the objects will be
2102         rebuilt.
2103
2104 In short: php objects can be serialized, too (except for their
2105         resource members), using this function. Other libs might choke on the
2106         very same xml that will be generated in this case (i.e. it has a
2107         nonstandard attribute on struct element tags)
2108
2109 If the ++$$decode_php_objs$$++ optional parameter is
2110         set, instances of php objects that have been appropriately encoded by
2111         the client using a coordinate option will be deserialized and passed
2112         to the user function as php objects instead of simple arrays (the same
2113         class definition should be present server side and client
2114         side).
2115
2116 __Note that this might pose a security risk__,
2117         since in order to rebuild the object instances their constructor
2118         method has to be invoked, and this means that the remote client can
2119         trigger execution of unforeseen php code on the server: not really a
2120         code injection, but almost. Please enable this option only when you
2121         trust the remote clients.
2122
2123 Example usage:
2124
2125
2126 [source, php]
2127 ----
2128 /**
2129 * State name from state number decoder. NB: do NOT remove this comment block.
2130 * @param integer $stateno the state number
2131 * @return string the name of the state (or error description)
2132 */
2133 function findstate($stateno)
2134 {
2135   global $stateNames;
2136   if (isset($stateNames[$stateno-1]))
2137   {
2138     return $stateNames[$stateno-1];
2139   }
2140   else
2141   {
2142     return "I don't have a state for the index '" . $stateno . "'";
2143   }
2144 }
2145
2146 // wrap php function, build xmlrpc server
2147 $methods = array();
2148 $findstate_sig = wrap_php_function('findstate');
2149 if ($findstate_sig)
2150   $methods['examples.getStateName'] = $findstate_sig;
2151 $srv = new xmlrpc_server($methods);
2152
2153 ----
2154
2155 [[deprecated]]
2156
2157 === Functions removed from the library
2158
2159 The following two functions have been deprecated in version 1.1 of
2160       the library, and removed in version 2, in order to avoid conflicts with
2161       the EPI xml-rpc library, which also defines two functions with the same
2162       names.
2163
2164 To ease the transition to the new naming scheme and avoid breaking
2165       existing implementations, the following scheme has been adopted:
2166
2167 * If EPI-XMLRPC is not active in the current PHP installation,
2168             the constant ++$$XMLRPC_EPI_ENABLED$$++ will be set to
2169             ++$$'0'$$++
2170
2171
2172 * If EPI-XMLRPC is active in the current PHP installation, the
2173             constant ++$$XMLRPC_EPI_ENABLED$$++ will be set to
2174             ++$$'1'$$++
2175
2176
2177
2178 The following documentation is kept for historical
2179       reference:
2180
2181 [[xmlrpcdecode]]
2182
2183 ==== xmlrpc_decode
2184
2185 mixedx mlrpc_decode xmlrpcval $xmlrpc_val Alias for php_xmlrpc_decode.
2186
2187 [[xmlrpcencode]]
2188
2189 ==== xmlrpc_encode
2190
2191 xmlrpcval xmlrpc_encode mixed $phpvalAlias for php_xmlrpc_encode.
2192
2193 [[debugging]]
2194
2195 === Debugging aids
2196
2197 ==== xmlrpc_debugmsg
2198
2199 void xmlrpc_debugmsgstring$debugstringSends the contents of $debugstring in XML
2200         comments in the server return payload. If a PHP client has debugging
2201         turned on, the user will be able to see server debug
2202         information.
2203
2204 Use this function in your methods so you can pass back
2205         diagnostic information. It is only available from
2206         __xmlrpcs.inc__.
2207
2208
2209 [[reserved]]
2210
2211 == Reserved methods
2212
2213 In order to extend the functionality offered by XML-RPC servers
2214     without impacting on the protocol, reserved methods are supported in this
2215     release.
2216
2217 All methods starting with system. are
2218     considered reserved by the server. PHP for XML-RPC itself provides four
2219     special methods, detailed in this chapter.
2220
2221 Note that all server objects will automatically respond to clients
2222     querying these methods, unless the property
2223     allow_system_funcs has been set to
2224     false before calling the
2225     service() method. This might pose a security risk
2226     if the server is exposed to public access, e.g. on the internet.
2227
2228
2229 === system.getCapabilities
2230
2231
2232 === system.listMethods
2233
2234 This method may be used to enumerate the methods implemented by
2235       the XML-RPC server.
2236
2237 The system.listMethods method requires no
2238       parameters. It returns an array of strings, each of which is the name of
2239       a method implemented by the server.
2240
2241 [[sysmethodsig]]
2242
2243 === system.methodSignature
2244
2245 This method takes one parameter, the name of a method implemented
2246       by the XML-RPC server.
2247
2248 It returns an array of possible signatures for this method. A
2249       signature is an array of types. The first of these types is the return
2250       type of the method, the rest are parameters.
2251
2252 Multiple signatures (i.e. overloading) are permitted: this is the
2253       reason that an array of signatures are returned by this method.
2254
2255 Signatures themselves are restricted to the top level parameters
2256       expected by a method. For instance if a method expects one array of
2257       structs as a parameter, and it returns a string, its signature is simply
2258       "string, array". If it expects three integers, its signature is "string,
2259       int, int, int".
2260
2261 For parameters that can be of more than one type, the "undefined"
2262       string is supported.
2263
2264 If no signature is defined for the method, a not-array value is
2265       returned. Therefore this is the way to test for a non-signature, if
2266       $resp below is the response object from a method
2267       call to system.methodSignature:
2268
2269 [source, php]
2270 ----
2271
2272 $v = $resp->value();
2273 if ($v->kindOf() != "array") {
2274   // then the method did not have a signature defined
2275 }
2276
2277 ----
2278
2279 See the __introspect.php__ demo included in this
2280       distribution for an example of using this method.
2281
2282 [[sysmethhelp]]
2283
2284 === system.methodHelp
2285
2286 This method takes one parameter, the name of a method implemented
2287       by the XML-RPC server.
2288
2289 It returns a documentation string describing the use of that
2290       method. If no such string is available, an empty string is
2291       returned.
2292
2293 The documentation string may contain HTML markup.
2294
2295 === system.multicall
2296
2297 This method takes one parameter, an array of 'request' struct
2298       types. Each request struct must contain a
2299       methodName member of type string and a
2300       params member of type array, and corresponds to
2301       the invocation of the corresponding method.
2302
2303 It returns a response of type array, with each value of the array
2304       being either an error struct (containing the faultCode and faultString
2305       members) or the successful response value of the corresponding single
2306       method call.
2307
2308
2309 [[examples]]
2310
2311 == Examples
2312
2313 The best examples are to be found in the sample files included with
2314     the distribution. Some are included here.
2315
2316 [[statename]]
2317
2318 === XML-RPC client: state name query
2319
2320 Code to get the corresponding state name from a number (1-50) from
2321       the demo server available on SourceForge
2322
2323 [source, php]
2324 ----
2325
2326   $m = new xmlrpcmsg('examples.getStateName',
2327     array(new xmlrpcval($HTTP_POST_VARS["stateno"], "int")));
2328   $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
2329   $r = $c->send($m);
2330   if (!$r->faultCode()) {
2331       $v = $r->value();
2332       print "State number " . htmlentities($HTTP_POST_VARS["stateno"]) . " is " .
2333         htmlentities($v->scalarval()) . "<BR>";
2334       print "<HR>I got this value back<BR><PRE>" .
2335         htmlentities($r->serialize()) . "</PRE><HR>\n";
2336   } else {
2337       print "Fault <BR>";
2338       print "Code: " . htmlentities($r->faultCode()) . "<BR>" .
2339             "Reason: '" . htmlentities($r->faultString()) . "'<BR>";
2340   }
2341
2342 ----
2343
2344 === Executing a multicall call
2345
2346 To be documented...
2347
2348
2349 [[faq]]
2350
2351 [qanda]
2352 == Frequently Asked Questions
2353
2354 === Hi
2355
2356 ==== How to send custom XML as payload of a method call::
2357
2358 Unfortunately, at the time the XML-RPC spec was designed, support
2359       for namespaces in XML was not as ubiquitous as it is now. As a
2360       consequence, no support was provided in the protocol for embedding XML
2361       elements from other namespaces into an xmlrpc request.
2362
2363 To send an XML "chunk" as payload of a method call or response,
2364       two options are available: either send the complete XML block as a
2365       string xmlrpc value, or as a base64 value. Since the '&lt;' character in
2366       string values is encoded as '&amp;lt;' in the xml payload of the method
2367       call, the XML string will not break the surrounding xmlrpc, unless
2368       characters outside of the assumed character set are used. The second
2369       method has the added benefits of working independently of the charset
2370       encoding used for the xml to be transmitted, and preserving exactly
2371       whitespace, whilst incurring in some extra message length and cpu load
2372       (for carrying out the base64 encoding/decoding).
2373
2374
2375 ==== Is there any limitation on the size of the requests / responses that can be successfully sent?::
2376
2377 Yes. But I have no hard figure to give; it most likely will depend
2378       on the version of PHP in usage and its configuration.
2379
2380 Keep in mind that this library is not optimized for speed nor for
2381       memory usage. Better alternatives exist when there are strict
2382       requirements on throughput or resource usage, such as the php native
2383       xmlrpc extension (see the PHP manual for more information).
2384
2385 Keep in mind also that HTTP is probably not the best choice in
2386       such a situation, and XML is a deadly enemy. CSV formatted data over
2387       socket would be much more efficient.
2388
2389 If you really need to move a massive amount of data around, and
2390       you are crazy enough to do it using phpxmlrpc, your best bet is to
2391       bypass usage of the xmlrpcval objects, at least in the decoding phase,
2392       and have the server (or client) object return to the calling function
2393       directly php values (see xmlrpc_client::return_type
2394       and xmlrpc_server::functions_parameters_type for more
2395       details).
2396
2397
2398 ==== My server (client) returns an error whenever the client (server) returns accented characters
2399
2400 To be documented...
2401
2402
2403 ==== How to enable long-lasting method calls
2404
2405 To be documented...
2406
2407
2408 ==== My client returns "XML-RPC Fault #2: Invalid return payload: enable debugging to examine incoming payload": what should I do?
2409
2410 The response you are seeing is a default error response that the
2411       client object returns to the php application when the server did not
2412       respond to the call with a valid xmlrpc response.
2413
2414 The most likely cause is that you are not using the correct URL
2415       when creating the client object, or you do not have appropriate access
2416       rights to the web page you are requesting, or some other common http
2417       misconfiguration.
2418
2419 To find out what the server is really returning to your client,
2420       you have to enable the debug mode of the client, using
2421       $client-&gt;setdebug(1);
2422
2423
2424 ==== How can I save to a file the xml of the xmlrpc responses received from servers?
2425
2426 If what you need is to save the responses received from the server
2427       as xml, you have two options:
2428
2429 1- use the serialize() method on the response object.
2430
2431
2432 [source, php]
2433 ----
2434
2435 $resp = $client->send($msg);
2436 if (!$resp->faultCode())
2437   $data_to_be_saved = $resp->serialize();
2438
2439 ----
2440
2441 Note that this will not be 100% accurate, since the xml generated
2442       by the response object can be different from the xml received,
2443       especially if there is some character set conversion involved, or such
2444       (eg. if you receive an empty string tag as &lt;string/&gt;, serialize()
2445       will output &lt;string&gt;&lt;/string&gt;), or if the server sent back
2446       as response something invalid (in which case the xml generated client
2447       side using serialize() will correspond to the error response generated
2448       internally by the lib).
2449
2450 2 - set the client object to return the raw xml received instead
2451       of the decoded objects:
2452
2453
2454 [source, php]
2455 ----
2456
2457 $client = new xmlrpc_client($url);
2458 $client->return_type = 'xml';
2459 $resp = $client->send($msg);
2460 if (!$resp->faultCode())
2461   $data_to_be_saved = $resp->value();
2462
2463 ----
2464
2465 Note that using this method the xml response response will not be
2466       parsed at all by the library, only the http communication protocol will
2467       be checked. This means that xmlrpc responses sent by the server that
2468       would have generated an error response on the client (eg. malformed xml,
2469       responses that have faultcode set, etc...) now will not be flagged as
2470       invalid, and you might end up saving not valid xml but random
2471       junk...
2472
2473
2474 ==== Can I use the ms windows character set?
2475
2476 If the data your application is using comes from a Microsoft
2477       application, there are some chances that the character set used to
2478       encode it is CP1252 (the same might apply to data received from an
2479       external xmlrpc server/client, but it is quite rare to find xmlrpc
2480       toolkits that encode to CP1252 instead of UTF8). It is a character set
2481       which is "almost" compatible with ISO 8859-1, but for a few extra
2482       characters.
2483
2484 PHP-XMLRPC only supports the ISO 8859-1 and UTF8 character sets.
2485       The net result of this situation is that those extra characters will not
2486       be properly encoded, and will be received at the other end of the
2487       XML-RPC transmission as "garbled data". Unfortunately the library cannot
2488       provide real support for CP1252 because of limitations in the PHP 4 xml
2489       parser. Luckily, we tried our best to support this character set anyway,
2490       and, since version 2.2.1, there is some form of support, left commented
2491       in the code.
2492
2493 To properly encode outgoing data that is natively in CP1252, you
2494       will have to uncomment all relative code in the file
2495       __xmlrpc.inc__ (you can search for the string "1252"),
2496       then set ++$$$GLOBALS['xmlrpc_internalencoding']='CP1252';$$++
2497       Please note that all incoming data will then be fed to your application
2498       as UTF-8 to avoid any potential data loss.
2499
2500
2501 ==== Does the library support using cookies / http sessions?
2502
2503 In short: yes, but a little coding is needed to make it
2504       happen.
2505
2506 The code below uses sessions to e.g. let the client store a value
2507       on the server and retrieve it later.
2508
2509 [source, php]
2510 ----
2511
2512 $resp = $client->send(new xmlrpcmsg('registervalue', array(new xmlrpcval('foo'), new xmlrpcval('bar'))));
2513 if (!$resp->faultCode())
2514 {
2515   $cookies = $resp->cookies();
2516   if (array_key_exists('PHPSESSID', $cookies)) // nb: make sure to use the correct session cookie name
2517   {
2518     $session_id = $cookies['PHPSESSID']['value'];
2519
2520     // do some other stuff here...
2521
2522     $client->setcookie('PHPSESSID', $session_id);
2523     $val = $client->send(new xmlrpcmsg('getvalue', array(new xmlrpcval('foo')));
2524   }
2525 }
2526
2527 ----
2528
2529 Server-side sessions are handled normally like in any other
2530       php application. Please see the php manual for more information about
2531       sessions.
2532
2533 NB: unlike web browsers, not all xmlrpc clients support usage of
2534       http cookies. If you have troubles with sessions and control only the
2535       server side of the communication, please check with the makers of the
2536       xmlrpc client in use.
2537
2538
2539 [[integration]]
2540
2541 [appendix]
2542 == Integration with the PHP xmlrpc extension
2543
2544 To be documented more...
2545
2546 In short: for the fastest execution possible, you can enable the php
2547     native xmlrpc extension, and use it in conjunction with phpxmlrpc. The
2548     following code snippet gives an example of such integration
2549
2550
2551 [source, php]
2552 ----
2553
2554 /*** client side ***/
2555 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');
2556
2557 // tell the client to return raw xml as response value
2558 $c->return_type = 'xml';
2559
2560 // let the native xmlrpc extension take care of encoding request parameters
2561 $r = $c->send(xmlrpc_encode_request('examples.getStateName', $_POST['stateno']));
2562
2563 if ($r->faultCode())
2564   // HTTP transport error
2565   echo 'Got error '.$r->faultCode();
2566 else
2567 {
2568   // HTTP request OK, but XML returned from server not parsed yet
2569   $v = xmlrpc_decode($r->value());
2570   // check if we got a valid xmlrpc response from server
2571   if ($v === NULL)
2572     echo 'Got invalid response';
2573   else
2574   // check if server sent a fault response
2575   if (xmlrpc_is_fault($v))
2576     echo 'Got xmlrpc fault '.$v['faultCode'];
2577   else
2578     echo'Got response: '.htmlentities($v);
2579 }
2580
2581 ----
2582
2583
2584 [[substitution]]
2585
2586 [appendix]
2587 == Substitution of the PHP xmlrpc extension
2588
2589 Yet another interesting situation is when you are using a ready-made
2590     php application, that provides support for the XMLRPC protocol via the
2591     native php xmlrpc extension, but the extension is not available on your
2592     php install (e.g. because of shared hosting constraints).
2593
2594 Since version 2.1, the PHP-XMLRPC library provides a compatibility
2595     layer that aims to be 100% compliant with the xmlrpc extension API. This
2596     means that any code written to run on the extension should obtain the
2597     exact same results, albeit using more resources and a longer processing
2598     time, using the PHP-XMLRPC library and the extension compatibility module.
2599     The module is part of the EXTRAS package, available as a separate download
2600     from the sourceforge.net website, since version 0.2
2601
2602
2603 [[enough]]
2604
2605 [appendix]
2606 == 'Enough of xmlrpcvals!': new style library usage
2607
2608 To be documented...
2609
2610 In the meantime, see docs about xmlrpc_client::return_type and
2611     xmlrpc_server::functions_parameters_types, as well as php_xmlrpc_encode,
2612     php_xmlrpc_decode and php_xmlrpc_decode_xml
2613
2614
2615 [[debugger]]
2616
2617 [appendix]
2618 == Usage of the debugger
2619
2620 A webservice debugger is included in the library to help during
2621     development and testing.
2622
2623 The interface should be self-explicative enough to need little
2624     documentation.
2625
2626 image::debugger.gif[,,,,align="center"]
2627
2628 The most useful feature of the debugger is without doubt the "Show
2629     debug info" option. It allows to have a screen dump of the complete http
2630     communication between client and server, including the http headers as
2631     well as the request and response payloads, and is invaluable when
2632     troubleshooting problems with charset encoding, authentication or http
2633     compression.
2634
2635 The debugger can take advantage of the JSONRPC library extension, to
2636     allow debugging of JSON-RPC webservices, and of the JS-XMLRPC library
2637     visual editor to allow easy mouse-driven construction of the payload for
2638     remote methods. Both components have to be downloaded separately from the
2639     sourceforge.net web pages and copied to the debugger directory to enable
2640     the extra functionality:
2641
2642
2643 * to enable jsonrpc functionality, download the PHP-XMLRPC
2644           EXTRAS package, and copy the file __jsonrpc.inc__
2645           either to the same directory as the debugger or somewhere in your
2646           php include path
2647
2648
2649 * to enable the visual value editing dialog, download the
2650           JS-XMLRPC library, and copy somewhere in the web root files
2651           __visualeditor.php__,
2652           __visualeditor.css__ and the folders
2653           __yui__ and __img__. Then edit the
2654           debugger file __controller.php__ and set
2655           appropriately the variable $editorpath.
2656
2657
2658 [[news]]
2659
2660 [appendix]
2661 == Whats's new
2662
2663 __Note:__ not all items the following list have
2664     (yet) been fully documented, and some might not be present in any other
2665     chapter in the manual. To find a more detailed description of new
2666     functions and methods please take a look at the source code of the
2667     library, which is quite thoroughly commented in phpdoc form.
2668
2669 === 4.0.0
2670
2671 ...to be documented...
2672
2673 === 3.0.0
2674
2675 __Note:__ this is the last release of the library that will support PHP 5.1 and up.
2676       Future releases will target php 5.3 as minimum supported version.
2677
2678 * when using curl and keepalive, reset curl handle if we did not get back an http 200 response (eg a 302)
2679
2680 * omit port on http 'Host' header if it is 80
2681
2682 * test suite allows interrogating https servers ignoring their certs
2683
2684 * method setAcceptedCompression was failing to disable reception of compressed responses if the
2685          client supported them
2686
2687 === 3.0.0 beta
2688
2689 This is the first release of the library to only support PHP 5.
2690       Some legacy code has been removed, and support for features such as
2691       exceptions and dateTime objects introduced.
2692
2693 The "beta" tag is meant to indicate the fact that the refactoring
2694       has been more widespread than in precedent releases and that more
2695       changes are likely to be introduced with time - the library is still
2696       considered to be production quality.
2697
2698 * improved: removed all usage of php functions deprecated in
2699             php 5.3, usage of assign-by-ref when creating new objects
2700             etc...
2701
2702 * improved: add support for the &lt;ex:nil/&gt; tag used by
2703             the apache library, both in input and output
2704
2705 * improved: add support for dateTime
2706             objects in both in php_xmlrpc_encode and as
2707             parameter for constructor of
2708             xmlrpcval
2709
2710 * improved: add support for timestamps as parameter for
2711             constructor of xmlrpcval
2712
2713 * improved: add option 'dates_as_objects' to
2714             php_xmlrpc_decode to return
2715             dateTime objects for xmlrpc
2716             datetimes
2717
2718 * improved: add new method
2719             SetCurlOptions to
2720             xmrlpc_client to allow extra flexibility in
2721             tweaking http config, such as explicitly binding to an ip
2722             address
2723
2724 * improved: add new method
2725             SetUserAgent to
2726             xmrlpc_client to to allow having different
2727             user-agent http headers
2728
2729 * improved: add a new member variable in server class to allow
2730             fine-tuning of the encoding of returned values when the server is
2731             in 'phpvals' mode
2732
2733 * improved: allow servers in 'xmlrpcvals' mode to also
2734             register plain php functions by defining them in the dispatch map
2735             with an added option
2736
2737 * improved: catch exceptions thrown during execution of php
2738             functions exposed as methods by the server
2739
2740 * fixed: bad encoding if same object is encoded twice using
2741             php_xmlrpc_encode
2742
2743 === 2.2.2
2744
2745 __Note:__ this is the last release of the
2746       library that will support PHP 4. Future releases (if any) should target
2747       php 5.0 as minimum supported version.
2748
2749 * fixed: encoding of utf-8 characters outside of the BMP
2750             plane
2751
2752 * fixed: character set declarations surrounded by double
2753             quotes were not recognized in http headers
2754
2755 * fixed: be more tolerant in detection of charset in http
2756             headers
2757
2758 * fixed: fix detection of zlib.output_compression
2759
2760 * fixed: use feof() to test if socket connections are to be
2761             closed instead of the number of bytes read (rare bug when
2762             communicating with some servers)
2763
2764 * fixed: format floating point values using the correct
2765             decimal separator even when php locale is set to one that uses
2766             comma
2767
2768 * fixed: improve robustness of the debugger when parsing weird
2769             results from non-compliant servers
2770
2771 * php warning when receiving 'false' in a bool value
2772
2773 * improved: allow the add_to_map server method to add docs for
2774             single params too
2775
2776 * improved: added the possibility to wrap for exposure as
2777             xmlrpc methods plain php class methods, object methods and even
2778             whole classes
2779
2780 === 2.2.1
2781
2782 * fixed: work aroung bug in php 5.2.2 which broke support of
2783           HTTP_RAW_POST_DATA
2784
2785 * fixed: is_dir parameter of setCaCertificate() method is
2786           reversed
2787
2788 * fixed: a php warning in xmlrpc_client creator method
2789
2790 * fixed: parsing of '1e+1' as valid float
2791
2792 * fixed: allow errorlevel 3 to work when prev. error handler was
2793           a static method
2794
2795 * fixed: usage of client::setcookie() for multiple cookies in
2796           non-ssl mode
2797
2798 * improved: support for CP1252 charset is not part or the
2799           library but almost possible
2800
2801 * improved: more info when curl is enabled and debug mode is
2802           on
2803 === 2.2
2804
2805 * fixed: debugger errors on php installs with magic_quotes_gpc
2806           on
2807
2808 * fixed: support for https connections via proxy
2809
2810 * fixed: wrap_xmlrpc_method() generated code failed to properly
2811           encode php objects
2812
2813 * improved: slightly faster encoding of data which is internally
2814           UTF-8
2815
2816 * improved: debugger always generates a 'null' id for jsonrpc if
2817           user omits it
2818
2819 * new: debugger can take advantage of a graphical value builder
2820           (it has to be downloaded separately, as part of jsxmlrpc package.
2821           See Appendix D for more details)
2822
2823 * new: support for the &lt;NIL/&gt; xmlrpc extension. see below
2824           for more details
2825
2826 * new: server support for the system.getCapabilities xmlrpc
2827           extension
2828
2829 * new: <<wrap_xmlrpc_method,wrap_xmlrpc_method()>>
2830           accepts two new options: debug and return_on_fault
2831
2832 === 2.1
2833
2834 * The wrap_php_function and
2835             wrap_xmlrpc_method functions have been moved
2836             out of the base library file __xmlrpc.inc__ into
2837             a file of their own: __$$xmlrpc_wrappers.php$$__. You
2838             will have to include() / require() it in your scripts if you have
2839             been using those functions. For increased security, the automatic
2840             rebuilding of php object instances out of received xmlrpc structs
2841             in wrap_xmlrpc_method() has been disabled
2842             (but it can be optionally re-enabled). Both
2843             wrap_php_function() and
2844             wrap_xmlrpc_method() functions accept many
2845             more options to fine tune their behaviour, including one to return
2846             the php code to be saved and later used as standalone php
2847             script
2848
2849 * The constructor of xmlrpcval() values has seen some internal
2850             changes, and it will not throw a php warning anymore when invoked
2851             using an unknown xmlrpc type: the error will only be written to
2852             php error log. Also ++$$new xmlrpcval('true', 'boolean')$$++
2853             is not supported anymore
2854
2855 * The new function
2856             php_xmlrpc_decode_xml() will take the xml
2857             representation of either an xmlrpc request, response or single
2858             value and return the corresponding php-xmlrpc object
2859             instance
2860
2861 * A new function wrap_xmlrpc_server()has
2862             been added, to wrap all (or some) of the methods exposed by a
2863             remote xmlrpc server into a php class
2864
2865 * A new file has been added:
2866             __$$verify_compat.php$$__, to help users diagnose the
2867             level of compliance of their php installation with the
2868             library
2869
2870 * Restored compatibility with php 4.0.5 (for those poor souls
2871             still stuck on it)
2872
2873 * Method xmlrpc_server-&gt;service()
2874             now returns a value: either the response payload or xmlrpcresp
2875             object instance
2876
2877 * Method
2878             xmlrpc_server-&gt;add_to_map() now
2879             accepts xmlrpc methods with no param definitions
2880
2881 * Documentation for single parameters of exposed methods can
2882             be added to the dispatch map (and turned into html docs in
2883             conjunction with a future release of the 'extras' package)
2884
2885 * Full response payload is saved into xmlrpcresp object for
2886             further debugging
2887
2888 * The debugger can now generate code that wraps a remote
2889             method into a php function (works for jsonrpc, too); it also has
2890             better support for being activated via a single GET call (e.g. for
2891             integration into other tools)
2892
2893 * Stricter parsing of incoming xmlrpc messages: two more
2894             invalid cases are now detected (double ++data++
2895             element inside ++array++ and
2896             ++struct++/++array++ after scalar
2897             inside ++value++ element)
2898
2899 * More logging of errors in a lot of situations
2900
2901 * Javadoc documentation of lib files (almost) complete
2902
2903 * Many performance tweaks and code cleanups, plus the usual
2904             crop of bugs fixed (see NEWS file for complete list of
2905             bugs)
2906
2907 * Lib internals have been modified to provide better support
2908             for grafting extra functionality on top of it. Stay tuned for
2909             future releases of the EXTRAS package (or go read Appendix
2910             B)...
2911
2912 === 2.0 final
2913
2914 * Added to the client class the possibility to use Digest and
2915             NTLM authentication methods (when using the CURL library) for
2916             connecting to servers and NTLM for connecting to proxies
2917
2918 * Added to the client class the possibility to specify
2919             alternate certificate files/directories for authenticating the
2920             peer with when using HTTPS communication
2921
2922 * Reviewed all examples and added a new demo file, containing
2923             a proxy to forward xmlrpc requests to other servers (useful e.g.
2924             for ajax coding)
2925
2926 * The debugger has been upgraded to reflect the new client
2927             capabilities
2928
2929 * All known bugs have been squashed, and the lib is more
2930             tolerant than ever of commonly-found mistakes
2931
2932 === 2.0 Release candidate 3
2933
2934 * Added to server class the property
2935             functions_parameters_type, that allows the
2936             server to register plain php functions as xmlrpc methods (i.e.
2937             functions that do not take an xmlrpcmsg object as unique
2938             param)
2939
2940 * let server and client objects serialize calls using a
2941             specified character set encoding for the produced xml instead of
2942             US-ASCII (ISO-8859-1 and UTF-8 supported)
2943
2944 * let php_xmlrpc_decode accept xmlrpcmsg objects as valid
2945             input
2946
2947 * 'class::method' syntax is now accepted in the server
2948             dispatch map
2949
2950 * xmlrpc_clent::SetDebug() accepts
2951             integer values instead of a boolean value, with debugging level 2
2952             adding to the information printed to screen the complete client
2953             request
2954
2955 === 2.0 Release candidate 2
2956
2957 * Added a new property of the client object:
2958             ++$$xmlrpc_client-&gt;return_type$$++, indicating whether
2959             calls to the send() method will return xmlrpcresp objects whose
2960             value() is an xmlrpcval object, a php value (automatically
2961             decoded) or the raw xml received from the server.
2962
2963 * Added in the extras dir. two new library file:
2964             __jsonrpc.inc__ and
2965             __jsonrpcs.inc__ containing new classes that
2966             implement support for the json-rpc protocol (alpha quality
2967             code)
2968
2969 * Added a new client method: ++setKey($key,
2970             $keypass)++ to be used in HTTPS connections
2971
2972 * Added a new file containing some benchmarks in the testsuite
2973             directory
2974
2975 === 2.0 Release candidate 1
2976
2977 * Support for HTTP proxies (new method:
2978           ++$$xmlrpc_client::setProxy()$$++)
2979
2980 * Support HTTP compression of both requests and responses.
2981           Clients can specify what kind of compression they accept for
2982           responses between deflate/gzip/any, and whether to compress the
2983           requests. Servers by default compress responses to clients that
2984           explicitly declare support for compression (new methods:
2985           ++$$xmlrpc_client::setAcceptedCompression()$$++,
2986           ++$$xmlrpc_client::setRequestCompression()$$++). Note that the
2987           ZLIB php extension needs to be enabled in PHP to support
2988           compression.
2989
2990 * Implement HTTP 1.1 connections, but only if CURL is enabled
2991           (added an extra parameter to
2992           ++$$xmlrpc_client::xmlrpc_client$$++ to set the desired HTTP
2993           protocol at creation time and a new supported value for the last
2994           parameter of ++$$xmlrpc_client::send$$++, which now can be
2995           safely omitted if it has been specified at creation time)
2996 +
2997 With PHP versions greater than 4.3.8 keep-alives are enabled
2998           by default for HTTP 1.1 connections. This should yield faster
2999           execution times when making multiple calls in sequence to the same
3000           xml-rpc server from a single client.
3001
3002 * Introduce support for cookies. Cookies to be sent to the
3003           server with a request can be set using
3004           ++$$xmlrpc_client::setCookie()$$++, while cookies received from
3005           the server are found in ++xmlrpcresp::cookies()++. It is
3006           left to the user to check for validity of received cookies and
3007           decide whether they apply to successive calls or not.
3008
3009 * Better support for detecting different character set encodings
3010           of xml-rpc requests and responses: both client and server objects
3011           will correctly detect the charset encoding of received xml, and use
3012           an appropriate xml parser.
3013 +
3014 Supported encodings are US-ASCII, UTF-8 and ISO-8859-1.
3015
3016 * Added one new xmlrpcmsg constructor syntax, allowing usage of
3017           a single string with the complete URL of the target server
3018
3019 * Convert xml-rpc boolean values into native php values instead
3020           of 0 and 1
3021
3022 * Force the ++$$php_xmlrpc_encode$$++ function to properly
3023           encode numerically indexed php arrays into xml-rpc arrays
3024           (numerically indexed php arrays always start with a key of 0 and
3025           increment keys by values of 1)
3026
3027 * Prevent the ++$$php_xmlrpc_encode$$++ function from
3028           further re-encoding any objects of class ++xmlrpcval++ that
3029           are passed to it. This allows to call the function with arguments
3030           consisting of mixed php values / xmlrpcval objects.
3031
3032 * Allow a server to NOT respond to system.* method calls
3033           (setting the ++$$$server-&gt;allow_system_funcs$$++
3034           property).
3035
3036 * Implement a new xmlrpcval method to determine if a value of
3037           type struct has a member of a given name without having to loop
3038           trough all members: ++xmlrpcval::structMemExists()++
3039
3040 * Expand methods ++xmlrpcval::addArray++,
3041           ++addScalar++ and ++addStruct++ allowing extra php
3042           values to be added to xmlrpcval objects already formed.
3043
3044 * Let the ++$$xmlrpc_client::send$$++ method accept an XML
3045           string for sending instead of an xmlrpcmsg object, to facilitate
3046           debugging and integration with the php native xmlrpc
3047           extension
3048
3049 * Extend the ++$$php_xmlrpc_encode$$++ and
3050           ++$$php_xmlrpc_decode$$++ functions to allow serialization and
3051           rebuilding of PHP objects. To successfully rebuild a serialized
3052           object, the object class must be defined in the deserializing end of
3053           the transfer. Note that object members of type resource will be
3054           deserialized as NULL values.
3055 +
3056 Note that his has been implemented adding a "php_class"
3057           attribute to xml representation of xmlrpcval of STRUCT type, which,
3058           strictly speaking, breaks the xml-rpc spec. Other xmlrpc
3059           implementations are supposed to ignore such an attribute (unless
3060           they implement a brain-dead custom xml parser...), so it should be
3061           safe enabling it in heterogeneous environments. The activation of
3062           this feature is done by usage of an option passed as second
3063           parameter to both ++$$php_xmlrpc_encode$$++ and
3064           ++$$php_xmlrpc_decode$$++.
3065
3066 * Extend the ++$$php_xmlrpc_encode$$++ function to allow
3067           automatic serialization of iso8601-conforming php strings as
3068           datetime.iso8601 xmlrpcvals, by usage of an optional
3069           parameter
3070
3071 * Added an automatic stub code generator for converting xmlrpc
3072           methods to php functions and vice-versa.
3073 +
3074 This is done via two new functions:
3075           ++$$wrap_php_function$$++ and ++$$wrap_xmlrpc_method$$++,
3076           and has many caveats, with php being a typeless language and
3077           all...
3078
3079 * Allow object methods to be used in server dispatch map
3080
3081 * Added a complete debugger solution, in the
3082           __debugger__ folder
3083
3084 * Added configurable server-side debug messages, controlled by
3085           the new method ++$$xmlrpc_server::SetDebug()$$++. At level 0,
3086           no debug messages are sent to the client; level 1 is the same as the
3087           old behaviour; at level 2 a lot more info is echoed back to the
3088           client, regarding the received call; at level 3 all warnings raised
3089           during server processing are trapped (this prevents breaking the xml
3090           to be echoed back to the client) and added to the debug info sent
3091           back to the client
3092
3093 * New XML parsing code, yields smaller memory footprint and
3094           faster execution times, not to mention complete elimination of the
3095           dreaded __eval()__ construct, so prone to code
3096           injection exploits
3097
3098 * Rewritten most of the error messages, making text more
3099           explicative
3100
3101 ++++++++++++++++++++++++++++++++++++++
3102 <!-- Keep this comment at the end of the file
3103 Local variables:
3104 mode: sgml
3105 sgml-omittag:nil
3106 sgml-shorttag:t
3107 sgml-minimize-attributes:nil
3108 sgml-always-quote-attributes:t
3109 sgml-indent-step:2
3110 sgml-indent-data:t
3111 sgml-parent-document:nil
3112 sgml-exposed-tags:nil
3113 sgml-local-catalogs:nil
3114 sgml-local-ecat-files:nil
3115 sgml-namecase-general:t
3116 sgml-general-insert-case:lower
3117 End:
3118 -->
3119 ++++++++++++++++++++++++++++++++++++++