print "Got '${resp}'\n";
-# now send a mail to nobody in particular
-
-#$resp = $client->call("mail.send", (
-# "edd",
-# "Test",
-# "Bonjour. Je m'appelle Gérard. Mañana. ",
-# "freddy",
-# "",
-# "",
-# 'text/plain; charset="iso-8859-1"')
-#);
-#
-#if ($resp->value()) {
-# print "Mail sent OK.\n";
-#} else {
-# print "Error sending mail.\n";
-#}
-
# test echoing of characters works fine
$resp = $client->call("examples.echo", 'Three "blind" mice - ' . "See 'how' they run");
#!/usr/bin/env python3
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
import xmlrpc.client
import base64
try:
print ("Got '" + server.examples.getStateName(32) + "'")
- # Disabled as demo servers often are prevented from sending mail...
- #r = server.mail.send(
- # "edd", "Test",
- # "Bonjour. Je m'appelle Gérard. Mañana. ", "freddy", "", "",
- # 'text/plain; charset="iso-8859-1"'
- # )
- #if r:
- # print ("Mail sent OK")
- #else:
- # print ("Error sending mail")
-
r = server.examples.echo('Three "blind" mice - ' + "See 'how' they run")
print (r)
# name/age example. this exercises structs and arrays
- a = [
+ a = [
{'name': 'Dave', 'age': 35}, {'name': 'Edd', 'age': 45 },
{'name': 'Fred', 'age': 23}, {'name': 'Barney', 'age': 36 }
]
# test base 64
r = server.examples.decode64(b'Mary had a little lamb She tied it to a pylon')
print (r)
-
+
except xmlrpc.client.Fault as err:
print("A fault occurred")
print("Fault code: %d" % err.faultCode)
* Please _do not_ copy this file verbatim into your production server.
*/
+// We answer to CORS preflight requests, to allow browsers which are visiting a site on a different domain to send
+// xml-rpc requests (generated via javascript) to this server.
+// Doing so has serious security implications, so we lock it by default to only be enabled on the well-known demo server.
+// If enabling it on your server, you most likely want to set up an allowed domains whitelist, rather than using'*'
+if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS' && $_SERVER['SERVER_ADMIN'] == 'info@altervista.org') {
+ header("Access-Control-Allow-Origin: *");
+ header("Access-Control-Allow-Methods: POST");
+ header("Access-Control-Expose-Headers: Content-Encoding");
+ die();
+}
+
require_once __DIR__ . "/_prepend.php";
use PhpXmlRpc\PhpXmlRpc;
$signatures = array_merge($signatures1, $signatures2, $signatures3);
+// Webservices used only by the testsuite - do not use them in production
if (defined('TESTMODE')) {
- // Webservices used only by the testsuite - do not use them in production
$signatures4 = include(__DIR__.'/methodProviders/testsuite.php');
$signatures5 = include(__DIR__.'/methodProviders/wrapper.php');
Yes. Set `+$client->use_curl = Client::USE_CURL_ALWAYS+` then use the Client method `+$client->setCurlOptions()+`
+=== Does the server support cross-domain xml-rpc calls?
+
+It is trivial to make phpxmlrpc servers support CORS preflight requests, allowing them to receive xml-rpc requests sent
+from browsers visiting different domains. However, this feature is not enabled out of the box, for obvious security concerns.
+See at the top of the file __demo/server/server.php__ for an example of enabling that.
+
=== How to enable long-lasting method calls
To be documented...