# XML - Managing Data Exchange/RPC

* Chapters
* Appendices
* Exercises
* Computer Science Home
* Library and Information Science Home
* Markup Languages
* To do list
* Contributors list
* Contributing to Wikibooks
| Previous Chapter | Next Chapter |
| ← WDDX | JSTL → |
Author: Nathan Slider Editor: Nathan Slider UGA Master of Internet Technology Program, 2005

## Learning Objectives

Upon completion of this chapter, you will be able to
* Discuss XML-RPC
* Create XML-RPC Code based on Examples

## RPC Defined

In order to fully understand XML-RPC, we should fist define RPC. A Remote Procedure Call (RPC) is a protocol that allows a computer program running on one host to cause code to be executed on another host without the programmer needing to explicitly code for this. An RPC is initiated by the caller (client) sending a request message to a remote system (the server) to execute a certain procedure using arguments supplied. A result message is returned to the caller. There are many variations and subtleties in various implementations, resulting in a variety of different (incompatible) RPC protocols.
In order to allow servers to be accessed by differing clients, a number of standardized RPC systems have been created. Most of these use an Interface Description Language (IDL) to allow various platforms to call the RPC. Web services were the first real attempt to implement RPC between platforms. Using Web services a .NET client can call a remote procedure implemented in Java on a Unix server (and vice versa).
Web services use XML as the IDL, and HTTP as the network protocol. The advantage of this system is simplicity and standardization, the IDL is a text file that is widely understood, and HTTP is built into almost all modern operating systems. An example of such an RPC system is XML-RPC.

## XML-RPC Defined

XML-RPC (Extensible Markup Language Remote Procedure Call) is a Remote Procedure Call protocol encoded in XML. It is a very simple protocol, defining only a handful of data types and commands, and the entire description can be printed on two pages of paper. This is in stark contrast to most RPC systems, where the standards documents often run into the thousands of pages and require considerable software support in order to be used.
It was first created by Dave Winer in 1995 with Microsoft. However, Microsoft considered it too simple and started adding functionality. After several rounds of this, the standard was no longer so simple and became what is now SOAP.
"We wanted a clean, extensible format that's very simple. It should be possible for an HTML coder to be able to look at a file containing an XML-RPC procedure call, understand what it's doing, and be able to modify it and have it work on the first or second try... We also wanted it to be an easy to implement protocol that could quickly be adapted to run in other environments or on other operating systems." -xmlrpc.com

## Data Types

Data Types Referenced from XML-RPC
| Name | Tag Example | Description |
| array | <array> <data> <value><i4>1404</i4></value> <value><string>Something Here</string></value> <value><i4>1</i4></value> </data> </array> | Array of values, storing no keys |
| base64 | <base64>eW91IGNhbid0IHJlYWQgdGhpcyE=</base64> | [Base 64]-encoded binary data |
| boolean | <boolean>1</boolean> | [Boolean] logical value (0 or 1) |
| date/time | <dateTime.iso8601>19980717T14:08:55</dateTime.iso8601> | Date and time |
| double | <double>-12.53</double> | Double [precision] floating number |
| integer | <i4>42</i4> | Whole number, [integer] |
| string | <string>Hello world!</string> | String of characters. Must follow XML encoding. |
| struct | <struct> <member> <name>foo</name> <value><i4>1</i4></value> </member> <member> <name>bar</name> <value><i4>2</i4></value> </member> </struct> | Array of values, storing keys |
| nil | <nil/> | Discriminated null value; an XML-RPC extension |

### Examples

An example of a typical XML-RPC request would be:
An example of a typical XML-RPC response would be:
A typical XML-RPC fault would be:
A final example, comparing a PHP associative array with an equivalent XML-RPC <struct>. This array:
Becomes the following XML-RPC:

## References

* XML-RPC Homepage
* XML-RPC Specification
* Free Online Dictionary of Computing
* Forum
* Tutorials
* Technology Reports
* Citations from CiteSeer