CodyKochmann
4/17/2017 - 6:09 PM

This is a demo on how to make multiple xmlrpc services from a single php script since the whole internet wants to make a wrapper that quite

This is a demo on how to make multiple xmlrpc services from a single php script since the whole internet wants to make a wrapper that quite honestly makes this process much more complicated than what you would actually have to do if you just used the core builtin methods.

<?php
/* author - Cody Kochmann
   this is a demo on how to make multiple xmlrpc services 
   from a single php script since the whole internet wants 
   to make a wrapper that quite honestly makes this process 
   much more complicated than what you would actually have 
   to do if you just used the core builtin methods 
*/

/* sample functions to serve */
function service_1($method_name, $args) {
	return __FUNCTION__.' recieved: '.print_r($args,true);
}
function service_2($method_name, $args){
	return __FUNCTION__.' recieved: '.print_r($args,true);
}

/* create the server */
$server = xmlrpc_server_create();

/* register the sample methods */
xmlrpc_server_register_method($server, "service_1", "service_1");
xmlrpc_server_register_method($server, "service_2", "service_2");

/* call the service against the incoming request */
header('Content-Type: text/xml');
print xmlrpc_server_call_method($server, file_get_contents("php://input"), array());