XML-RPC and SOAP (April 2003)

1,100 views

Published on

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

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,100
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
25
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

XML-RPC and SOAP (April 2003)

  1. 1. XML-RPC and SOAP An introduction to two RPC system that use open Internet standards.
  2. 2. What is RPC? 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.
  3. 3. What is XML-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.
  4. 4. History of XML-RPC XML-RPC was created by Userland Software. First implementation: Frontier in April 1998. Supported universally now. Userland also created SOAP and RSS.
  5. 5. The Mechanics 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.
  6. 6. 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 darwin Type "help", "copyright", "credits" or "license" for more information. >>> from xmlrpclib import Server >>>
  7. 7. 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 darwin Type "help", "copyright", "credits" or "license" for more information. >>> from xmlrpclib import Server >>> betty = Server("http://betty.userland.com") >>>
  8. 8. 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 darwin Type "help", "copyright", "credits" or "license" for more information. >>> from xmlrpclib import Server >>> betty = Server("http://betty.userland.com") >>> print betty.examples.getStateName(41)
  9. 9. 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 darwin Type "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 >>>
  10. 10. Example Request POST /RPC2 HTTP/1.0 Host: betty.userland.com Content-Type: text/xml ... <?xml version="1.0"?> <methodCall> <methodName>examples.getStateName</methodName> <params> <param> <value><i4>41</i4></value> </param> </params> </methodCall>
  11. 11. Example Response HTTP/1.1 200 OK Content-Type: text/xml ... <?xml version="1.0"?> <methodResponse> <params> <param> <value><string>South Dakota</string></value> </param> </params> </methodResponse>
  12. 12. Basic Parameter Types Integer (4-byte, signed) <i4> or <int> Boolean <boolean> String <string> Double Precision Floating Point <double> Date/Time <dateTime.iso8601> Binary <base64>
  13. 13. More 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.
  14. 14. 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>
  15. 15. Example Structure Original: {'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>
  16. 16. Fault Responses 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.
  17. 17. Limitations 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.
  18. 18. Advantages 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.
  19. 19. 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)
  20. 20. 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.
  21. 21. SOAP Over XML-RPC 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.
  22. 22. SOAP Over Others 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.
  23. 23. Limitations of SOAP Is neither simple nor lightweight nor easyto-use. Specification not guaranteed stable yet. Documentation contains errors. Too many cooks working on the specification, not co-operating with each other very well.
  24. 24. Not Covered Here Defining an XML-RPC server. Detailed examples of XML-RPC requests and responses. Details on SOAP.
  25. 25. Links 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
  26. 26. Q&A

×