XML-RPC and SOAP (April 2003)
-
Upload
kiran-jonnalagadda -
Category
Technology
-
view
399 -
download
0
description
Transcript of XML-RPC and SOAP (April 2003)
An introduction to two RPC system that use open Internet standards.
XML-RPC and SOAP
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?
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?
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
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
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>>>
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")>>>
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)
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>>>
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>
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>
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
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
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>
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>
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
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
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
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)
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.
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
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
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
Not Covered Here
Defining an XML-RPC server.
Detailed examples of XML-RPC requests and responses.
Details on SOAP.
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
Q&A