Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : XML-RPC Functions : xmlrpc_server_call_method

xmlrpc_server_call_method

Parses XML requests and call methods (PHP 4 >= 4.0.7, PHP 5)
string xmlrpc_server_call_method ( resource server, string xml, mixed user_data [, array output_options] )

Warning:

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

Warning:

This function is currently not documented; only the argument list is available.

Related Examples ( Source code ) » xmlrpc_server_call_method


Code Examples / Notes » xmlrpc_server_call_method

marco.buratto

xmlrpc_server_call_method() with class methods
<?php
require_once ('Connections/adodb_mysql_connection.php');
// Instantiating my own class
$my_report = new external_report($db_connection);
// Setting up the XML-RPC "server"
$xmlrpc_server_handler = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc_server_handler, "external_method", array(&$my_report, "export"));
// Creating XML return data
if ($response = xmlrpc_server_call_method($xmlrpc_server_handler, $HTTP_RAW_POST_DATA, null))
   {
   header('Content-Type: text/xml');
   echo $response;
   }
// **************** class definition ****************
class external_report
   {
   protected $db_connection;
   public function __construct($db_connection_pointer)
       {
       if (method_exists($db_connection_pointer, "Execute")) $this->db_connection = $db_connection_pointer;
       else die("...");
       }
   public function export($method_name, $params_array)
       {
       $id_dir = (int)$params_array[0];
       $id_usr = (int)$params_array[1]; // not used, just an example
       // We have to add arguments' validating code here and NOT inside the constructor (as usual)
       // because arguments are passed directly by xmlrpc_server_call_method (?!!)
       
       $myexport = array();
       $dirs_query = "SELECT documento_id FROM tabella_cartelle WHERE cartella_id = ".$id_dir;
       $dirs_result = $this->db_connection->Execute($dirs_query) or die("...");
       $index = 0;
       while(!$dirs_result->EOF)
           {
           $docs_query = "SELECT codice, titolo FROM tabella_documenti WHERE id_documento = ".$dirs_result->Fields('documento_id');
           $docs_result = $this->db_connection->Execute($docs_query) or die("...");
           $myexport[$index]['codice'] = $docs_result->Fields('codice');
           $myexport[$index]['titolo'] = $docs_result->Fields('titolo');
           $index++;
           $dirs_result->MoveNext();
           }
       return $myexport;
       }
   }
?>


zionglau


nyvsld

<?php
/* method implementation */
function impl($method_name,$params,$user_data){
 var_dump(func_get_args('impl'));
 return array_sum($params);
}
/* create server */
$s=xmlrpc_server_create();
xmlrpc_server_register_method($s,'add','impl');
/* calling server method */
$req=xmlrpc_encode_request('add',array(1,2,3));
$resp=xmlrpc_server_call_method($s,$req,array(3,4));
/* process result */
$decoded=xmlrpc_decode($resp);
if(xmlrpc_is_fault($decoded)){
echo 'fault!';
}
var_dump($decoded);
?>


Change Language


Follow Navioo On Twitter
xmlrpc_decode_request
xmlrpc_decode
xmlrpc_encode_request
xmlrpc_encode
xmlrpc_get_type
xmlrpc_is_fault
xmlrpc_parse_method_descriptions
xmlrpc_server_add_introspection_data
xmlrpc_server_call_method
xmlrpc_server_create
xmlrpc_server_destroy
xmlrpc_server_register_introspection_callback
xmlrpc_server_register_method
xmlrpc_set_type
eXTReMe Tracker