CodyKochmann
4/17/2017 - 4:20 PM

XMLRPC php server and client example found at - http://code.runnable.com/UnEjkT04_CBwAAB4/how-to-create-a-xmlrpc-server-and-a-xmlrpc-client-

<?php

/*
 * PHP XMLRPC - How to create a XMLRPC Server
 */

//The easiest way to read an XMLRPC request is through the input stream
$request_xml = file_get_contents("php://input");

//create a basic demo method for the server to use
function say_hello($method_name, $args) {
    return "Hello ".$args[0];
}

//create the XMLRPC server
$xmlrpc_server = xmlrpc_server_create();

//register the demo method to the XMLRPC server
xmlrpc_server_register_method($xmlrpc_server, "say_hello", "say_hello");

//start the server listener
header('Content-Type: text/xml');
print xmlrpc_server_call_method($xmlrpc_server, $request_xml, array());

?>
<?php

/*
 * PHP XMLRPC - How to create a XMLRPC Server
 */
 
//call the "say_hello" method of the XMLRPC Server
//and pass "John" as the first parameter
$request = xmlrpc_encode_request("say_hello", array('John'));
//create the stream context for the request
$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "Content-Type: text/xml\r\nUser-Agent: PHPRPC/1.0\r\n",
    'content' => $request
)));

//URL of the XMLRPC Server
$server = 'http://localhost/server.php';
$file = file_get_contents($server, false, $context);
//decode the XMLRPC response
$response = xmlrpc_decode($file);
//display the response
echo $response;
?>