XML-RPC and SOAP (April 2003)

26
An introduction to two RPC system that use open Internet standards. XML-RPC and SOAP

description

An introduction to two RPC systems that use open internet standards (made in April 2003).

Transcript of XML-RPC and SOAP (April 2003)

Page 1: XML-RPC and SOAP (April 2003)

An introduction to two RPC system that use open Internet standards.

XML-RPC and SOAP

Page 2: XML-RPC and SOAP (April 2003)

RPC stands for Remote Procedure Call.

RPC is a mechanism for making a procedure call across applications or machines.

An RPC call involves calling a function with certain parameters and expecting a result.

Both sides must agree on the format in which data is passed to and fro.

What is RPC?

Page 3: XML-RPC and SOAP (April 2003)

XML-RPC implements RPC using open Web standards.

Data is encoded (“marshalled”) in XML using a special DTD for XML-RPC.

The RPC call is made using HTTP.

The application exporting the function must implement or be attached to a HTTP server.

What is XML-RPC?

Page 4: XML-RPC and SOAP (April 2003)

XML-RPC was created by Userland Software.

First implementation: Frontier in April 1998.

Supported universally now.

Userland also created SOAP and RSS.

History of XML-RPC

Page 5: XML-RPC and SOAP (April 2003)

Caller asks library to call a function on a server with a parameter set.

Library encodes parameters in XML and makes the call.

Server processes request and returns results.

Library decodes results from XML and returns results to caller.

The Mechanics

Page 6: XML-RPC and SOAP (April 2003)

Example Python Client

[jace@Jace jace]$ python Python 2.2.2 (#1, 01/12/03, 07:51:34) [GCC Apple cpp-precomp 6.14] on darwinType "help", "copyright", "credits" or "license" for more information.

>>> from xmlrpclib import Server>>>

Page 7: XML-RPC and SOAP (April 2003)

Example Python Client

[jace@Jace jace]$ python Python 2.2.2 (#1, 01/12/03, 07:51:34) [GCC Apple cpp-precomp 6.14] on darwinType "help", "copyright", "credits" or "license" for more information.>>> from xmlrpclib import Server

>>> betty = Server("http://betty.userland.com")>>>

Page 8: XML-RPC and SOAP (April 2003)

Example Python Client

[jace@Jace jace]$ python Python 2.2.2 (#1, 01/12/03, 07:51:34) [GCC Apple cpp-precomp 6.14] on darwinType "help", "copyright", "credits" or "license" for more information.>>> from xmlrpclib import Server>>> betty = Server("http://betty.userland.com")

>>> print betty.examples.getStateName(41)

Page 9: XML-RPC and SOAP (April 2003)

Example Python Client

[jace@Jace jace]$ python Python 2.2.2 (#1, 01/12/03, 07:51:34) [GCC Apple cpp-precomp 6.14] on darwinType "help", "copyright", "credits" or "license" for more information.>>> from xmlrpclib import Server>>> betty = Server("http://betty.userland.com")>>> print betty.examples.getStateName(41)South Dakota>>>

Page 10: XML-RPC and SOAP (April 2003)

Example RequestPOST /RPC2 HTTP/1.0Host: betty.userland.comContent-Type: text/xml...

<?xml version="1.0"?><methodCall>

<methodName>examples.getStateName</methodName> <params> <param>

<value><i4>41</i4></value> </param> </params></methodCall>

Page 11: XML-RPC and SOAP (April 2003)

Example Response

HTTP/1.1 200 OKContent-Type: text/xml

...

<?xml version="1.0"?><methodResponse> <params> <param>

<value><string>South Dakota</string></value> </param> </params></methodResponse>

Page 12: XML-RPC and SOAP (April 2003)

Integer (4-byte, signed) <i4> or <int>

Boolean <boolean>

String <string>

Double Precision Floating Point <double>

Date/Time <dateTime.iso8601>

Binary <base64>

Basic Parameter Types

Page 13: XML-RPC and SOAP (April 2003)

Array <array>

Collection of items of any data type. Multiple types are allowed in one array.

Structure <struct>

A structure is a named array, also called a dictionary or a hash table.

More Parameter Types

Page 14: XML-RPC and SOAP (April 2003)

Example Array

Original:[12, 'Egypt', FALSE, -31]

<array> <data>

<value><i4>12</i4></value> <value><string>Egypt</string></value> <value><boolean>0</boolean></value> <value><i4>-31</i4></value> </data></array>

Page 15: XML-RPC and SOAP (April 2003)

Example StructureOriginal:

{'lowerBound': 18, 'upperBound': 139}

<struct> <member>

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

<name>upperBound</name> <value><i4>139</i4></value> </member></struct>

Page 16: XML-RPC and SOAP (April 2003)

A function call may fail for some reason.

A failed response also uses HTTP code 200.

Instead of a <params> tag containing results, a <fault> tag containing a fault code and fault string is returned.

Both code and string are server defined.

Fault Responses

Page 17: XML-RPC and SOAP (April 2003)

No introspection available.

No access to properties or variables. Only function calls.

Can’t pass an object as a parameter. No named parameters either.

HTTP and XML both have processing overheads. Text consumes more bandwidth.

Limitations

Page 18: XML-RPC and SOAP (April 2003)

Really simple. You can write a client in minutes, a server in a little longer.

Lightweight. XML-RPC builds on existing HTTP and XML server and client libraries.

Secure. HTTP already offers basic authentication, SSL/TLS and cookie auth.

Advantages

Page 19: XML-RPC and SOAP (April 2003)

Who Uses XML-RPC?

Prominent Examples:

UserLand Software (Manila, Radio)

LiveJournal (now has an XML-RPC API)

Zope (transparent support for XML-RPC)

The KDE Project (kxmlrpc)

Microsoft (Windows NT API; unverified)

Page 20: XML-RPC and SOAP (April 2003)

SOAP

Stands for Simple Object Access Protocol. Attempts to overcome XML-RPC’s limits.

Is a W3C candidate recommendation.

Created by DevelopMentor, IBM, Lotus, Microsoft and UserLand Software.

Page 21: XML-RPC and SOAP (April 2003)

SOAP provides for user-defined data types, unlike XML-RPC’s limit of eight types.

SOAP with WSDL (Web Services Description Language) supports object introspection.

SOAP allows named parameters.

SOAP allows extensive customisation.

SOAP Over XML-RPC

Page 22: XML-RPC and SOAP (April 2003)

Is firewall friendly. DCOM and CORBA dynamically assign ports. SOAP doesn’t.

SOAP is vendor and platform independent.

Is not bound to a protocol. Can be implemented over HTTP or FTP or SMTP.

HTTP is scalable and easy to administer.

SOAP Over Others

Page 23: XML-RPC and SOAP (April 2003)

Is neither simple nor lightweight nor easy-to-use.

Specification not guaranteed stable yet.

Documentation contains errors.

Too many cooks working on the specification, not co-operating with each other very well.

Limitations of SOAP

Page 24: XML-RPC and SOAP (April 2003)

Not Covered Here

Defining an XML-RPC server.

Detailed examples of XML-RPC requests and responses.

Details on SOAP.

Page 25: XML-RPC and SOAP (April 2003)

XML-RPC Specification:http://www.xmlrpc.com/spec

SOAP Specification:http://www.w3.org/TR/SOAP/

XML-RPC vs SOAP:http://weblog.masukomi.org/writings/xml-rpc_vs_soap.htm

Links

Page 26: XML-RPC and SOAP (April 2003)

Q&A