Ec (2); can let the software of different platforms interact with each other through the XML-RPC, we assume that the front-end (client) with PHP, Python as the service background, through the XML-RPC to call the services provided by Python. Example: 1. PHP client & nbsp; & lt ;? Phpxmlrpc_client.phpXML-RPC client demo (xmlrpc. inc); $ xmlrpc_interna script ec (2); script
We can let the software of different platforms interact with each other through the XML-RPC, we assume that using PHP as the front-end (client), Python as the service background, through the XML-RPC to call the services provided by Python. Example:
1. PHP Client
// Xmlrpc_client.php
// XML-RPC client demo
Require (''xmlrpc. inc '');
$ Xmlrpc_internalencoding = ''utf-8 '';
// Create a client object. The three parameters are path, hostname, and port.
# $ S = new xmlrpc_client (''/testxml/xmlrpc_server.php'', ''localhost'', 80 );
$ S = new xmlrpc_client (''/'', ''localhost'', 8888 );
// Create xmlrpcval object, which allows the encoding of our variable
// Create the xmlrpcval object and encode our PHP variables in the XML format required by the XML-RPC
# $ InputString = new xmlrpcval (''world victory '', ''string '');
$ InputString = php_xmlrpc_encode (''victory World '');
// Create an array of parameters
// Although we only have one parameter, we still need to convert it into an array, because the second parameter of xmlrpcmsg is a parameter table.
$ Parameters = array ($ inputString );
// Create the message object
// Create XML-RPC message, parameters are remote method name and parameter table
$ Msg = new xmlrpcmsg (''echostring'', $ parameters );
// $ S-> request_charset_encoding = ''utf-8 '';
// Send the message, get the response
// Send a message. The returned value $ rsp is an xmlrpcresp object. It contains the following three methods:
// FaultCode () error code. If the code is successful, 0 is returned.
// FaultString () error message
// Value () return value, which exists in the form of xmlrpcval object. decoding is required before PHP is used.
$ S-> debug = true;
$ Rsp = $ s-> send ($ msg );
// Check for errors
If ($ rsp-> faultcode () = 0 ){
// Decode the response to a PHP type
// The xmlrpc_decode () function is used to decode the xmlrpcval object.
$ Response = php_xmlrpc_decode ($ rsp-> value ());
// Print results
Print''
'';
var_dump($response);
print ''
'';
} Else {
// Print errors
Print ''error: ''. $ rsp-> faultcode ().'', ''. $ rsp-> faultstring ().''
'';
}
// Show messages
// Check the message content.
$ Msg-> createpayload ();
Print ''request:
''. $ Msg-> payload .'' '';
Print ''response: ''. $ Rsp-> serialize ().'' '';
?>
2. Python Server
#-*-Coding: GB2312 -*-
Import SimpleXMLRPCServer
# Define your own CMS class
Class MyCMS:
Def getVersion (self
<