* improved: limit the size of incoming data which will be used in error responses and logged error messages, making
it slightly harder to carry out DOS attacks against the library
-* fixed: when calling `Client::multicall()` with `$client->return_type = 'xml'`, we would be always falling back to
- non-multicall requests
-
* fixed: when a server is configured with its default value of 'xmlrpcvals' for `$functions_parameters_type`, and
a method handler in the dispatch was defined with `'parameters_type' = 'phpvals'`, the handler would be passed a
Request object instead of plain php values.
+* fixed: when calling `Client::multicall()` with `$client->return_type = 'xml'`, we would be always falling back to
+ non-multicall requests
+
* fixed: receiving integers which use the '<EX:I8>' xml tag
* new: added the `Client::setTimeout` method, meant to replace usage of the `$timeout` argument in calls to `send`
* new: methods `Wrapper::holdObject()` and `Wrapper::getheldObject()`, allowing flexibility in storing object instances
for code-generation scenarios involving `Wrapper::wrapPhpClass` and `Wrapper::wrapPhpFunction`
+* improved: made sure all debug output goes through the logger at response parsing time (there was one printf call left)
+
* improved: all the Client's `setSomething()` methods now return the client object, allowing for usage of fluent style
calling. The same applies to `Request::setDebug`
* improved: the debugger will now sport the "load method synopsis" button when interacting with json-rpc servers
-* improved: made sure the test container has at least one locale with comma as decimal separator
+* improved: made sure the test container and gha test runners have at least one locale with comma as decimal separator
* BC notes:
--- /dev/null
+<?php
+require_once __DIR__ . "/_prepend.php";
+
+/**
+ * Demoing how to inject a custom logger for use by the library
+ */
+
+use PhpXmlRpc\Client;
+use PhpXmlRpc\Encoder;
+use PhpXmlRpc\Helper\Charset;
+use PhpXmlRpc\Helper\Http;
+use PhpXmlRpc\Helper\XMLParser;
+use PhpXmlRpc\Request;
+
+// Definition of a custom logger implementing the same API as the default one
+
+class MyLogger
+{
+ protected $debugBuffer = '';
+ protected $errorBuffer = '';
+
+ // logger API
+ public function debugMessage($message, $encoding = null)
+ {
+ $this->debugBuffer .= $message . "\n";
+ }
+
+ // logger API
+ public function errorLog($message)
+ {
+ $this->errorBuffer .= $message . "\n";
+ }
+
+ public function getDebug()
+ {
+ return $this->debugBuffer;
+ }
+
+ public function getError()
+ {
+ return $this->errorBuffer;
+ }
+}
+
+// create the custom logger instance
+
+$logger = new MyLogger();
+
+// inject it into all the classes (possibly) involved
+
+Charset::setLogger($logger);
+Client::setLogger($logger);
+Encoder::setLogger($logger);
+Http::setLogger($logger);
+Request::setLogger($logger);
+XMLParser::setLogger($logger);
+
+// then send a request
+
+$input = array(
+ array('name' => 'Dave', 'age' => 24),
+ array('name' => 'Edd', 'age' => 45),
+ array('name' => 'Joe', 'age' => 37),
+ array('name' => 'Fred', 'age' => 27),
+);
+
+$encoder = new Encoder();
+$client = new Client(XMLRPCSERVER);
+
+// set maximum debug level, to have all the communication details logged
+$client->setDebug(2);
+
+// avid compressed responses, as they mess up the output if echoed on the command-line
+$client->setAcceptedCompression('');
+
+// send request
+output("Sending the request. No output debug should appear below...<br>");
+$request = new Request('examples.sortByAge', array($encoder->encode($input)));
+$response = $client->send($request);
+output("Response received.<br>");
+
+output("The client error info is:<pre>\n" . $logger->getError() . "\n</pre>");
+output("The client debug info is:<pre>\n" . $logger->getDebug() . "\n</pre>");