Support i8 type
[plcapi.git] / doc / manual / phpxmlrpc_manual.adoc
1 = XML-RPC for PHP
2 :revision: 4.0.0
3 :keywords: xmlrpc, xml, rpc, webservices, http
4 :toc: left
5 :imagesdir: images
6 :source-highlighter: highlightjs
7
8
9 [preface]
10 == Introduction
11
12 WARNING: THIS MANUAL HAS NOT YET BEEN UPDATED TO REFLECT ALL THE CHANGES WHICH HAVE MADE IN VERSION 4. *DO NOT USE* FOR NOW. You can find the API documentation at link:$$http://gggeek.github.io/phpxmlrpc/doc-4/api/index.html$$[http://gggeek.github.io/phpxmlrpc/doc-4/api/index.html]
13
14 This collection of PHP classes provides a framework for writing XML-RPC clients and servers in PHP.
15
16 Main goals of the project are ease of use, flexibility and completeness.
17
18 The original author is Edd Dumbill of link:$$http://usefulinc.com/$$[Useful Information Company]. As of the 1.0 stable
19     release, the project was opened to wider involvement and moved to
20     link:$$http://phpxmlrpc.sourceforge.net/$$[SourceForge]; later, to link:$$https://github.com/gggeek/phpxmlrpc$$[Github]
21
22 XML-RPC is a format devised by link:$$http://www.userland.com/$$[Userland Software] for achieving remote procedure call
23     via XML using HTTP as the transport. XML-RPC has its own web site, link:$$http://www.xmlrpc.com/$$[www.xmlrpc.com]
24
25 A list of XML-RPC implementations for other languages such as Perl and Python can be found on the
26     link:$$http://www.xmlrpc.com/$$[www.xmlrpc.com] site.
27
28 === Acknowledgements
29
30 Daniel E. Baumann
31
32 James Bercegay
33
34 Leon Blackwell
35
36 Stephane Bortzmeyer
37
38 Daniel Convissor
39
40 Geoffrey T. Dairiki
41
42 Stefan Esser
43
44 James Flemer
45
46 Ernst de Haan
47
48 Tom Knight
49
50 Axel Kollmorgen
51
52 Peter Kocks
53
54 Daniel Krippner
55
56 {empty}S. Kuip
57
58 {empty}A. Lambert
59
60 Frederic Lecointre
61
62 Dan Libby
63
64 Arnaud Limbourg
65
66 Ernest MacDougal Campbell III
67
68 Lukasz Mach
69
70 Kjartan Mannes
71
72 Ben Margolin
73
74 Nicolay Mausz
75
76 Justin Miller
77
78 Jan Pfeifer
79
80 Giancarlo Pinerolo
81
82 Peter Russel
83
84 Jean-Jacques Sarton
85
86 Viliam Simko
87
88 Idan Sofer
89
90 Douglas Squirrel
91
92 Heiko Stübner
93
94 Anatoly Techtonik
95
96 Tommaso Trani
97
98 Eric van der Vlist
99
100 Christian Wenz
101
102 Jim Winstead
103
104 Przemyslaw Wroblewski
105
106 Bruno Zanetti Melotti
107
108
109 [[requirements]]
110 == System Requirements
111
112 The library has been designed with goals of flexibility and backward compatibility. As such, it supports a wide range of
113     PHP installs. Note that not all features of the lib are available in every configuration.
114
115 The __minimum supported__ PHP version is 5.3.
116
117 If you wish to use HTTPS or HTTP 1.1 to communicate with remote servers, or to use NTLM authentication, you need the
118     *curl* extension compiled into your PHP installation.
119
120 If you wish to receive XML-RPC requests or responses in any other character set than US-ASCII, ISO-8859-1 or UTF-8, you
121     will need the *mbstring* extension compiled into your PHP installation.
122
123 The *xmlrpc* native extension is not required to be compiled into your PHP installation, but if it is, there will be no
124     interference with the operation of this library.
125
126
127 [[manifest]]
128 == Files in the distribution
129
130 debugger/*:: a graphical debugger which can be used to test calls to xmlrpc servers
131
132 demo/*:: example code for implementing both xmlrpc client and server functionality
133
134 doc/*:: the documentation/ this manual, and the list of API changes between versions 3 and 4
135
136 extras/rsakey.pem:: A test certificate key for the SSL support, which can be used to generate dummy certificates. It has
137     the passphrase "test."
138
139 extras/test.pl, extras/test.py:: Perl and Python programs to exercise server.php to test that some of the methods work.
140
141 extras/workspace.testPhpServer.fttb:: Frontier scripts to exercise the demo server. Thanks to Dave Winer for permission
142     to include these. See link:$$http://www.xmlrpc.com/discuss/msgReader$853$$[Dave's announcement of these.]
143
144 lib/*:: a compatibility layer for applications which still rely on version 3 of the API
145
146 src/*:: the XML-RPC library classes. You can autoload these via Composer, or via a dedicated Autoloader class
147
148 tests/*:: the test suite for the library, written using PhpUnit, and the configuration to run it on Travis
149
150
151 [[bugs]]
152
153 == Known Bugs
154
155 Known bugs are tracked using the link:$$https://github.com/gggeek/phpxmlrpc/issues$$[GitHub issue tracker]
156
157 == Known limitations
158
159 This started out as a bare framework. Many "nice" bits have been put in over time, but backwards compatibility has
160     always taken precedence over API cleanups. As such, you might find some API choices questionable.
161
162 Specifically, very little type validation or coercion has been put in. PHP being a loosely-typed language, this is
163     going to have to be done explicitly (in other words: you can call a lot of library functions passing them arguments
164     of the wrong type and receive an error message only much further down the code, where it will be difficult to
165     understand).
166
167 dateTime.iso8601 is supported opaquely. It can't be done natively as the XML-RPC specification explicitly forbids
168     passing of timezone specifiers in ISO8601 format dates. You can, however, use the PhpXmlRpc\Helper\Date class to do
169     the encoding and decoding for you.
170
171 Very little HTTP response checking is performed (e.g. HTTP redirects are not followed and the Content-Length HTTP
172     header, mandated by the xml-rpc spec, is not validated); cookie support still involves quite a bit of coding on the
173     part of the user.
174
175 Support for receiving from servers version 1 cookies (i.e. conforming to RFC 2965) is quite incomplete, and might cause
176     unforeseen errors.
177
178
179 [[support]]
180
181 == Support
182
183
184 === Online Support
185
186 XML-RPC for PHP is offered "as-is" without any warranty or commitment to support. However, informal advice and help is
187     available via the XML-RPC for PHP website and mailing list.
188
189 * The __XML-RPC for PHP__ development is hosted on
190     link:$$https://github.com/gggeek/phpxmlrpc$$[github.com/gggeek/phpxmlrpc]. Bugs, feature requests and patches can be
191     posted to the link:$$https://github.com/gggeek/phpxmlrpc/issues$$[project's website].
192
193 * The __PHP XML-RPC interest mailing list__ is run by the original author. More details
194     link:$$http://lists.gnomehack.com/mailman/listinfo/phpxmlrpc$$[can be found here].
195
196
197 [[jellyfish]]
198
199 === The Jellyfish Book
200
201 image::progxmlrpc.s.gif[The Jellyfish Book]
202 Together with Simon St.Laurent and Joe Johnston, Edd Dumbill wrote a book on XML-RPC for O'Reilly and Associates on
203     XML-RPC. It features a rather fetching jellyfish on the cover.
204
205 Complete details of the book are link:$$http://www.oreilly.com/catalog/progxmlrpc/$$[available from O'Reilly's web site.]
206
207 Edd is responsible for the chapter on PHP, which includes a worked example of creating a forum server, and hooking it up
208     the O'Reilly's link:$$http://meerkat.oreillynet.com/$$[Meerkat] service in order to allow commenting on news stories
209     from around the Web.
210
211 If you've benefited from the effort that has been put into writing this software, then please consider buying the book!
212
213
214 [[apidocs]]
215
216 == Class documentation
217
218
219 ==== Notes on types
220
221 ===== int
222
223 The type i4 and i8 are accepted as a synonym
224           for int when creating xmlrpcval objects. The
225           xml parsing code will always convert i4 and i8 to
226           int: int is regarded
227           by this implementation as the canonical name for this type.
228
229 ===== base64
230
231 Base 64 encoding is performed transparently to the caller when
232           using this type. Decoding is also transparent. Therefore you ought
233           to consider it as a "binary" data type, for use when you want to
234           pass data that is not 7-bit clean.
235
236 ===== boolean
237
238 The php values ++true++ and
239           ++1++ map to ++true++. All other
240           values (including the empty string) are converted to
241           ++false++.
242
243 ===== string
244
245 Characters <, >;, ', ", &, are encoded using their
246           entity reference as &lt; &gt; &apos; &quot; and
247           &amp; All other characters outside of the ASCII range are
248           encoded using their character reference representation (e.g.
249           &#200 for é). The XML-RPC spec recommends only encoding
250           ++< >++ but this implementation goes further,
251           for reasons explained by link:$$http://www.w3.org/TR/REC-xml#syntax$$[the XML 1.0 recommendation]. In particular, using character reference
252           representation has the advantage of producing XML that is valid
253           independently of the charset encoding assumed.
254
255 ===== null
256
257 There is no support for encoding ++null++
258           values in the XML-RPC spec, but at least a couple of extensions (and
259           many toolkits) do support it. Before using ++null++
260           values in your messages, make sure that the responding party accepts
261           them, and uses the same encoding convention (see ...).
262
263 [[xmlrpcval-creation]]
264
265 ==== Xmlrpcval creation
266
267 The constructor is the normal way to create an
268         xmlrpcval. The constructor can take these
269         forms:
270
271 xmlrpcvalnew
272             xmlrpcval xmlrpcvalnew
273             xmlrpcval string $stringVal xmlrpcvalnew
274             xmlrpcval mixed $scalarVal string$scalartyp xmlrpcvalnew
275             xmlrpcval array $arrayVal string $arraytyp The first constructor creates an empty value, which must be
276         altered using the methods addScalar,
277         addArray or addStruct before
278         it can be used.
279
280 The second constructor creates a simple string value.
281
282 The third constructor is used to create a scalar value. The
283         second parameter must be a name of an XML-RPC type. Valid types are:
284         "++int++", "++boolean++",
285         "++string++", "++double++",
286         "++dateTime.iso8601++", "++base64++" or
287         "null".
288
289 Examples:
290
291 [source, php]
292 ----
293
294 $myInt = new xmlrpcval(1267, "int");
295 $myString = new xmlrpcval("Hello, World!", "string");
296 $myBool = new xmlrpcval(1, "boolean");
297 $myString2 = new xmlrpcval(1.24, "string"); // note: this will serialize a php float value as xmlrpc string
298
299 ----
300
301 The fourth constructor form can be used to compose complex
302         XML-RPC values. The first argument is either a simple array in the
303         case of an XML-RPC array or an associative
304         array in the case of a struct. The elements of
305         the array __must be xmlrpcval objects themselves__.
306
307 The second parameter must be either "++array++"
308         or "++struct++".
309
310 Examples:
311
312 [source, php]
313 ----
314
315 $myArray = new xmlrpcval(
316   array(
317     new xmlrpcval("Tom"),
318     new xmlrpcval("Dick"),
319     new xmlrpcval("Harry")
320   ),
321   "array");
322
323 // recursive struct
324 $myStruct = new xmlrpcval(
325   array(
326     "name" => new xmlrpcval("Tom", "string"),
327     "age" => new xmlrpcval(34, "int"),
328     "address" => new xmlrpcval(
329       array(
330         "street" => new xmlrpcval("Fifht Ave", "string"),
331         "city" => new xmlrpcval("NY", "string")
332       ),
333       "struct")
334   ),
335   "struct");
336
337 ----
338
339 See the file ++vardemo.php++ in this distribution
340         for more examples.
341
342 [[xmlrpc-client]]
343
344 ==== Xmlrpc-client creation
345
346 The constructor accepts one of two possible syntaxes:
347
348 xmlrpc_clientnew
349             xmlrpc_clientstring$server_urlxmlrpc_clientnew
350             xmlrpc_clientstring$server_pathstring$server_hostnameint$server_port80string$transport'http'Here are a couple of usage examples of the first form:
351
352
353 [source, php]
354 ----
355
356 $client = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php");
357 $another_client = new xmlrpc_client("https://james:bond@secret.service.com:443/xmlrpcserver?agent=007");
358
359 ----
360
361 The second syntax does not allow to express a username and
362         password to be used for basic HTTP authorization as in the second
363         example above, but instead it allows to choose whether xmlrpc calls
364         will be made using the HTTP 1.0 or 1.1 protocol.
365
366 Here's another example client set up to query Userland's XML-RPC
367         server at __betty.userland.com__:
368
369 [source, php]
370 ----
371
372 $client = new xmlrpc_client("/RPC2", "betty.userland.com", 80);
373
374 ----
375
376 The server_port parameter is optional,
377         and if omitted will default to 80 when using HTTP and 443 when using
378         HTTPS (see the <<xmlrpc-client-send>> method
379         below).
380
381 The transport parameter is optional, and
382         if omitted will default to 'http'. Allowed values are either
383         'http', 'https' or
384         'http11'. Its value can be overridden with every call
385         to the send method. See the
386         send method below for more details about the
387         meaning of the different values.
388
389
390 [[xmlrpc-server]]
391
392 === xmlrpc_server
393
394 The implementation of this class has been kept as simple to use as
395       possible. The constructor for the server basically does all the work.
396       Here's a minimal example:
397
398
399 [source, php]
400 ----
401
402   function foo ($xmlrpcmsg) {
403     ...
404     return new xmlrpcresp($some_xmlrpc_val);
405   }
406
407   class bar {
408     function foobar($xmlrpcmsg) {
409       ...
410       return new xmlrpcresp($some_xmlrpc_val);
411     }
412   }
413
414   $s = new xmlrpc_server(
415     array(
416       "examples.myFunc1" => array("function" => "foo"),
417       "examples.myFunc2" => array("function" => "bar::foobar"),
418     ));
419
420 ----
421
422 This performs everything you need to do with a server. The single
423       constructor argument is an associative array from xmlrpc method names to
424       php function names. The incoming request is parsed and dispatched to the
425       relevant php function, which is responsible for returning a
426       xmlrpcresp object, that will be serialized back
427       to the caller.
428
429
430 ==== Method handler functions
431
432 Both php functions and class methods can be registered as xmlrpc
433         method handlers.
434
435 The synopsis of a method handler function is:
436
437 xmlrpcresp $resp = function (xmlrpcmsg $msg)
438
439 No text should be echoed 'to screen' by the handler function, or
440         it will break the xml response sent back to the client. This applies
441         also to error and warning messages that PHP prints to screen unless
442         the appropriate parameters have been set in the php.in file. Another
443         way to prevent echoing of errors inside the response and facilitate
444         debugging is to use the server SetDebug method with debug level 3 (see
445         ...). Exceptions thrown duting execution of handler functions are
446         caught by default and a XML-RPC error reponse is generated instead.
447         This behaviour can be finetuned by usage of the
448         exception_handling member variable (see
449         ...).
450
451 Note that if you implement a method with a name prefixed by
452         ++system.++ the handler function will be invoked by the
453         server with two parameters, the first being the server itself and the
454         second being the xmlrpcmsg object.
455
456 The same php function can be registered as handler of multiple
457         xmlrpc methods.
458
459 Here is a more detailed example of what the handler function
460         foo may do:
461
462
463 [source, php]
464 ----
465
466   function foo ($xmlrpcmsg) {
467     global $xmlrpcerruser; // import user errcode base value
468
469     $meth = $xmlrpcmsg->method(); // retrieve method name
470     $par = $xmlrpcmsg->getParam(0); // retrieve value of first parameter - assumes at least one param received
471     $val = $par->scalarval(); // decode value of first parameter - assumes it is a scalar value
472
473     ...
474
475     if ($err) {
476       // this is an error condition
477       return new xmlrpcresp(0, $xmlrpcerruser+1, // user error 1
478         "There's a problem, Captain");
479     } else {
480       // this is a successful value being returned
481       return new xmlrpcresp(new xmlrpcval("All's fine!", "string"));
482     }
483   }
484
485 ----
486
487 See __server.php__ in this distribution for
488         more examples of how to do this.
489
490 Since release 2.0RC3 there is a new, even simpler way of
491         registering php functions with the server. See section 5.7
492         below
493
494
495 ==== The dispatch map
496
497 The first argument to the xmlrpc_server
498         constructor is an array, called the __dispatch map__.
499         In this array is the information the server needs to service the
500         XML-RPC methods you define.
501
502 The dispatch map takes the form of an associative array of
503         associative arrays: the outer array has one entry for each method, the
504         key being the method name. The corresponding value is another
505         associative array, which can have the following members:
506
507
508 * ++function++ - this
509             entry is mandatory. It must be either a name of a function in the
510             global scope which services the XML-RPC method, or an array
511             containing an instance of an object and a static method name (for
512             static class methods the 'class::method' syntax is also
513             supported).
514
515
516 * ++signature++ - this
517             entry is an array containing the possible signatures (see <<signatures>>) for the method. If this entry is present
518             then the server will check that the correct number and type of
519             parameters have been sent for this method before dispatching
520             it.
521
522
523 * ++docstring++ - this
524             entry is a string containing documentation for the method. The
525             documentation may contain HTML markup.
526
527
528 * ++$$signature_docs$$++ - this entry can be used
529             to provide documentation for the single parameters. It must match
530             in structure the 'signature' member. By default, only the
531             documenting_xmlrpc_server class in the
532             extras package will take advantage of this, since the
533             "system.methodHelp" protocol does not support documenting method
534             parameters individually.
535
536
537 * ++$$parameters_type$$++ - this entry can be used
538             when the server is working in 'xmlrpcvals' mode (see ...) to
539             define one or more entries in the dispatch map as being functions
540             that follow the 'phpvals' calling convention. The only useful
541             value is currently the string ++phpvals++.
542
543 Look at the __server.php__ example in the
544         distribution to see what a dispatch map looks like.
545
546 [[signatures]]
547
548 ==== Method signatures
549
550 A signature is a description of a method's return type and its
551         parameter types. A method may have more than one signature.
552
553 Within a server's dispatch map, each method has an array of
554         possible signatures. Each signature is an array of types. The first
555         entry is the return type. For instance, the method
556 [source, php]
557 ----
558 string examples.getStateName(int)
559
560 ----
561
562  has the signature
563 [source, php]
564 ----
565 array($xmlrpcString, $xmlrpcInt)
566
567 ----
568
569  and, assuming that it is the only possible signature for the
570         method, it might be used like this in server creation:
571 [source, php]
572 ----
573
574 $findstate_sig = array(array($xmlrpcString, $xmlrpcInt));
575
576 $findstate_doc = 'When passed an integer between 1 and 51 returns the
577 name of a US state, where the integer is the index of that state name
578 in an alphabetic order.';
579
580 $s = new xmlrpc_server( array(
581   "examples.getStateName" => array(
582     "function" => "findstate",
583     "signature" => $findstate_sig,
584     "docstring" => $findstate_doc
585   )));
586
587 ----
588
589
590
591 Note that method signatures do not allow to check nested
592         parameters, e.g. the number, names and types of the members of a
593         struct param cannot be validated.
594
595 If a method that you want to expose has a definite number of
596         parameters, but each of those parameters could reasonably be of
597         multiple types, the array of acceptable signatures will easily grow
598         into a combinatorial explosion. To avoid such a situation, the lib
599         defines the global var $xmlrpcValue, which can be
600         used in method signatures as a placeholder for 'any xmlrpc
601         type':
602
603
604 [source, php]
605 ----
606
607 $echoback_sig = array(array($xmlrpcValue, $xmlrpcValue));
608
609 $findstate_doc = 'Echoes back to the client the received value, regardless of its type';
610
611 $s = new xmlrpc_server( array(
612   "echoBack" => array(
613     "function" => "echoback",
614     "signature" => $echoback_sig, // this sig guarantees that the method handler will be called with one and only one parameter
615     "docstring" => $echoback_doc
616   )));
617
618 ----
619
620 Methods system.listMethods,
621         system.methodHelp,
622         system.methodSignature and
623         system.multicall are already defined by the
624         server, and should not be reimplemented (see Reserved Methods
625         below).
626
627
628 ==== Delaying the server response
629
630 You may want to construct the server, but for some reason not
631         fulfill the request immediately (security verification, for instance).
632         If you omit to pass to the constructor the dispatch map or pass it a
633         second argument of ++0++ this will have the desired
634         effect. You can then use the service() method of
635         the server class to service the request. For example:
636
637
638 [source, php]
639 ----
640
641 $s = new xmlrpc_server($myDispMap, 0); // second parameter = 0 prevents automatic servicing of request
642
643 // ... some code that does other stuff here
644
645 $s->service();
646
647 ----
648
649 Note that the service method will print
650         the complete result payload to screen and send appropriate HTTP
651         headers back to the client, but also return the response object. This
652         permits further manipulation of the response, possibly in combination
653         with output buffering.
654
655 To prevent the server from sending HTTP headers back to the
656         client, you can pass a second parameter with a value of
657         ++TRUE++ to the service
658         method. In this case, the response payload will be returned instead of
659         the response object.
660
661 Xmlrpc requests retrieved by other means than HTTP POST bodies
662         can also be processed. For example:
663
664
665 [source, php]
666 ----
667
668 $s = new xmlrpc_server(); // not passing a dispatch map prevents automatic servicing of request
669
670 // ... some code that does other stuff here, including setting dispatch map into server object
671
672 $resp = $s->service($xmlrpc_request_body, true); // parse a variable instead of POST body, retrieve response payload
673
674 // ... some code that does other stuff with xml response $resp here
675
676 ----
677
678
679 ==== Modifying the server behaviour
680
681 A couple of methods / class variables are available to modify
682         the behaviour of the server. The only way to take advantage of their
683         existence is by usage of a delayed server response (see above)
684
685
686 ===== setDebug()
687
688 This function controls weather the server is going to echo
689           debugging messages back to the client as comments in response body.
690           Valid values: 0,1,2,3, with 1 being the default. At level 0, no
691           debug info is returned to the client. At level 2, the complete
692           client request is added to the response, as part of the xml
693           comments. At level 3, a new PHP error handler is set when executing
694           user functions exposed as server methods, and all non-fatal errors
695           are trapped and added as comments into the response.
696
697
698 ===== allow_system_funcs
699
700 Default_value: TRUE. When set to FALSE, disables support for
701           System.xxx functions in the server. It
702           might be useful e.g. if you do not wish the server to respond to
703           requests to System.ListMethods.
704
705
706 ===== compress_response
707
708 When set to TRUE, enables the server to take advantage of HTTP
709           compression, otherwise disables it. Responses will be transparently
710           compressed, but only when an xmlrpc-client declares its support for
711           compression in the HTTP headers of the request.
712
713 Note that the ZLIB php extension must be installed for this to
714           work. If it is, compress_response will default to
715           TRUE.
716
717
718 ===== exception_handling
719
720 This variable controls the behaviour of the server when an
721           exception is thrown by a method handler php function. Valid values:
722           0,1,2, with 0 being the default. At level 0, the server catches the
723           exception and return an 'internal error' xmlrpc response; at 1 it
724           catches the exceptions and return an xmlrpc response with the error
725           code and error message corresponding to the exception that was
726           thron; at 2 = the exception is floated to the upper layers in the
727           code
728
729
730 ===== response_charset_encoding
731
732 Charset encoding to be used for response (only affects string
733           values).
734
735 If it can, the server will convert the generated response from
736           internal_encoding to the intended one.
737
738 Valid values are: a supported xml encoding (only UTF-8 and
739           ISO-8859-1 at present, unless mbstring is enabled), null (leave
740           charset unspecified in response and convert output stream to
741           US_ASCII), 'default' (use xmlrpc library default as specified in
742           xmlrpc.inc, convert output stream if needed), or 'auto' (use
743           client-specified charset encoding or same as request if request
744           headers do not specify it (unless request is US-ASCII: then use
745           library default anyway).
746
747
748 ==== Fault reporting
749
750 Fault codes for your servers should start at the value indicated
751         by the global ++$xmlrpcerruser++ + 1.
752
753 Standard errors returned by the server include:
754
755 ++1++ Unknown method:: Returned if the server was asked to dispatch a method it
756               didn't know about
757
758 ++2++ Invalid return payload:: This error is actually generated by the client, not
759               server, code, but signifies that a server returned something it
760               couldn't understand. A more detailed error report is sometimes
761               added onto the end of the phrase above.
762
763 ++3++ Incorrect parameters:: This error is generated when the server has signature(s)
764               defined for a method, and the parameters passed by the client do
765               not match any of signatures.
766
767 ++4++ Can't introspect: method unknown:: This error is generated by the builtin
768               system.* methods when any kind of
769               introspection is attempted on a method undefined by the
770               server.
771
772 ++5++ Didn't receive 200 OK from remote server:: This error is generated by the client when a remote server
773               doesn't return HTTP/1.1 200 OK in response to a request. A more
774               detailed error report is added onto the end of the phrase
775               above.
776
777 ++6++ No data received from server:: This error is generated by the client when a remote server
778               returns HTTP/1.1 200 OK in response to a request, but no
779               response body follows the HTTP headers.
780
781 ++7++ No SSL support compiled in:: This error is generated by the client when trying to send
782               a request with HTTPS and the CURL extension is not available to
783               PHP.
784
785 ++8++ CURL error:: This error is generated by the client when trying to send
786               a request with HTTPS and the HTTPS communication fails.
787
788 ++9-14++ multicall errors:: These errors are generated by the server when something
789               fails inside a system.multicall request.
790
791 ++100-++ XML parse errors:: Returns 100 plus the XML parser error code for the fault
792               that occurred. The faultString returned
793               explains where the parse error was in the incoming XML
794               stream.
795
796
797 ==== 'New style' servers
798
799 In the same spirit of simplification that inspired the
800         xmlrpc_client::return_type class variable, a new
801         class variable has been added to the server class:
802         functions_parameters_type. When set to 'phpvals',
803         the functions registered in the server dispatch map will be called
804         with plain php values as parameters, instead of a single xmlrpcmsg
805         instance parameter. The return value of those functions is expected to
806         be a plain php value, too. An example is worth a thousand
807         words:
808 [source, php]
809 ----
810
811   function foo($usr_id, $out_lang='en') {
812     global $xmlrpcerruser;
813
814     ...
815
816     if ($someErrorCondition)
817       return new xmlrpcresp(0, $xmlrpcerruser+1, 'DOH!');
818     else
819       return array(
820         'name' => 'Joe',
821         'age' => 27,
822         'picture' => new xmlrpcval(file_get_contents($picOfTheGuy), 'base64')
823       );
824   }
825
826   $s = new xmlrpc_server(
827     array(
828       "examples.myFunc" => array(
829         "function" => "bar::foobar",
830         "signature" => array(
831           array($xmlrpcString, $xmlrpcInt),
832           array($xmlrpcString, $xmlrpcInt, $xmlrpcString)
833         )
834       )
835     ), false);
836   $s->functions_parameters_type = 'phpvals';
837   $s->service();
838
839 ----
840
841 There are a few things to keep in mind when using this
842         simplified syntax:
843
844 to return an xmlrpc error, the method handler function must
845         return an instance of xmlrpcresp. The only
846         other way for the server to know when an error response should be
847         served to the client is to throw an exception and set the server's
848         exception_handling memeber var to 1;
849
850 to return a base64 value, the method handler function must
851         encode it on its own, creating an instance of an xmlrpcval
852         object;
853
854 the method handler function cannot determine the name of the
855         xmlrpc method it is serving, unlike standard handler functions that
856         can retrieve it from the message object;
857
858 when receiving nested parameters, the method handler function
859         has no way to distinguish a php string that was sent as base64 value
860         from one that was sent as a string value;
861
862 this has a direct consequence on the support of
863         system.multicall: a method whose signature contains datetime or base64
864         values will not be available to multicall calls;
865
866 last but not least, the direct parsing of xml to php values is
867         much faster than using xmlrpcvals, and allows the library to handle
868         much bigger messages without allocating all available server memory or
869         smashing PHP recursive call stack.
870
871
872 [[globalvars]]
873
874 == Global variables
875
876 Many global variables are defined in the xmlrpc.inc file. Some of
877     those are meant to be used as constants (and modifying their value might
878     cause unpredictable behaviour), while some others can be modified in your
879     php scripts to alter the behaviour of the xml-rpc client and
880     server.
881
882
883 === "Constant" variables
884
885
886 ==== $xmlrpcerruser
887
888 $xmlrpcerruser800The minimum value for errors reported by user
889         implemented XML-RPC servers. Error numbers lower than that are
890         reserved for library usage.
891
892
893 ==== $xmlrpcI4, $xmlrpcI8 $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull
894
895 For convenience the strings representing the XML-RPC types have
896         been encoded as global variables:
897 [source, php]
898 ----
899
900 $xmlrpcI4="i4";
901 $xmlrpcI8="i8";
902 $xmlrpcInt="int";
903 $xmlrpcBoolean="boolean";
904 $xmlrpcDouble="double";
905 $xmlrpcString="string";
906 $xmlrpcDateTime="dateTime.iso8601";
907 $xmlrpcBase64="base64";
908 $xmlrpcArray="array";
909 $xmlrpcStruct="struct";
910 $xmlrpcValue="undefined";
911 $xmlrpcNull="null";
912
913 ----
914
915 ==== $xmlrpcTypes, $xmlrpc_valid_parents, $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_backslash, $_xh, $xml_iso88591_Entities, $xmlEntities, $xmlrpcs_capabilities
916
917 Reserved for internal usage.
918
919
920 === Variables whose value can be modified
921
922 [[xmlrpc-defencoding]]
923
924 ==== xmlrpc_defencoding
925
926 $xmlrpc_defencoding"UTF8"This variable defines the character set encoding that will be
927         used by the xml-rpc client and server to decode the received messages,
928         when a specific charset declaration is not found (in the messages sent
929         non-ascii chars are always encoded using character references, so that
930         the produced xml is valid regardless of the charset encoding
931         assumed).
932
933 Allowed values: ++"UTF8"++,
934         ++"ISO-8859-1"++, ++"ASCII".++
935
936 Note that the appropriate RFC actually mandates that XML
937         received over HTTP without indication of charset encoding be treated
938         as US-ASCII, but many servers and clients 'in the wild' violate the
939         standard, and assume the default encoding is UTF-8.
940
941
942 ==== xmlrpc_internalencoding
943
944 $xmlrpc_internalencoding"ISO-8859-1"This variable defines the character set encoding
945         that the library uses to transparently encode into valid XML the
946         xml-rpc values created by the user and to re-encode the received
947         xml-rpc values when it passes them to the PHP application. It only
948         affects xml-rpc values of string type. It is a separate value from
949         xmlrpc_defencoding, allowing e.g. to send/receive xml messages encoded
950         on-the-wire in US-ASCII and process them as UTF-8. It defaults to the
951         character set used internally by PHP (unless you are running an
952         MBString-enabled installation), so you should change it only in
953         special situations, if e.g. the string values exchanged in the xml-rpc
954         messages are directly inserted into / fetched from a database
955         configured to return UTF8 encoded strings to PHP. Example
956         usage:
957
958 [source, php]
959 ----
960
961 <?php
962
963 include('xmlrpc.inc');
964 $xmlrpc_internalencoding = 'UTF-8'; // this has to be set after the inclusion above
965 $v = new xmlrpcval('κόÏ\83με'); // This xmlrpc value will be correctly serialized as the greek word 'kosme'
966
967 ----
968
969 ==== xmlrpcName
970
971 $xmlrpcName"XML-RPC for PHP"The string representation of the name of the XML-RPC
972         for PHP library. It is used by the client for building the User-Agent
973         HTTP header that is sent with every request to the server. You can
974         change its value if you need to customize the User-Agent
975         string.
976
977
978 ==== xmlrpcVersion
979
980 $xmlrpcVersion"2.2"The string representation of the version number of
981         the XML-RPC for PHP library in use. It is used by the client for
982         building the User-Agent HTTP header that is sent with every request to
983         the server. You can change its value if you need to customize the
984         User-Agent string.
985
986
987 ==== xmlrpc_null_extension
988
989 When set to TRUE, the lib will enable
990         support for the <NIL/> (and <EX:NIL/>) xmlrpc value, as
991         per the extension to the standard proposed here. This means that
992         <NIL> and <EX:NIL/> tags received will be parsed as valid
993         xmlrpc, and the corresponding xmlrpcvals will return "null" for
994         scalarTyp().
995
996
997 ==== xmlrpc_null_apache_encoding
998
999 When set to ++TRUE++, php NULL values encoded
1000         into xmlrpcval objects get serialized using the
1001         ++<EX:NIL/>++ tag instead of
1002         ++<NIL/>++. Please note that both forms are
1003         always accepted as input regardless of the value of this
1004         variable.
1005
1006
1007 [[helpers]]
1008
1009 == Helper functions
1010
1011 XML-RPC for PHP contains some helper functions which you can use to
1012     make processing of XML-RPC requests easier.
1013
1014
1015 === Date functions
1016
1017 The XML-RPC specification has this to say on dates:
1018
1019 [quote]
1020 ____
1021 [[wrap_xmlrpc_method]]
1022 Don't assume a timezone. It should be
1023         specified by the server in its documentation what assumptions it makes
1024         about timezones.
1025 ____
1026
1027
1028 Unfortunately, this means that date processing isn't
1029       straightforward. Although XML-RPC uses ISO 8601 format dates, it doesn't
1030       use the timezone specifier.
1031
1032 We strongly recommend that in every case where you pass dates in
1033       XML-RPC calls, you use UTC (GMT) as your timezone. Most computer
1034       languages include routines for handling GMT times natively, and you
1035       won't have to translate between timezones.
1036
1037 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
1038       8601 specification. Note that XML-RPC uses exactly one of the available
1039       representations: CCYYMMDDTHH:MM:SS.
1040
1041 [[iso8601encode]]
1042
1043 ==== iso8601_encode
1044
1045 stringiso8601_encodestring$time_tint$utc0Returns an ISO 8601 formatted date generated from the UNIX
1046         timestamp $time_t, as returned by the PHP
1047         function time().
1048
1049 The argument $utc can be omitted, in
1050         which case it defaults to ++0++. If it is set to
1051         ++1++, then the function corrects the time passed in
1052         for UTC. Example: if you're in the GMT-6:00 timezone and set
1053         $utc, you will receive a date representation
1054         six hours ahead of your local time.
1055
1056 The included demo program __vardemo.php__
1057         includes a demonstration of this function.
1058
1059 [[iso8601decode]]
1060
1061 ==== iso8601_decode
1062
1063 intiso8601_decodestring$isoStringint$utc0Returns a UNIX timestamp from an ISO 8601 encoded time and date
1064         string passed in. If $utc is
1065         ++1++ then $isoString is assumed
1066         to be in the UTC timezone, and thus the result is also UTC: otherwise,
1067         the timezone is assumed to be your local timezone and you receive a
1068         local timestamp.
1069
1070 [[arrayuse]]
1071
1072 === Easy use with nested PHP values
1073
1074 Dan Libby was kind enough to contribute two helper functions that
1075       make it easier to translate to and from PHP values. This makes it easier
1076       to deal with complex structures. At the moment support is limited to
1077       int, double, string,
1078       array, datetime and struct
1079       datatypes; note also that all PHP arrays are encoded as structs, except
1080       arrays whose keys are integer numbers starting with 0 and incremented by
1081       1.
1082
1083 These functions reside in __xmlrpc.inc__.
1084
1085 [[phpxmlrpcdecode]]
1086
1087 ==== php_xmlrpc_decode
1088
1089 mixedphp_xmlrpc_decodexmlrpcval$xmlrpc_valarray$optionsarrayphp_xmlrpc_decodexmlrpcmsg$xmlrpcmsg_valstring$optionsReturns a native PHP value corresponding to the values found in
1090         the xmlrpcval $xmlrpc_val,
1091         translated into PHP types. Base-64 and datetime values are
1092         automatically decoded to strings.
1093
1094 In the second form, returns an array containing the parameters
1095         of the given
1096         xmlrpcmsg_val, decoded
1097         to php types.
1098
1099 The options parameter is optional. If
1100         specified, it must consist of an array of options to be enabled in the
1101         decoding process. At the moment the only valid option are
1102         decode_php_objs and
1103         ++$$dates_as_objects$$++. When the first is set, php
1104         objects that have been converted to xml-rpc structs using the
1105         php_xmlrpc_encode function and a corresponding
1106         encoding option will be converted back into object values instead of
1107         arrays (provided that the class definition is available at
1108         reconstruction time). When the second is set, XML-RPC datetime values
1109         will be converted into native dateTime objects
1110         instead of strings.
1111
1112 ____WARNING__:__ please take
1113         extreme care before enabling the decode_php_objs
1114         option: when php objects are rebuilt from the received xml, their
1115         constructor function will be silently invoked. This means that you are
1116         allowing the remote end to trigger execution of uncontrolled PHP code
1117         on your server, opening the door to code injection exploits. Only
1118         enable this option when you have complete trust of the remote
1119         server/client.
1120
1121 Example:
1122 [source, php]
1123 ----
1124
1125 // wrapper to expose an existing php function as xmlrpc method handler
1126 function foo_wrapper($m)
1127 {
1128   $params = php_xmlrpc_decode($m);
1129   $retval = call_user_func_array('foo', $params);
1130   return new xmlrpcresp(new xmlrpcval($retval)); // foo return value will be serialized as string
1131 }
1132
1133 $s = new xmlrpc_server(array(
1134    "examples.myFunc1" => array(
1135      "function" => "foo_wrapper",
1136      "signatures" => ...
1137   )));
1138
1139 ----
1140
1141 [[phpxmlrpcencode]]
1142
1143 ==== php_xmlrpc_encode
1144
1145 xmlrpcvalphp_xmlrpc_encodemixed$phpvalarray$optionsReturns an xmlrpcval object populated with the PHP
1146         values in $phpval. Works recursively on arrays
1147         and objects, encoding numerically indexed php arrays into array-type
1148         xmlrpcval objects and non numerically indexed php arrays into
1149         struct-type xmlrpcval objects. Php objects are encoded into
1150         struct-type xmlrpcvals, excepted for php values that are already
1151         instances of the xmlrpcval class or descendants thereof, which will
1152         not be further encoded. Note that there's no support for encoding php
1153         values into base-64 values. Encoding of date-times is optionally
1154         carried on on php strings with the correct format.
1155
1156 The options parameter is optional. If
1157         specified, it must consist of an array of options to be enabled in the
1158         encoding process. At the moment the only valid options are
1159         encode_php_objs, ++$$null_extension$$++
1160         and auto_dates.
1161
1162 The first will enable the creation of 'particular' xmlrpcval
1163         objects out of php objects, that add a "php_class" xml attribute to
1164         their serialized representation. This attribute allows the function
1165         php_xmlrpc_decode to rebuild the native php objects (provided that the
1166         same class definition exists on both sides of the communication). The
1167         second allows to encode php ++NULL++ values to the
1168         ++<NIL/>++ (or
1169         ++<EX:NIL>++, see ...) tag. The last encodes any
1170         string that matches the ISO8601 format into an XML-RPC
1171         datetime.
1172
1173 Example:
1174 [source, php]
1175 ----
1176
1177 // the easy way to build a complex xml-rpc struct, showing nested base64 value and datetime values
1178 $val = php_xmlrpc_encode(array(
1179   'first struct_element: an int' => 666,
1180   'second: an array' => array ('apple', 'orange', 'banana'),
1181   'third: a base64 element' => new xmlrpcval('hello world', 'base64'),
1182   'fourth: a datetime' => '20060107T01:53:00'
1183   ), array('auto_dates'));
1184
1185 ----
1186
1187 ==== php_xmlrpc_decode_xml
1188
1189 xmlrpcval | xmlrpcresp |
1190             xmlrpcmsgphp_xmlrpc_decode_xmlstring$xmlarray$optionsDecodes the xml representation of either an xmlrpc request,
1191         response or single value, returning the corresponding php-xmlrpc
1192         object, or ++FALSE++ in case of an error.
1193
1194 The options parameter is optional. If
1195         specified, it must consist of an array of options to be enabled in the
1196         decoding process. At the moment, no option is supported.
1197
1198 Example:
1199 [source, php]
1200 ----
1201
1202 $text = '<value><array><data><value>Hello world</value></data></array></value>';
1203 $val = php_xmlrpc_decode_xml($text);
1204 if ($val) echo 'Found a value of type '.$val->kindOf(); else echo 'Found invalid xml';
1205
1206 ----
1207
1208 === Automatic conversion of php functions into xmlrpc methods (and vice versa)
1209
1210 For the extremely lazy coder, helper functions have been added
1211       that allow to convert a php function into an xmlrpc method, and a
1212       remotely exposed xmlrpc method into a local php function - or a set of
1213       methods into a php class. Note that these comes with many caveat.
1214
1215
1216 ==== wrap_xmlrpc_method
1217
1218 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
1219         function that will call the remote method and return results using
1220         native php types for both params and results. The generated php
1221         function will return an xmlrpcresp object for failed xmlrpc
1222         calls.
1223
1224 The second syntax is deprecated, and is listed here only for
1225         backward compatibility.
1226
1227 The server must support the
1228         system.methodSignature xmlrpc method call for
1229         this function to work.
1230
1231 The client param must be a valid
1232         xmlrpc_client object, previously created with the address of the
1233         target xmlrpc server, and to which the preferred communication options
1234         have been set.
1235
1236 The optional parameters can be passed as array key,value pairs
1237         in the extra_options param.
1238
1239 The signum optional param has the purpose
1240         of indicating which method signature to use, if the given server
1241         method has multiple signatures (defaults to 0).
1242
1243 The timeout and
1244         protocol optional params are the same as in the
1245         xmlrpc_client::send() method.
1246
1247 If set, the optional new_function_name
1248         parameter indicates which name should be used for the generated
1249         function. In case it is not set the function name will be
1250         auto-generated.
1251
1252 If the ++$$return_source$$++ optional parameter is
1253         set, the function will return the php source code to build the wrapper
1254         function, instead of evaluating it (useful to save the code and use it
1255         later as stand-alone xmlrpc client).
1256
1257 If the ++$$encode_php_objs$$++ optional parameter is
1258         set, instances of php objects later passed as parameters to the newly
1259         created function will receive a 'special' treatment that allows the
1260         server to rebuild them as php objects instead of simple arrays. Note
1261         that this entails using a "slightly augmented" version of the xmlrpc
1262         protocol (ie. using element attributes), which might not be understood
1263         by xmlrpc servers implemented using other libraries.
1264
1265 If the ++$$decode_php_objs$$++ optional parameter is
1266         set, instances of php objects that have been appropriately encoded by
1267         the server using a coordinate option will be deserialized as php
1268         objects instead of simple arrays (the same class definition should be
1269         present server side and client side).
1270
1271 __Note that this might pose a security risk__,
1272         since in order to rebuild the object instances their constructor
1273         method has to be invoked, and this means that the remote server can
1274         trigger execution of unforeseen php code on the client: not really a
1275         code injection, but almost. Please enable this option only when you
1276         trust the remote server.
1277
1278 In case of an error during generation of the wrapper function,
1279         FALSE is returned, otherwise the name (or source code) of the new
1280         function.
1281
1282 Known limitations: server must support
1283         system.methodsignature for the wanted xmlrpc
1284         method; for methods that expose multiple signatures, only one can be
1285         picked; for remote calls with nested xmlrpc params, the caller of the
1286         generated php function has to encode on its own the params passed to
1287         the php function if these are structs or arrays whose (sub)members
1288         include values of type base64.
1289
1290 Note: calling the generated php function 'might' be slow: a new
1291         xmlrpc client is created on every invocation and an xmlrpc-connection
1292         opened+closed. An extra 'debug' param is appended to the parameter
1293         list of the generated php function, useful for debugging
1294         purposes.
1295
1296 Example usage:
1297
1298
1299 [source, php]
1300 ----
1301
1302 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');
1303
1304 $function = wrap_xmlrpc_method($client, 'examples.getStateName');
1305
1306 if (!$function)
1307   die('Cannot introspect remote method');
1308 else {
1309   $stateno = 15;
1310   $statename = $function($a);
1311   if (is_a($statename, 'xmlrpcresp')) // call failed
1312   {
1313     echo 'Call failed: '.$statename->faultCode().'. Calling again with debug on';
1314     $function($a, true);
1315   }
1316   else
1317     echo "OK, state nr. $stateno is $statename";
1318 }
1319
1320 ----
1321
1322 [[wrap_php_function]]
1323
1324 ==== wrap_php_function
1325
1326 arraywrap_php_functionstring$funcnamestring$wrapper_function_namearray$extra_optionsGiven a user-defined PHP function, create a PHP 'wrapper'
1327         function that can be exposed as xmlrpc method from an xmlrpc_server
1328         object and called from remote clients, and return the appropriate
1329         definition to be added to a server's dispatch map.
1330
1331 The optional $wrapper_function_name
1332         specifies the name that will be used for the auto-generated
1333         function.
1334
1335 Since php is a typeless language, to infer types of input and
1336         output parameters, it relies on parsing the javadoc-style comment
1337         block associated with the given function. Usage of xmlrpc native types
1338         (such as datetime.dateTime.iso8601 and base64) in the docblock @param
1339         tag is also allowed, if you need the php function to receive/send data
1340         in that particular format (note that base64 encoding/decoding is
1341         transparently carried out by the lib, while datetime vals are passed
1342         around as strings).
1343
1344 Known limitations: only works for
1345         user-defined functions, not for PHP internal functions (reflection
1346         does not support retrieving number/type of params for those); the
1347         wrapped php function will not be able to programmatically return an
1348         xmlrpc error response.
1349
1350 If the ++$$return_source$$++ optional parameter is
1351         set, the function will return the php source code to build the wrapper
1352         function, instead of evaluating it (useful to save the code and use it
1353         later in a stand-alone xmlrpc server). It will be in the stored in the
1354         ++source++ member of the returned array.
1355
1356 If the ++$$suppress_warnings$$++ optional parameter
1357         is set, any runtime warning generated while processing the
1358         user-defined php function will be catched and not be printed in the
1359         generated xml response.
1360
1361 If the extra_options array contains the
1362         ++$$encode_php_objs$$++ value, wrapped functions returning
1363         php objects will generate "special" xmlrpc responses: when the xmlrpc
1364         decoding of those responses is carried out by this same lib, using the
1365         appropriate param in php_xmlrpc_decode(), the objects will be
1366         rebuilt.
1367
1368 In short: php objects can be serialized, too (except for their
1369         resource members), using this function. Other libs might choke on the
1370         very same xml that will be generated in this case (i.e. it has a
1371         nonstandard attribute on struct element tags)
1372
1373 If the ++$$decode_php_objs$$++ optional parameter is
1374         set, instances of php objects that have been appropriately encoded by
1375         the client using a coordinate option will be deserialized and passed
1376         to the user function as php objects instead of simple arrays (the same
1377         class definition should be present server side and client
1378         side).
1379
1380 __Note that this might pose a security risk__,
1381         since in order to rebuild the object instances their constructor
1382         method has to be invoked, and this means that the remote client can
1383         trigger execution of unforeseen php code on the server: not really a
1384         code injection, but almost. Please enable this option only when you
1385         trust the remote clients.
1386
1387 Example usage:
1388
1389
1390 [source, php]
1391 ----
1392 /**
1393 * State name from state number decoder. NB: do NOT remove this comment block.
1394 * @param integer $stateno the state number
1395 * @return string the name of the state (or error description)
1396 */
1397 function findstate($stateno)
1398 {
1399   global $stateNames;
1400   if (isset($stateNames[$stateno-1]))
1401   {
1402     return $stateNames[$stateno-1];
1403   }
1404   else
1405   {
1406     return "I don't have a state for the index '" . $stateno . "'";
1407   }
1408 }
1409
1410 // wrap php function, build xmlrpc server
1411 $methods = array();
1412 $findstate_sig = wrap_php_function('findstate');
1413 if ($findstate_sig)
1414   $methods['examples.getStateName'] = $findstate_sig;
1415 $srv = new xmlrpc_server($methods);
1416
1417 ----
1418
1419 [[deprecated]]
1420
1421 === Functions removed from the library
1422
1423 The following two functions have been deprecated in version 1.1 of
1424       the library, and removed in version 2, in order to avoid conflicts with
1425       the EPI xml-rpc library, which also defines two functions with the same
1426       names.
1427
1428 To ease the transition to the new naming scheme and avoid breaking
1429       existing implementations, the following scheme has been adopted:
1430
1431 * If EPI-XMLRPC is not active in the current PHP installation,
1432             the constant `XMLRPC_EPI_ENABLED` will be set to
1433             '0'
1434
1435
1436 * If EPI-XMLRPC is active in the current PHP installation, the
1437             constant `XMLRPC_EPI_ENABLED` will be set to
1438             '1'
1439
1440
1441
1442 The following documentation is kept for historical
1443       reference:
1444
1445 [[xmlrpcdecode]]
1446
1447 ==== xmlrpc_decode
1448
1449 mixedx mlrpc_decode xmlrpcval $xmlrpc_val Alias for php_xmlrpc_decode.
1450
1451 [[xmlrpcencode]]
1452
1453 ==== xmlrpc_encode
1454
1455 xmlrpcval xmlrpc_encode mixed $phpvalAlias for php_xmlrpc_encode.
1456
1457 [[debugging]]
1458
1459 === Debugging aids
1460
1461 ==== xmlrpc_debugmsg
1462
1463 void xmlrpc_debugmsgstring$debugstringSends the contents of $debugstring in XML
1464         comments in the server return payload. If a PHP client has debugging
1465         turned on, the user will be able to see server debug
1466         information.
1467
1468 Use this function in your methods so you can pass back
1469         diagnostic information. It is only available from
1470         __xmlrpcs.inc__.
1471
1472
1473 [[reserved]]
1474
1475 == Reserved methods
1476
1477 In order to extend the functionality offered by XML-RPC servers
1478     without impacting on the protocol, reserved methods are supported in this
1479     release.
1480
1481 All methods starting with system. are
1482     considered reserved by the server. PHP for XML-RPC itself provides four
1483     special methods, detailed in this chapter.
1484
1485 Note that all server objects will automatically respond to clients
1486     querying these methods, unless the property
1487     allow_system_funcs has been set to
1488     false before calling the
1489     service() method. This might pose a security risk
1490     if the server is exposed to public access, e.g. on the internet.
1491
1492
1493 === system.getCapabilities
1494
1495
1496 === system.listMethods
1497
1498 This method may be used to enumerate the methods implemented by
1499       the XML-RPC server.
1500
1501 The system.listMethods method requires no
1502       parameters. It returns an array of strings, each of which is the name of
1503       a method implemented by the server.
1504
1505 [[sysmethodsig]]
1506
1507 === system.methodSignature
1508
1509 This method takes one parameter, the name of a method implemented
1510       by the XML-RPC server.
1511
1512 It returns an array of possible signatures for this method. A
1513       signature is an array of types. The first of these types is the return
1514       type of the method, the rest are parameters.
1515
1516 Multiple signatures (i.e. overloading) are permitted: this is the
1517       reason that an array of signatures are returned by this method.
1518
1519 Signatures themselves are restricted to the top level parameters
1520       expected by a method. For instance if a method expects one array of
1521       structs as a parameter, and it returns a string, its signature is simply
1522       "string, array". If it expects three integers, its signature is "string,
1523       int, int, int".
1524
1525 For parameters that can be of more than one type, the "undefined"
1526       string is supported.
1527
1528 If no signature is defined for the method, a not-array value is
1529       returned. Therefore this is the way to test for a non-signature, if
1530       $resp below is the response object from a method
1531       call to system.methodSignature:
1532
1533 [source, php]
1534 ----
1535
1536 $v = $resp->value();
1537 if ($v->kindOf() != "array") {
1538   // then the method did not have a signature defined
1539 }
1540
1541 ----
1542
1543 See the __introspect.php__ demo included in this
1544       distribution for an example of using this method.
1545
1546 [[sysmethhelp]]
1547
1548 === system.methodHelp
1549
1550 This method takes one parameter, the name of a method implemented
1551       by the XML-RPC server.
1552
1553 It returns a documentation string describing the use of that
1554       method. If no such string is available, an empty string is
1555       returned.
1556
1557 The documentation string may contain HTML markup.
1558
1559 === system.multicall
1560
1561 This method takes one parameter, an array of 'request' struct
1562       types. Each request struct must contain a
1563       methodName member of type string and a
1564       params member of type array, and corresponds to
1565       the invocation of the corresponding method.
1566
1567 It returns a response of type array, with each value of the array
1568       being either an error struct (containing the faultCode and faultString
1569       members) or the successful response value of the corresponding single
1570       method call.
1571
1572
1573 [[examples]]
1574
1575 == Examples
1576
1577 The best examples are to be found in the sample files included with
1578     the distribution. Some are included here.
1579
1580 [[statename]]
1581
1582 === XML-RPC client: state name query
1583
1584 Code to get the corresponding state name from a number (1-50) from
1585       the demo server available on SourceForge
1586
1587 [source, php]
1588 ----
1589
1590   $m = new xmlrpcmsg('examples.getStateName',
1591     array(new xmlrpcval($HTTP_POST_VARS["stateno"], "int")));
1592   $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
1593   $r = $c->send($m);
1594   if (!$r->faultCode()) {
1595       $v = $r->value();
1596       print "State number " . htmlentities($HTTP_POST_VARS["stateno"]) . " is " .
1597         htmlentities($v->scalarval()) . "<BR>";
1598       print "<HR>I got this value back<BR><PRE>" .
1599         htmlentities($r->serialize()) . "</PRE><HR>\n";
1600   } else {
1601       print "Fault <BR>";
1602       print "Code: " . htmlentities($r->faultCode()) . "<BR>" .
1603             "Reason: '" . htmlentities($r->faultString()) . "'<BR>";
1604   }
1605
1606 ----
1607
1608 === Executing a multicall call
1609
1610 To be documented...
1611
1612
1613 [[faq]]
1614
1615 [qanda]
1616 == Frequently Asked Questions
1617
1618 ==== How to send custom XML as payload of a method call::
1619
1620 Unfortunately, at the time the XML-RPC spec was designed, support
1621       for namespaces in XML was not as ubiquitous as it is now. As a
1622       consequence, no support was provided in the protocol for embedding XML
1623       elements from other namespaces into an xmlrpc request.
1624
1625 To send an XML "chunk" as payload of a method call or response,
1626       two options are available: either send the complete XML block as a
1627       string xmlrpc value, or as a base64 value. Since the '<' character in
1628       string values is encoded as '&lt;' in the xml payload of the method
1629       call, the XML string will not break the surrounding xmlrpc, unless
1630       characters outside of the assumed character set are used. The second
1631       method has the added benefits of working independently of the charset
1632       encoding used for the xml to be transmitted, and preserving exactly
1633       whitespace, whilst incurring in some extra message length and cpu load
1634       (for carrying out the base64 encoding/decoding).
1635
1636
1637 ==== Is there any limitation on the size of the requests / responses that can be successfully sent?::
1638
1639 Yes. But I have no hard figure to give; it most likely will depend
1640       on the version of PHP in usage and its configuration.
1641
1642 Keep in mind that this library is not optimized for speed nor for
1643       memory usage. Better alternatives exist when there are strict
1644       requirements on throughput or resource usage, such as the php native
1645       xmlrpc extension (see the PHP manual for more information).
1646
1647 Keep in mind also that HTTP is probably not the best choice in
1648       such a situation, and XML is a deadly enemy. CSV formatted data over
1649       socket would be much more efficient.
1650
1651 If you really need to move a massive amount of data around, and
1652       you are crazy enough to do it using phpxmlrpc, your best bet is to
1653       bypass usage of the xmlrpcval objects, at least in the decoding phase,
1654       and have the server (or client) object return to the calling function
1655       directly php values (see xmlrpc_client::return_type
1656       and xmlrpc_server::functions_parameters_type for more
1657       details).
1658
1659
1660 ==== My server (client) returns an error whenever the client (server) returns accented characters
1661
1662 To be documented...
1663
1664
1665 ==== How to enable long-lasting method calls
1666
1667 To be documented...
1668
1669
1670 ==== My client returns "XML-RPC Fault #2: Invalid return payload: enable debugging to examine incoming payload": what should I do?
1671
1672 The response you are seeing is a default error response that the
1673       client object returns to the php application when the server did not
1674       respond to the call with a valid xmlrpc response.
1675
1676 The most likely cause is that you are not using the correct URL
1677       when creating the client object, or you do not have appropriate access
1678       rights to the web page you are requesting, or some other common http
1679       misconfiguration.
1680
1681 To find out what the server is really returning to your client,
1682       you have to enable the debug mode of the client, using
1683       $client->setdebug(1);
1684
1685
1686 ==== How can I save to a file the xml of the xmlrpc responses received from servers?
1687
1688 If what you need is to save the responses received from the server
1689       as xml, you have two options:
1690
1691 1- use the serialize() method on the response object.
1692
1693
1694 [source, php]
1695 ----
1696
1697 $resp = $client->send($msg);
1698 if (!$resp->faultCode())
1699   $data_to_be_saved = $resp->serialize();
1700
1701 ----
1702
1703 Note that this will not be 100% accurate, since the xml generated
1704       by the response object can be different from the xml received,
1705       especially if there is some character set conversion involved, or such
1706       (eg. if you receive an empty string tag as <string/>, serialize()
1707       will output <string></string>), or if the server sent back
1708       as response something invalid (in which case the xml generated client
1709       side using serialize() will correspond to the error response generated
1710       internally by the lib).
1711
1712 2 - set the client object to return the raw xml received instead
1713       of the decoded objects:
1714
1715
1716 [source, php]
1717 ----
1718
1719 $client = new xmlrpc_client($url);
1720 $client->return_type = 'xml';
1721 $resp = $client->send($msg);
1722 if (!$resp->faultCode())
1723   $data_to_be_saved = $resp->value();
1724
1725 ----
1726
1727 Note that using this method the xml response response will not be
1728       parsed at all by the library, only the http communication protocol will
1729       be checked. This means that xmlrpc responses sent by the server that
1730       would have generated an error response on the client (eg. malformed xml,
1731       responses that have faultcode set, etc...) now will not be flagged as
1732       invalid, and you might end up saving not valid xml but random
1733       junk...
1734
1735
1736 ==== Can I use the ms windows character set?
1737
1738 If the data your application is using comes from a Microsoft
1739       application, there are some chances that the character set used to
1740       encode it is CP1252 (the same might apply to data received from an
1741       external xmlrpc server/client, but it is quite rare to find xmlrpc
1742       toolkits that encode to CP1252 instead of UTF8). It is a character set
1743       which is "almost" compatible with ISO 8859-1, but for a few extra
1744       characters.
1745
1746 PHP-XMLRPC only supports the ISO 8859-1 and UTF8 character sets.
1747       The net result of this situation is that those extra characters will not
1748       be properly encoded, and will be received at the other end of the
1749       XML-RPC transmission as "garbled data". Unfortunately the library cannot
1750       provide real support for CP1252 because of limitations in the PHP 4 xml
1751       parser. Luckily, we tried our best to support this character set anyway,
1752       and, since version 2.2.1, there is some form of support, left commented
1753       in the code.
1754
1755 To properly encode outgoing data that is natively in CP1252, you
1756       will have to uncomment all relative code in the file
1757       __xmlrpc.inc__ (you can search for the string "1252"),
1758       then set ++$$$GLOBALS['xmlrpc_internalencoding']='CP1252';$$++
1759       Please note that all incoming data will then be fed to your application
1760       as UTF-8 to avoid any potential data loss.
1761
1762
1763 ==== Does the library support using cookies / http sessions?
1764
1765 In short: yes, but a little coding is needed to make it
1766       happen.
1767
1768 The code below uses sessions to e.g. let the client store a value
1769       on the server and retrieve it later.
1770
1771 [source, php]
1772 ----
1773
1774 $resp = $client->send(new xmlrpcmsg('registervalue', array(new xmlrpcval('foo'), new xmlrpcval('bar'))));
1775 if (!$resp->faultCode())
1776 {
1777   $cookies = $resp->cookies();
1778   if (array_key_exists('PHPSESSID', $cookies)) // nb: make sure to use the correct session cookie name
1779   {
1780     $session_id = $cookies['PHPSESSID']['value'];
1781
1782     // do some other stuff here...
1783
1784     $client->setcookie('PHPSESSID', $session_id);
1785     $val = $client->send(new xmlrpcmsg('getvalue', array(new xmlrpcval('foo')));
1786   }
1787 }
1788
1789 ----
1790
1791 Server-side sessions are handled normally like in any other
1792       php application. Please see the php manual for more information about
1793       sessions.
1794
1795 NB: unlike web browsers, not all xmlrpc clients support usage of
1796       http cookies. If you have troubles with sessions and control only the
1797       server side of the communication, please check with the makers of the
1798       xmlrpc client in use.
1799
1800
1801 [[integration]]
1802
1803 [appendix]
1804 == Integration with the PHP xmlrpc extension
1805
1806 To be documented more...
1807
1808 In short: for the fastest execution possible, you can enable the php
1809     native xmlrpc extension, and use it in conjunction with phpxmlrpc. The
1810     following code snippet gives an example of such integration
1811
1812
1813 [source, php]
1814 ----
1815
1816 /*** client side ***/
1817 $c = new xmlrpc_client('http://phpxmlrpc.sourceforge.net/server.php');
1818
1819 // tell the client to return raw xml as response value
1820 $c->return_type = 'xml';
1821
1822 // let the native xmlrpc extension take care of encoding request parameters
1823 $r = $c->send(xmlrpc_encode_request('examples.getStateName', $_POST['stateno']));
1824
1825 if ($r->faultCode())
1826   // HTTP transport error
1827   echo 'Got error '.$r->faultCode();
1828 else
1829 {
1830   // HTTP request OK, but XML returned from server not parsed yet
1831   $v = xmlrpc_decode($r->value());
1832   // check if we got a valid xmlrpc response from server
1833   if ($v === NULL)
1834     echo 'Got invalid response';
1835   else
1836   // check if server sent a fault response
1837   if (xmlrpc_is_fault($v))
1838     echo 'Got xmlrpc fault '.$v['faultCode'];
1839   else
1840     echo'Got response: '.htmlentities($v);
1841 }
1842
1843 ----
1844
1845
1846 [[substitution]]
1847
1848 [appendix]
1849 == Substitution of the PHP xmlrpc extension
1850
1851 Yet another interesting situation is when you are using a ready-made
1852     php application, that provides support for the XMLRPC protocol via the
1853     native php xmlrpc extension, but the extension is not available on your
1854     php install (e.g. because of shared hosting constraints).
1855
1856 Since version 2.1, the PHP-XMLRPC library provides a compatibility
1857     layer that aims to be 100% compliant with the xmlrpc extension API. This
1858     means that any code written to run on the extension should obtain the
1859     exact same results, albeit using more resources and a longer processing
1860     time, using the PHP-XMLRPC library and the extension compatibility module.
1861     The module is part of the EXTRAS package, available as a separate download
1862     from the sourceforge.net website, since version 0.2
1863
1864
1865 [[enough]]
1866
1867 [appendix]
1868 == 'Enough of xmlrpcvals!': new style library usage
1869
1870 To be documented...
1871
1872 In the meantime, see docs about xmlrpc_client::return_type and
1873     xmlrpc_server::functions_parameters_types, as well as php_xmlrpc_encode,
1874     php_xmlrpc_decode and php_xmlrpc_decode_xml
1875
1876
1877 [[debugger]]
1878
1879 [appendix]
1880 == Usage of the debugger
1881
1882 A webservice debugger is included in the library to help during
1883     development and testing.
1884
1885 The interface should be self-explicative enough to need little
1886     documentation.
1887
1888 image::debugger.gif[,,,,align="center"]
1889
1890 The most useful feature of the debugger is without doubt the "Show
1891     debug info" option. It allows to have a screen dump of the complete http
1892     communication between client and server, including the http headers as
1893     well as the request and response payloads, and is invaluable when
1894     troubleshooting problems with charset encoding, authentication or http
1895     compression.
1896
1897 The debugger can take advantage of the JSONRPC library extension, to
1898     allow debugging of JSON-RPC webservices, and of the JS-XMLRPC library
1899     visual editor to allow easy mouse-driven construction of the payload for
1900     remote methods. Both components have to be downloaded separately from the
1901     sourceforge.net web pages and copied to the debugger directory to enable
1902     the extra functionality:
1903
1904
1905 * to enable jsonrpc functionality, download the PHP-XMLRPC
1906           EXTRAS package, and copy the file __jsonrpc.inc__
1907           either to the same directory as the debugger or somewhere in your
1908           php include path
1909
1910
1911 * to enable the visual value editing dialog, download the
1912           JS-XMLRPC library, and copy somewhere in the web root files
1913           __visualeditor.php__,
1914           __visualeditor.css__ and the folders
1915           __yui__ and __img__. Then edit the
1916           debugger file __controller.php__ and set
1917           appropriately the variable $editorpath.
1918
1919
1920 [[news]]
1921
1922 [appendix]
1923
1924 == Whats's new
1925
1926 CAUTION: not all items the following list have (yet) been fully documented, and some might not be present in any other
1927     chapter in the manual. To find a more detailed description of new functions and methods please take a look at the
1928     source code of the library, which is quite thoroughly commented in phpdoc form.
1929
1930 === 4.0.0
1931
1932 * new: introduction of namespaces and full OOP.
1933 +
1934 All php classes have been renamed and moved to separate files.
1935 +
1936 Class autoloading can now be done in accord with the PSR-4 standard.
1937 +
1938 All global variables and global functions have been removed.
1939 +
1940 Iterating over xmlrpc value objects is now easier thank to support for ArrayAccess and Traversable interfaces.
1941 +
1942 Backward compatibility is maintained via _lib/xmlrpc.inc_, _lib/xmlrpcs.inc_ and _lib/xmlrpc_wrappers.inc_.
1943     For more details, head on to doc/api_changes_v4.md
1944
1945 * changed: the default character encoding delivered from the library to your code is now utf8.
1946   It can be changed at any time setting a value to `PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding`
1947
1948 * improved: the library now accepts requests/responses sent using other character sets than UTF-8/ISO-8859-1/ASCII.
1949   This only works when the mbstring php extension is enabled.
1950
1951 * improved: no need to call anymore `$client->setSSLVerifyHost(2)` to silence a curl warning when using https
1952   with recent curl builds
1953
1954 * improved: the xmlrpcval class now supports the interfaces `Countable` and `IteratorAggregate`
1955
1956 * improved: a specific option allows users to decide the version of SSL to use for https calls.
1957   This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
1958   and the cURL extension has been compiled with GnuTLS (such as on Travis VMs)
1959
1960 * improved: the function `wrap_php_function()` now can be used to wrap closures (it is now a method btw)
1961
1962 * improved: all _wrap_something()_ functions now return a closure by default instead of a function name
1963
1964 * improved: debug messages are not html-escaped any more when executing from the command line
1965
1966 * improved: the library is now tested using Travis ( https://travis-ci.org/ ).
1967   Tests are executed using all php versions from 5.3 to 7.0 nightly, plus HHVM; code-coverage information
1968   is generated using php 5.6 and uploaded to both Code Coverage and Scrutinizer online services
1969
1970 * improved: phpunit is now installed via composer, not bundled anymore
1971
1972 * improved: when phpunit is used to generate code-coverage data, the code executed server-side is accounted for
1973
1974 * improved: the test suite has basic checks for the debugger and demo files
1975
1976 * improved: more tests in the test suite
1977
1978 * fixed: the server would not reset the user-set debug messages between subsequent `service()` calls
1979
1980 * fixed: the server would not reset previous php error handlers when an exception was thrown by user code and
1981   exception_handling set to 2
1982
1983 * fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml
1984   prolog only
1985
1986 * fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml
1987   prolog only
1988
1989 * fixed: the function `decode_xml()` would not decode an xml with character set declaration in the xml prolog
1990
1991 * fixed: the client can now successfully call methods using ISO-8859-1 or UTF-8 characters in their name
1992
1993 * fixed: the debugger would fail sending a request with ISO-8859-1 payload (it missed the character set declaration).
1994   It would have a hard time coping with ISO-8859-1 in other fields, such as e.g. the remote method name
1995
1996 * fixed: the debugger would generate a bad payload via the 'load method synopsis' button for signatures containing NULL
1997   or undefined parameters
1998
1999 * fixed: the debugger would generate a bad payload via the 'load method synopsis' button for methods with multiple
2000   signatures
2001
2002 * improved: the debugger is displayed using UTF-8, making it more useful to debug any kind of service
2003
2004 * improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding;
2005   previously those messages would just disappear (this is visible e.g. in the debugger)
2006
2007 * changed: debug info handling
2008     - at debug level 1, the rebuilt php objects are not dumped to screen (server-side already did that)
2009     - at debug level 1, curl communication info are not dumped to screen
2010     - at debug level 1, the tests echo payloads of failures; at debug level 2 all payloads
2011
2012 * improved: makefiles have been replaced with a php_based pakefile
2013
2014 * improved: the source for the manual is stored in asciidoc format, which can be displayed natively by GitHub
2015   with nice html formatting. Also the HTML version generated by hand and bundled in tarballs is much nicer
2016   to look at than previous versions
2017
2018 * improved: all php code is now formatted according to the PSR-2 standard
2019
2020 === 3.0.0
2021
2022 __Note:__ this is the last release of the library that will support PHP 5.1 and up. Future releases will target php 5.3
2023     as minimum supported version.
2024
2025 * when using curl and keepalive, reset curl handle if we did not get back an http 200 response (eg a 302)
2026
2027 * omit port on http 'Host' header if it is 80
2028
2029 * test suite allows interrogating https servers ignoring their certs
2030
2031 * method `setAcceptedCompression` was failing to disable reception of compressed responses if the client supported them
2032
2033 === 3.0.0 beta
2034
2035 This is the first release of the library to only support PHP 5. Some legacy code has been removed, and support for
2036     features such as exceptions and dateTime objects introduced.
2037
2038 The "beta" tag is meant to indicate the fact that the refactoring has been more widespread than in precedent releases
2039     and that more changes are likely to be introduced with time - the library is still considered to be production
2040     quality.
2041
2042 * improved: removed all usage of php functions deprecated in php 5.3, usage of assign-by-ref when creating new objects
2043     etc...
2044
2045 * improved: add support for the `<ex:nil>` tag used by the apache library, both in input and output
2046
2047 * improved: add support for dateTime objects in both in php_xmlrpc_encode and as parameter for constructor of xmlrpcval
2048
2049 * improved: add support for timestamps as parameter for constructor of xmlrpcval
2050
2051 * improved: add option `dates_as_objects` to `php_xmlrpc_decode` to return dateTime objects for xmlrpc datetimes
2052
2053 * improved: add new method `SetCurlOptions` to xmrlpc_client to allow extra flexibility in tweaking http config, such as
2054     explicitly binding to an ip address
2055
2056 * improved: add new method `SetUserAgent` to xmrlpc_client to to allow having different user-agent http headers
2057
2058 * improved: add a new member variable in server class to allow fine-tuning of the encoding of returned values when the
2059     server is in 'phpvals' mode
2060
2061 * improved: allow servers in 'xmlrpcvals' mode to also register plain php functions by defining them in the dispatch map
2062     with an added option
2063
2064 * improved: catch exceptions thrown during execution of php functions exposed as methods by the server
2065
2066 * fixed: bad encoding if same object is encoded twice using `php_xmlrpc_encode`
2067
2068 === 2.2.2
2069
2070 __Note:__ this is the last release of the library that will support PHP 4. Future releases (if any) should target
2071     php 5.0 as minimum supported version.
2072
2073 * fixed: encoding of utf-8 characters outside of the BMP plane
2074
2075 * fixed: character set declarations surrounded by double quotes were not recognized in http headers
2076
2077 * fixed: be more tolerant in detection of charset in http headers
2078
2079 * fixed: fix detection of zlib.output_compression
2080
2081 * fixed: use `feof()` to test if socket connections are to be closed instead of the number of bytes read (rare bug when
2082     communicating with some servers)
2083
2084 * fixed: format floating point values using the correct decimal separator even when php locale is set to one that uses
2085     comma
2086
2087 * fixed: improve robustness of the debugger when parsing weird results from non-compliant servers
2088
2089 * php warning when receiving `false` in a bool value
2090
2091 * improved: allow the add_to_map server method to add docs for single params too
2092
2093 * improved: added the possibility to wrap for exposure as xmlrpc methods plain php class methods, object methods and even
2094     whole classes
2095
2096 === 2.2.1
2097
2098 * fixed: work aroung bug in php 5.2.2 which broke support of `HTTP_RAW_POST_DATA`
2099
2100 * fixed: is_dir parameter of `setCaCertificate()` method is reversed
2101
2102 * fixed: a php warning in xmlrpc_client creator method
2103
2104 * fixed: parsing of `1e+1` as valid float
2105
2106 * fixed: allow errorlevel 3 to work when prev. error handler was a static method
2107
2108 * fixed: usage of `client::setcookie()` for multiple cookies in non-ssl mode
2109
2110 * improved: support for CP1252 charset is not part or the library but almost possible
2111
2112 * improved: more info when curl is enabled and debug mode is on
2113
2114 === 2.2
2115
2116 * fixed: debugger errors on php installs with `magic_quotes_gpc` on
2117
2118 * fixed: support for https connections via proxy
2119
2120 * fixed: `wrap_xmlrpc_method()` generated code failed to properly encode php objects
2121
2122 * improved: slightly faster encoding of data which is internally UTF-8
2123
2124 * improved: debugger always generates a `null` id for jsonrpc if user omits it
2125
2126 * new: debugger can take advantage of a graphical value builder (it has to be downloaded separately, as part of jsxmlrpc
2127     package. See Appendix D for more details)
2128
2129 * new: support for the `<NIL/>` xmlrpc extension. see below for more details
2130
2131 * new: server support for the `system.getCapabilities` xmlrpc extension
2132
2133 * new: `wrap_xmlrpc_method`, `wrap_xmlrpc_method()` accepts two new options: debug and return_on_fault
2134
2135 === 2.1
2136
2137 * The wrap_php_function and wrap_xmlrpc_method functions have been moved out of the base library file _xmlrpc.inc_
2138     into a file of their own: _xmlrpc_wrappers.php_. You will have to include() / require() it in your scripts if
2139     you have been using those functions.
2140     For increased security, the automatic rebuilding of php object instances out ofreceived xmlrpc structs in
2141     `wrap_xmlrpc_method()` has been disabled (but it can be optionally re-enabled).
2142     Both `wrap_php_function()` and `wrap_xmlrpc_method()` functions accept many more options to fine tune their behaviour,
2143     including one to return the php code to be saved and later used as standalone php script
2144
2145 * The constructor of xmlrpcval() values has seen some internal changes, and it will not throw a php warning anymore when
2146     invoked using an unknown xmlrpc type: the error will only be written to php error log. Also
2147     `new xmlrpcval('true', 'boolean')` is not supported anymore
2148
2149 * The new function `php_xmlrpc_decode_xml()` will take the xml representation of either an xmlrpc request, response or
2150     single value and return the corresponding php-xmlrpc object instance
2151
2152 * A new function `wrap_xmlrpc_server()` has been added, to wrap all (or some) of the methods exposed by a remote xmlrpc
2153     server into a php class
2154
2155 * A new file has been added: _verify_compat.php_, to help users diagnose the level of compliance of their php
2156     installation with the library
2157
2158 * Restored compatibility with php 4.0.5 (for those poor souls still stuck on it)
2159
2160 * Method `xmlrpc_server->service()` now returns a value: either the response payload or xmlrpcresp object instance
2161
2162 * Method `xmlrpc_server->add_to_map()` now accepts xmlrpc methods with no param definitions
2163
2164 * Documentation for single parameters of exposed methods can be added to the dispatch map (and turned into html docs in
2165     conjunction with a future release of the 'extras' package)
2166
2167 * Full response payload is saved into xmlrpcresp object for further debugging
2168
2169 * The debugger can now generate code that wraps a remote method into a php function (works for jsonrpc, too); it also
2170     has better support for being activated via a single GET call (e.g. for integration into other tools)
2171
2172 * Stricter parsing of incoming xmlrpc messages: two more invalid cases are now detected (double `data` element inside
2173     `array` and `struct`/`array` after scalar inside `value` element)
2174
2175 * More logging of errors in a lot of situations
2176
2177 * Javadoc documentation of lib files (almost) complete
2178
2179 * Many performance tweaks and code cleanups, plus the usual crop of bugs fixed (see NEWS file for complete list of bugs)
2180
2181 * Lib internals have been modified to provide better support for grafting extra functionality on top of it. Stay tuned
2182     for future releases of the EXTRAS package (or go read Appendix B)...
2183
2184 === 2.0 final
2185
2186 * Added to the client class the possibility to use Digest and NTLM authentication methods (when using the CURL library)
2187     for connecting to servers and NTLM for connecting to proxies
2188
2189 * Added to the client class the possibility to specify alternate certificate files/directories for authenticating the
2190     peer with when using HTTPS communication
2191
2192 * Reviewed all examples and added a new demo file, containing a proxy to forward xmlrpc requests to other servers
2193     (useful e.g. for ajax coding)
2194
2195 * The debugger has been upgraded to reflect the new client capabilities
2196
2197 * All known bugs have been squashed, and the lib is more tolerant than ever of commonly-found mistakes
2198
2199 === 2.0 Release candidate 3
2200
2201 * Added to server class the property functions_parameters_type, that allows the server to register plain php functions
2202     as xmlrpc methods (i.e. functions that do not take an xmlrpcmsg object as unique param)
2203
2204 * let server and client objects serialize calls using a specified character set encoding for the produced xml instead of
2205     US-ASCII (ISO-8859-1 and UTF-8 supported)
2206
2207 * let `php_xmlrpc_decode` accept xmlrpcmsg objects as valid input
2208
2209 * 'class::method' syntax is now accepted in the server dispatch map
2210
2211 * `xmlrpc_clent::SetDebug()` accepts integer values instead of a boolean value, with debugging level 2 adding to the
2212     information printed to screen the complete client request
2213
2214 === 2.0 Release candidate 2
2215
2216 * Added a new property of the client object: `xmlrpc_client->return_type`, indicating whether calls to the
2217     send() method will return xmlrpcresp objects whose value() is an xmlrpcval object, a php value (automatically
2218     decoded) or the raw xml received from the server.
2219
2220 * Added in the extras dir. two new library files: _jsonrpc.inc_ and _jsonrpcs.inc_ containing new classes that
2221     implement support for the json-rpc protocol (alpha quality code)
2222
2223 * Added a new client method: `setKey($key, $keypass)` to be used in HTTPS connections
2224
2225 * Added a new file containing some benchmarks in the testsuite directory
2226
2227 === 2.0 Release candidate 1
2228
2229 * Support for HTTP proxies (new method: `xmlrpc_client::setProxy()`)
2230
2231 * Support HTTP compression of both requests and responses.
2232     Clients can specify what kind of compression they accept for responses between deflate/gzip/any, and whether to
2233     compress the requests.
2234     Servers by default compress responses to clients that explicitly declare support for compression (new methods:
2235     `xmlrpc_client::setAcceptedCompression()`, `xmlrpc_client::setRequestCompression()`).
2236     Note that the ZLIB php extension needs to be enabled in PHP to support compression.
2237
2238 * Implement HTTP 1.1 connections, but only if CURL is enabled (added an extra parameter to
2239     `xmlrpc_client::xmlrpc_client` to set the desired HTTP protocol at creation time and a new supported value for
2240     the last parameter of `xmlrpc_client::send`, which now can be safely omitted if it has been specified at
2241     creation time).
2242 +
2243 With PHP versions greater than 4.3.8 keep-alives are enabled by default for HTTP 1.1 connections. This should yield
2244     faster execution times when making multiple calls in sequence to the same xml-rpc server from a single client.
2245
2246 * Introduce support for cookies.
2247     Cookies to be sent to the server with a request can be set using `xmlrpc_client::setCookie()`, while cookies
2248     received from the server are found in ++xmlrpcresp::cookies()++. It is left to the user to check for validity of
2249     received cookies and decide whether they apply to successive calls or not.
2250
2251 * Better support for detecting different character set encodings of xml-rpc requests and responses: both client and
2252     server objects will correctly detect the charset encoding of received xml, and use an appropriate xml parser.
2253 +
2254 Supported encodings are US-ASCII, UTF-8 and ISO-8859-1.
2255
2256 * Added one new xmlrpcmsg constructor syntax, allowing usage of a single string with the complete URL of the target
2257     server
2258
2259 * Convert xml-rpc boolean values into native php values instead of 0 and 1
2260
2261 * Force the `php_xmlrpc_encode` function to properly encode numerically indexed php arrays into xml-rpc arrays
2262     (numerically indexed php arrays always start with a key of 0 and increment keys by values of 1)
2263
2264 * Prevent the `php_xmlrpc_encode` function from further re-encoding any objects of class ++xmlrpcval++ that
2265     are passed to it. This allows to call the function with arguments consisting of mixed php values / xmlrpcval objects
2266
2267 * Allow a server to NOT respond to system.* method calls (setting the `$server->allow_system_funcs` property).
2268
2269 * Implement a new xmlrpcval method to determine if a value of type struct has a member of a given name without having to
2270     loop trough all members: `xmlrpcval::structMemExists()`
2271
2272 * Expand methods `xmlrpcval::addArray`, `addScalar` and `addStruct` allowing extra php values to be added to
2273     xmlrpcval objects already formed.
2274
2275 * Let the `xmlrpc_client::send` method accept an XML string for sending instead of an xmlrpcmsg object, to
2276     facilitate debugging and integration with the php native xmlrpc extension
2277
2278 * Extend the `php_xmlrpc_encode` and `php_xmlrpc_decode` functions to allow serialization and rebuilding of
2279     PHP objects. To successfully rebuild a serialized object, the object class must be defined in the deserializing end
2280     of the transfer. Note that object members of type resource will be deserialized as NULL values.
2281 +
2282 Note that his has been implemented adding a "php_class" attribute to xml representation of xmlrpcval of STRUCT type,
2283     which, strictly speaking, breaks the xml-rpc spec. Other xmlrpc implementations are supposed to ignore such an
2284     attribute (unless they implement a brain-dead custom xml parser...), so it should be safe enabling it in
2285     heterogeneous environments. The activation of this feature is done by usage of an option passed as second parameter
2286     to both `php_xmlrpc_encode` and `php_xmlrpc_decode`.
2287
2288 * Extend the `php_xmlrpc_encode` function to allow automatic serialization of iso8601-conforming php strings as
2289     datetime.iso8601 xmlrpcvals, by usage of an optional parameter
2290
2291 * Added an automatic stub code generator for converting xmlrpc methods to php functions and vice-versa.
2292 +
2293 This is done via two new functions: `wrap_php_function` and `wrap_xmlrpc_method`, and has many caveats,
2294     with php being a typeless language and all...
2295
2296 * Allow object methods to be used in server dispatch map
2297
2298 * Added a complete debugger solution, in the __debugger__ folder
2299
2300 * Added configurable server-side debug messages, controlled by the new method `xmlrpc_server::SetDebug()`.
2301     At level 0, no debug messages are sent to the client; level 1 is the same as the old behaviour; at level 2 a lot
2302     more info is echoed back to the client, regarding the received call; at level 3 all warnings raised during server
2303     processing are trapped (this prevents breaking the xml to be echoed back to the client) and added to the debug info
2304     sent back to the client
2305
2306 * New XML parsing code, yields smaller memory footprint and faster execution times, not to mention complete elimination
2307     of the dreaded __eval()__ construct, so prone to code injection exploits
2308
2309 * Rewritten most of the error messages, making text more explicative
2310
2311 ++++++++++++++++++++++++++++++++++++++
2312 <!-- Keep this comment at the end of the file
2313 Local variables:
2314 mode: sgml
2315 sgml-omittag:nil
2316 sgml-shorttag:t
2317 sgml-minimize-attributes:nil
2318 sgml-always-quote-attributes:t
2319 sgml-indent-step:2
2320 sgml-indent-data:t
2321 sgml-parent-document:nil
2322 sgml-exposed-tags:nil
2323 sgml-local-catalogs:nil
2324 sgml-local-ecat-files:nil
2325 sgml-namecase-general:t
2326 sgml-general-insert-case:lower
2327 End:
2328 -->
2329 ++++++++++++++++++++++++++++++++++++++