CtrlXmlRpc is a CTRL extension including XML-RPC functions. XML-RPC is a protocol for web services, similar to SOAP but much simpler.
In order to run an XMLRPC server, you have to start the HTTP server and install a handler. "/RPC2" is the default URL for XMLRPC. See also httpConnect().
See also chapter XmlRpc, basics. |
Synopsis
mixed xmlrpcHandler(string content); |
Parameters
Parameter |
Meaning |
content |
The content |
Return value
Result of the function call like it is sent from the HTTP server to the client. This can be a string (XML coded result) or a dyn_string (result + additional header for HTTP) or a dyn_mixed (first entry is the result either as a string or a compressed blob. The further rows are additional header. Since a "Content-Type" header is required for a gzip'ed result, the gziped result cannot be returned as blob. |
Description
CtrlXmlRpc is a CTRL extension with XmlRpc functions. XmlRpc is a protocol for web services, similar to SOAP but much simplier.
In order to run an XmlRpc server, you have to start the HTTP server and install a handler. "/RPC2" is the default URL for XmlRpc. |
Example |
#uses "CtrlXmlRpc"
main() {
httpServer(false, 80); httpConnect("xmlrpcHandler", "/RPC2");
}
mixed xmlrpcHandler(mixed content) { // content is the content // decode content string function; dyn_mixed args; // Execute a little bit different according to the function
mixed result; switch (function) { case "test" : result = test(args[1]); break; } // Encode the result again and return to the server string ret; xmlrpcEncodeResponse(result, ret); return ret; } |
Example This is an example of the xmlrpcHandler when the function gzip() is used to compress the response. |
main()
// If you want to compress (gzip) the response:
mixed xmlrpcHandler(mixed content, string user, string ip, dyn_string ds1, dyn_string ds2, int connIdx) { string method; // Method nameif (strlen(ret) > 1024) && strpos(httpGetHeader("Accept-Encoding"), "gzip") >= 0) |
Member of
|
Availability
|
See also
xmlrpcConnectToServer(), xmlrpcCloseServer(), xmlrpcCall(), xmlrpcClient(), xmlrpcDecodeRequest(), xmlrpcEncodeResponse() |
V 3.11 SP1
Copyright