Xml rpc a lightweight data communication protocol
1 / 29

XML-RPC a lightweight data communication protocol - PowerPoint PPT Presentation

  • Updated On :

XML-RPC a lightweight data communication protocol. Jing Deng Computer Science Department University of Colorado at Boulder 26 September 2001. Overview. Introduction XML-RPC protocol How it works Data format How to use XML-RPC (Java example) References. Introduction. What is XML-RPC

Related searches for XML-RPC a lightweight data communication protocol

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'XML-RPC a lightweight data communication protocol' - ownah

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Xml rpc a lightweight data communication protocol l.jpg

XML-RPCa lightweight data communication protocol

Jing Deng

Computer Science Department

University of Colorado at Boulder

26 September 2001

Overview l.jpg

  • Introduction

  • XML-RPC protocol

    • How it works

    • Data format

  • How to use XML-RPC (Java example)

  • References

Introduction l.jpg

  • What is XML-RPC

    • Remote process calling protocol with XML format

  • What can it do

    • allow software running on disparate operating systems, running in different environments to make procedure calls over the Internet.

  • History

    • Created by UserLand Software in April 1998, for its Frontier software communication

Fundamentals l.jpg

  • XML

    • A very powerful meta-language for description data. XML-RPC just uses a little bit of XML

  • RPC

    • A mechanism which allows a program running on one computer to execute a function that is actually running on another computer

  • HTTP

    • Most data on Internet are transferred under HTTP protocol

    • Not very efficient, but easy to use

    • Make XML-RPC more convenient to be used in web applications

Definition l.jpg

  • XML-RPC is a remote procedure calling protocol that works over the Internet.

  • XML-RPC is composed by an HTTP-POST request and a HTTP reply.

  • The body of the request and the value returned from server is formatted by XML.

Xml rpc overview l.jpg
XML-RPC Overview

  • XML-RPC call is conducted between two parties:

    • A client to send RPC request

    • A server to process RPC request and send back the return value to the client

      • Server’s address is in a standard URL

      • http://example.org:8080/rpcserver/

  • The data is composed by a HTTP header and a XML body

Xml rpc overview cont l.jpg
XML-RPC Overview (Cont.)

  • A XML-RPC request and a XML-RPC response

  • Both of them are composed by a HTTP header and a XML body

  • Request should indicate a method name and its parameters

  • Response should contain a function return value and indicates if it is a successful return or a error message

  • There is a data type set for parameters and return value

How does xml rpc work l.jpg









How does XML-RPC work


Web server

Client program


XML-RPC listener

Request example l.jpg


User-Agent: Frontier/5.1.2

Host: xml.colorado.edu

Content-Type: text/xml

Content-length: 181

<?xml version=“1.0”?>



<params> <param>




Request Example

Request format l.jpg
Request Format

  • A single <methodCall> structure, which contains

    • A single <methodName>. It contains the calling method’s name

    • A single <params>, which can contain any number of

      • <param>s. Each <param> has a

        • <value>

Data type scalar value s l.jpg
Data Type – Scalar <value>s

<i4> or <int> four-byte signed integer -12

<boolean> 0 (false) or 1 (true) 1

<string> ASCII string Hi!

<double> double-precision 3.1415

<dateTime.iso8601> date/time 19980717T14:08:55

<base64> base64-encoded binary eW91IGNhbid

(default type is string)

Data type cont struct l.jpg
Data Type (Cont.) - <struct>

<struct> contains <member>s, each <member> contains a <name> and a <value>



<name>lowerBound</name> <value><i4>18</i4></value>



<name>upperBound</name> <value><i4>122</i4></value>



Data type cont array l.jpg
Data Type (Cont.) - <array>

An <array> contains a single <data> element, which can contain any number of <value>s









Response example l.jpg
Response Example

HTTP/1.1 200 OK

Connection: close

Content-Length: 158

Content-Type: text/xml

Date: Wed, 26 Sep 2001 10:10:28 GMT

Server: UserLand Frontier/5.1.2-WinNT

<?xml version=“1.0”?>


<params> <param>

<value><string>South Dakota</string></value>



Response format l.jpg
Response Format

  • One <methodResponse>, it may contains either

    • A single <params> -- a successful procedure return

      It contains a single <param> which contains a single <value>

    • A <fault> -- a failure procedure return

      It contains a <value> which is a <struct> that contains two members: <faultCode> and <int>, <faultString> and <string>

Example xml rpc in java l.jpg
Example - XML-RPC in Java

  • Many XML-RPC applications encapsulate the details of XML-RPC protocol

  • They provides an interface for users to send remote procedure call, and retrieve return value

  • A XML-RPC Java library: helma.xmlrpc

Helma xmlprc l.jpg

  • A free XML-RPC library

  • http://xmlrpc.helma.org/

  • Contains source code, documentations, and examples

  • Has a jar file as a library: xmlrpc.jar, which contains a OpenXML parser as well

  • Easy to install

Xml rpc client l.jpg
XML-RPC Client

  • Send XML-RPC to server, and get the return value

  • Interface (encapsulate most protocol details: HTTP, XML)

    • XmlRpcClient class

      • XmlRpcClient(String URL);

      • public Object execute(String procedure_name,

        Vector params);

Xml rpc server l.jpg
XML-RPC Server

  • Process XML-RPC request, call the procedure that request wants to call, and send back the return value

  • Two kinds of server

    • A mini web server, only process XML-RPC

      WebServer class

      • (See its interface later…)

  • XML-RPC listener which cooperates with a web server

    XmlRpcServer class

    • Input is a XML stream, and output is a XML stream also

    • execute() method to process RPC

Xml rpc handler l.jpg
XML-RPC Handler

  • Contains the procedures client wants to call

  • We need to register handler to server

    • Automatic registration

    • Explicit registration

      • Implement XmlRpcHanlder interface

      • Use Xml.RpcHandler.execute() to process input parameter

  • Interface

    • WebServer.addHandler(String handler_name, Object handler);

Example handler l.jpg
Example - Handler

public class AreaHandler {

public Double rectArea(double length, double width) {

return new Double(length * width);


public Double circleArea(double radious) {

double value = (radious * radious * Math.PI);

return new Double (value);



Example server l.jpg
Example - Server

import java.io.IOException;

import helma.xmlrpc.WebServer;

import helma.xmlrpc.XmlRpc;

public class AreaServer {

public static void main(String[] args) {

try {

WebServer server = new WebServer(Integer.parseInt(args[0]));

server.addHandler("area", new AreaHandler());

} catch (IOException e) {

System.out.println("Could not start server: " + e.getMessage());



Example client l.jpg
Example - Client

import java.io.IOException;

import java.util.Vector;

import helma.xmlrpc.XmlRpc;

import helma.xmlrpc.XmlRpcClient;

import helma.xmlrpc.XmlRpcException;

public class AreaClient {

public static void main(String args[]) {

try {

XmlRpcClient client =

new XmlRpcClient("http://localhost:8899");

// continue….

Example client cont l.jpg
Example – Client (Cont.)

// continue from last slide…..

Vector params = new Vector();

params.addElement(new Double(args[0]));

Object result = client.execute("area.circleArea", params);


} catch (IOException e) {

System.out.println("IO Exception: " + e.getMessage());

} catch (XmlRpcException e) {

System.out.println("Exception within XML-RPC: " + e.getMessage());




Discussions l.jpg

  • Characters of XML-RPC

    • Platform independent because it is a protocol

    • Very simple, very easy to implement, very ease to use

    • Too simple for some applications

    • Implemented with many languages: Java, C/C++, Perl, Python, etc…

  • Other important issues I didn’t mention…

    • Security

    • Apply XML-RPC in web applications

Discussions cont l.jpg
Discussions (Cont.)

  • Comparisons

    • Differences between XML-RPC and web page

    • Differences between XML-RPC and RMI, Corba

    • Differences between XML-RPC and SOAP

  • Beyond XML-RPC


References l.jpg

  • XML-RPC documents




  • XML-RPC in Java


  • XML-RPC in C and C++


References cont l.jpg
References (Cont.)

  • Book

    Simon St.Laurent, Joe Johnston, Edd Dumbill, programming web services with XML-RPC, O’Reilly, 2001

  • Others