+4 votes
184 views
in Web development by (242k points)
reopened
XML-RPC: remote procedure calls in XML format

1 Answer

+5 votes
by (1.6m points)
edited
 
Best answer

What is XML-RPC?
How does XML-RPC work?
XML-RPC applications
Example of a simple request to the server with XML-RPC

image

XML-RPC: remote procedure calls in XML format

Accessing certain functions remotely on computers that are on other networks or distributed systems has been a common practice for decades. The basic idea of ​​the underlying technology RPC (Remote Procedure Calls) was formulated as early as 1976 by James E. White in RFC 707, making it an older principle than, for example, the World Wide Web..

Done

In 2015 Google developed the   gRPC framework for RPC to conform to the structures of current computer systems.

One of the most popular solutions to take advantage of RPC requests is XML-RPC, which allows calls to be made using the HTTP (S) protocol and the Extensible Markup Language (XML). What is this specification , what is it used for, and how exactly does it work?

Index
  1. What is XML-RPC?
  2. How does XML-RPC work?
  3. XML-RPC applications
  4. Example of a simple request to the server with XML-RPC

What is XML-RPC?

XML-RPC (short for Extensible Markup Language Remote Procedure Call) is a protocol specification for making RPC calls (remote calls in computer networks) with the help of the stateless network protocol HTTP and the XML markup language which in this case , gives it its name. While HTTP regulates the transport of data, XML is used for the presentation of such data. In determining the XML-RPC standard, the fact that it could be implemented without great effort in different programming languages ​​and system platforms was valued above all..

Note

The XML-RPC specification exclusively uses the non-secure HTTP protocol for data transmission, although there are currently quite widespread and accepted variations of the standard compatible with HTTPS, which offers much greater security when opting for SSL / TLS security certificates .

Software developer Dave Winer and his company UserLand Software, in close collaboration with Microsoft , were primarily responsible for developing XML-RPC in 1998 . It didn't take long for this large corporation to see the enormous potential this new standard had to promote its own B2B business relationships. XML-RPC has been incorporating different and new functions to its range of features, leading to the standard known as SOAP (Simple Object Access Protocol) or Simple Object Access Protocol, which has been consolidated as an interface protocol for web services ..

How does XML-RPC work?

Clients who want to access XML-RPC use the HTTP transfer protocol or, more specifically, the HTTP request POST method. After receiving the HTTP request, the server evaluates the XML document found in the request body. From its content, it generates, for example, the parameters for the desired function and executes it. As a result, the server repackages it into an XML document that will be returned to the client as an HTTP response. XML-RPC therefore supports the following data types when it delivers parameters or receives a response from a client:

Type of data Label example Description
array <array><data>?</data> </array> List that can contain multiple values ​​or data types
base64 <base64> SGFsbG8gV2VsdA == </base64> Binary data encoded according to the Base64 system
boolean <boolean> 1 </boolean> Boolean variable (true = 1 vs. false = 0)
dateTime.iso8601 <dateTime.iso8601> 20200414T16: 23: 55 </dateTime.iso8601> Date and time in ISO 8601 format
double <double> -0.32653 </double> Double-precision floating point (64-bit)
integer <int> 32 </int> or <i4> 32 </i4> Integer data type
string <string> Hello everyone! </string> Character string; can contain null bytes
struct <struct><data>?</data> </struct> It is made up of pairs of key values ​​(in this case, the keys are character strings and the values ​​can be of any type)

If multiple values ​​or data types are to be joined, the XML-RPC notation provides two options:? array ? Y ? struct ?. With the first option, the data is arranged in a list, and, by? struct ?, pre-structured key value pairs are presented to the server, as illustrated in the following example:

  <struct></struct> <member></member> <name>Entrada 1</name> <value><int>1</int></value> <member></member> <name>Entrada 2</name> <value><int>2</int></value>  
Note

Some languages ​​that have XML-RPC implementations, such as Java, also offer the option of specifying zero values . To do this, the XML document should always use the nil data type , which, however, is not officially part of the XML-RPC specification and is not supported on all servers.

XML-RPC applications

XML-RPC does not play a very important role in today's communication networks. Since its release in 1998, this interchange format has proven to be too rigid , among other things, due to its limited scalability and the fact that it cannot transfer its own XML structures. As a result of the excessive time required for the conversion, it became necessary to find a new and fast solution that would work together with the aforementioned SOAP (also developed by the Winer team in collaboration with Microsoft).

However, today there are still web applications that have an XML-RPC interface , among other things, to facilitate the exchange of data with external service providers. Even content management systems, such as WordPress, often incorporate an XML-RPC interface for exchange with other web services . In addition, the exchange format is the basis of the so - called pingback technology , which has been serving blog writers for years as an important tool to configure links? In our article What is behind the pingback and trackback methods you will find more information about this topic.

Example of a simple request to the server with XML-RPC

Finally, nothing better than an example to illustrate client-server communication through an XML-RPC interface. The HTTP request from the client would be as follows:

  <!--?xml version="1.0"?--> <methodcall></methodcall> <methodname>statustest</methodname> <params></params> <param> <value><i4>10</i4></value>  

In the methodCall container , in this case, the statustest function is activated , which, in turn, is defined in the methodName container . As a parameter , the function returns the integer 10 as a value .

A possible response from the server to this statustest could be this:

  <!--?xml version="1.0"?--> <methodresponse></methodresponse> <params></params> <param> <value><string>Status: OK</string></value>  

In this example, the simple response from the server is Status: OK .


...