Turn from: http://kingquake21.iteye.com/blog/1033471
JSON-RPC Specification: Http://json-rpc.org/wiki/specification
XML-RPC Specification: Http://www.xmlrpc.com/spec
SOAP Specification: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383487
Reference: http://weblog.masukomi.org/writings/xml-rpc_vs_soap.htm
All three are meant to implement message exchange in RPC, and no transport protocol is defined. However, in order to facilitate transmission in the network, and because of the stateless HTTP, HTTP is the common transport protocol for these three. The following example is also based on the HTTP protocol
XML-RPC and SOAP are both xml-based message exchange:
XML-RPC is very simple, defining several basic types, anonymous structures, anonymous arrays;
Soap can also customize types in addition to the basic type, named struct body, named array, and can use Polymorphic method invocation methods
While Json-rpc is a JSON-formatted message exchange, JSON is more lightweight than XML and is easy to use in page JS, and other features like XML-RPC
Here are some examples of sending requests using these protocols:
XML-RPC
XHTML Code POST/RPC2 http/1.0 user-agent:frontier/5.1.2 (WinNT) Host:betty.userland.com content-type:text/xml Co ntent-length:181 <?xml version= "1.0"?> <methodCall> <methodname>examples.getstatename </methodName> <params> <param> <value><i4>41</i4></value> ; </param> </params> </methodCall>
Soap:
XHTML code post /stockquote http/1.1 host: www.stockquoteserver.com content-type: text/xml; charset= "Utf-8" content-length: nnnn SOAPAction: "Some-uri" <SOAP-ENV:Envelope xmlns:soap-env= "http:// schemas.xmlsoap.org/soap/envelope/" soap-env:encodingstyle=" http://schemas.xmlsoap.org/ soap/encoding/"/> <SOAP-ENV:Header> <t:Transaction xmlns:t= "Some-uri" soap-env : mustunderstand= "1" > 5 </t:Transaction> </soap-env:header> <SOAP-ENV:Body> <m:getlasttradeprice xmlns:m= "Some-uri" > <symbol>DEF</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Json:
JavaScript code--> {"Method": "echo", "params": ["Hello Json-rpc"], "id": 1} <--{"result": "Hello json-rpc", "ER Ror ": null," id ": 1}