I. INTRODUCTION
The full name of XML-RPC is XML remote Procedure call, which is the XML remoting method invocation.
It is a set of specifications and a series of implementations that allow programs that run on different operating systems, in different environments, to implement Internet-based process calls. This remote procedure call uses HTTP as the transport protocol, and XML as the encoding format for transmitting information. The definition of XML-RPC is as simple as possible, but simultaneously capable of transmitting, processing, and returning complex data structures.
XML RPC uses the HTTP protocol as the RPC mechanism for the transport protocol, using XML literals to transfer commands and data. an RPC system, which inevitably consists of 2 parts:1.RPC client, used to call the method to the RPC server and receive the return data of the method;2.RPC Server, which responds to RPC client requests, executes methods, and echoes the method execution results. RPC is the abbreviation of remote Procedure call, translated into Chinese is a long-distance method calls, is a local machine on the remote machine to invoke a process (method) technology, this process is called "distributed computing", is to improve the "interoperability of each discrete machine" "and invented the technology.
available versions of XML RPC
Both the XML RPC client and the XML RPC server have many versions of the implementation. In general, an implementation version will implement client/server at the same time. However, because both satisfy the XML RPC specification, in theory, any version of the RPC client implementation and any one version of RPC server can be used as a companion.
Further, because XML RPC is transmitted as XML text using the HTTP protocol, it is not related to programming languages. For example, an implemented version of the RPC client includes: Perl,php,python,c/c++,java, and so on; the implementation language for RPC server includes Perl,java, and so on.
There are also more than one version implemented in the same programming language. For example, the Java version of the implementation is:
marque Xmlrpc is now and redstone Xml-rpc Library Merge (http://xmlrpc.sourceforge.net/)
Apache XMLRPC implementation, this project belongs to the Apache Web Service project, so the URL address begins with the Ws.apache (http://ws.apache.org/) Download link http// archive.apache.org/dist/ws/say Apache is really great!
This page is very good to say: http://www.tutorialspoint.com/xml-rpc/xml_rpc_quick_guide.htm
This page is a bit deep: http://www.ibm.com/developerworks/cn/webservices/1211_zhusy_rpc/
Two. Python implementation
There are too many cows, I have no words. Python implementation http://blog.csdn.net/abcjennifer/article/details/38393185
Create a server, construct a method, register a method
From Simplexmlrpcserver import Simplexmlrpcserver
def is_even (n):
return n%2 = = 0
Server = Simplexmlrpcserver (("localhost", 8000)) #确定URL和端口
Print "Listening on port 8000 ..."
Server.register_function (Is_even, "Is_even") #注册is_even函数
Server.serve_forever () #启动服务器 and make it available for this connection
Create client, request method
Import Xmlrpclib
Proxy = Xmlrpclib. Serverproxy ("Http://localhost:8000/")
Print "3 is even:%s"% str (Proxy.is_even (3)) #客户端调用XML-rpc function
Print "Even:%s"% str (proxy.is_even (100))
Three. Xmlrpc++ is a C + + version of the XML-RPC interface implementation
Four. Java Dafa good, eminence
Apache's xml-rpc seems to have changed a lot, and it has become extremely rigorous.
The following code is divided into the server side and the client two parts, deliberately used in a sentence programming. Read it gives a one go, temperamental predominance texture. The function is: The server side has two functions add and sub, the client requests one of them and pass in two parameters of type int, return the result of type int and output.
Server-side code:
Class Rpcserver {public static void main (string[] args) throws IOException {WebServer Server = new WebServer (8080); server. Getxmlrpcserver (). sethandlermapping (New xmlrpchandlermapping () {@Overridepublic Xmlrpchandler gethandler (String HandlerName) throws Xmlrpcnosuchhandlerexception, xmlrpcexception {switch (handlerName) {case "add": Return new Xmlrpchandler () {@Overridepublic Object execute (xmlrpcrequest arg) throws xmlrpcexception {int x = (int) arg.getparameter (0), y = (int) arg.getparameter (1); return x + y;}}; Case "Sub": Return new Xmlrpchandler () {@Overridepublic Object execute (xmlrpcrequest arg) throws xmlrpcexception {int x = ( int) arg.getparameter (0), y = (int) arg.getparameter (1); return x-y;}}; Default:return null;}}); Server.start ();}}
Here is the client code
Class Rpcclient {public static void main (string[] args) throws Xmlrpcexception {xmlrpcclient client = new Xmlrpcclient (); I NT ans = (int) client.execute (new Xmlrpcrequest () {int x = 3, y = 6; @Overridepublic int GetParameterCount () {return 2;} @Overridepublic Object getparameter (int x) {if (x = = 0) return This.x;elsereturn this.y;} @Overridepublic String Getmethodname () {return ' Add ';} @Overridepublic xmlrpcrequestconfig GetConfig () {Xmlrpcclientconfigimpl x = new Xmlrpcclientconfigimpl (); try { X.setserverurl (New URL ("http://localhost:8080"));} catch (Malformedurlexception e) {e.printstacktrace ();} return x;}}); System.out.println (ANS);}}
Five. About the MetaWeblog agreement
This protocol applies the XML-RPC, is the major blog unified support interface for users to use. Baidu MetaWeblog will come out a bunch of, with these several function interface is enough to access the blog.
The following methods is supported:
Blogger.deletepost
Blogger.getusersblogs
Metaweblog.editpost
metaweblog.getcategories
Metaweblog.getpost
metaweblog.getrecentposts
Metaweblog.newmediaobject
Metaweblog.newpost
Xml-rpc Remote Method invocation