You are previewing Programming Web Services with XML-RPC.
O'Reilly logo
Programming Web Services with XML-RPC

Book Description

Have you ever needed to share processing between two or more computers running programs written in different languages on different operating systems? Or have you ever wanted to publish information on the Web so that programs other than browsers could work with it? XML-RPC, a system for remote procedure calls built on XML and the ubiquitous HTTP protocol, is the solution you've been looking for. Programming Web Services with XML-RPC introduces the simple but powerful capabilities of XML-RPC, which lets you connect programs running on different computers with a minimum of fuss, by wrapping procedure calls in XML and establishing simple pathways for calling functions. With XML-RPC, Java programs can talk to Perl scripts, which can talk to Python programs, ASP applications, and so on. You can provide access to procedure calls without having to worry about the system on the other end, so it's easy to create services that are available on the Web. XML-RPC isn't the only solution for web services; the Simple Object Access Protocol (SOAP) is another much-hyped protocol for implementing web services. While XML-RPC provides fewer capabilities than SOAP, it also has far fewer interoperability problems and its capabilities and limitations are much better understood. XML-RPC is also stable, with over 30 implementations on a wide variety of platforms, so you can start doing real work with it immediately. Programming Web Services with XML-RPC covers the details of five XML-RPC implementations, so you can get started developing distributed applications in Java, Perl, Python, ASP, or PHP. The chapters on these implementations contain code examples that you can use as the basis for your own work. This book also provides in-depth coverage of the XML-RPC specification, which is helpful for low-level debugging of XML-RPC clients and servers. And if you want to build your own XML-RPC implementation for another environment, the detailed explanations in this book will serve as a foundation for that work.

Table of Contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Foreword
  4. Preface
    1. Audience
    2. Organization
    3. Conventions Used in This Book
    4. Using Code Examples
    5. How to Contact Us
    6. Acknowledgments
      1. Simon St.Laurent’s Acknowledgements
      2. Joe Johnston’s Acknowledgments
      3. Edd Dumbill’s Acknowledgments
  5. 1. Introduction
    1. What XML-RPC Does
      1. Remote Procedure Calls (RPC)
      2. Letting Computers Talk: XML and the Web
      3. Reusing Web Protocols and Infrastructure
      4. Building a Different Kind of Web
    2. Where XML-RPC Excels
    3. A Quick Tour of the Minefields
      1. RPC Issues
      2. Protocol Reuse Issues
        1. HTTP isn’t very efficient
        2. XML-RPC isn’t your average web page
        3. Breaking through firewalls by reusing HTTP
  6. 2. The XML-RPC Protocol
    1. Choreography
      1. Synchronous
      2. Stateless
    2. Data Types
      1. Simple Data Types
        1. Integers
        2. Floating-point numbers
        3. Boolean values
        4. Strings
        5. Date-times
        6. Binary
      2. Compound Data Types
        1. Arrays
        2. Structs
    3. Request Format
      1. XML Payload
        1. Parameters
        2. Method naming
      2. HTTP Headers
        1. POST
        2. Host
        3. Content-Type
        4. Content-Length
        5. User-Agent
        6. Using other headers
      3. A Complete Request
    4. Response Format
      1. Method Result
      2. Fault Reporting
      3. HTTP Headers
        1. HTTP response code
        2. Server
        3. Content-Type
        4. Content-Length
      4. A Complete Response
    5. The Nil Value
    6. A DTD for XML-RPC
  7. 3. Client-Server Communication: XML-RPC in Java
    1. Why XML-RPC for Java?
    2. The XML-RPC Java Library
      1. Installing the helma.xmlrpc Library
      2. General XML-RPC Library Configuration
      3. Data Types and Java XML-RPC
    3. Building XML-RPC Clients
    4. Building XML-RPC Servers
      1. Using the WebServer Class
      2. Using XmlRpcServer Without WebServer
    5. Creating XML-RPC Handlers
      1. Creating Handlers Using Automatic Registration
      2. Creating Handlers Using Explicit Registration
    6. Three Practical Examples
      1. Library Functions
      2. Reporting
      3. A get and set Approach
    7. Moving Toward Cross-Platform Peer-to-Peer
  8. 4. XML-RPC and Perl
    1. Perl’s Implementation of XML-RPC
    2. Data Types
      1. Translating Perl Values to XML-RPC Elements
      2. Packaging Scalar Values
      3. Preparing Date-Time Data
      4. Preparing Encoded Binary Data
      5. Using Helper Methods to Create Objects
      6. Preparing Array and Hash Data
      7. Translating XML-RPC Elements to Perl Values
      8. Extracting Values from Objects
      9. Determining the Type of Object
    3. XML-RPC Clients
      1. Client Architecture
      2. Invoking a Remote Procedure
        1. Creating the client object
        2. Calling the XML-RPC method
        3. Getting the response to the call
        4. Handling error responses
      3. A Client Script
    4. XML-RPC Servers
      1. Server Architecture
      2. Setting Up an XML-RPC Server
      3. A Server Script
    5. Integrating XML-RPC into a Web Server
  9. 5. Integrating Web Applications: XML-RPC in PHP
    1. Getting the XML-RPC Library for PHP
    2. Understanding the Client Classes
    3. Mapping Data Between PHP and XML-RPC
      1. Getting PHP Data into XML-RPC Tags
      2. Turning XML-RPC Data Back into PHP
      3. Shortcuts to Encoding and Decoding XML-RPC Values
    4. Invoking Methods
      1. Preparing a Client Object
      2. Preparing a Method Invocation and Its Parameters
      3. Invoking the Method
      4. Checking the Result
      5. Handling XML-RPC Error Conditions
    5. Building XML-RPC Servers in PHP
      1. Methods
      2. Service Descriptions
      3. Servicing a Request
      4. Introspection
    6. Connecting Web Applications
      1. Creating a Discussion Server
      2. Meerkat: O’Reilly’s Technology Database
      3. Joining Meerkat and the Discussion Server
      4. A Closer Look at the Meerkat Discussion Server
    7. What PHP and XML-RPC Can Do
  10. 6. XML-RPC and Python
    1. Python Implementations of XML-RPC
    2. Installing PythonWare XML-RPC
    3. Data Types
      1. Python Data and XML Elements
        1. Data types that require no extra work
        2. Data types that must be wrapped in an object
          1. Boolean data
          2. Date-time data
          3. Binary data
    4. XML-RPC Clients
      1. Client Architecture
      2. A Client Script
    5. XML-RPC Servers
      1. Setting Up an XML-RPC Server
        1. Creating a copy of the script
        2. Setting a port number
        3. Recoding the call( ) method to define the API
          1. Creating a hierarchical API
        4. Creating dispatch functions to implement the API
          1. Processing the argument list
          2. Returning a value
          3. Returning a fault value
        5. Running the server script
      2. A Server Script
    6. Integrating XML-RPC into a Web Server
    7. Using Zope as an XML-RPC Server
  11. 7. Bridging XML-RPC and COM: XML-RPC in ASP
    1. Using XML-RPC with ASP
    2. Making Active Server Pages More Active
      1. From Person-to-Computer to Computer-to-Computer
      2. Treating ASP as a Window into Your System
    3. Data Types and the API
    4. Building an Address Book Web Service with ASP
      1. Getting the Contents of the Address Book
      2. Looking up Entries in the Address Book
      3. Adding and Removing Address Book Entries
    5. Talking to MS Access from Linux
    6. An XML-RPC Client in ASP
    7. Creating a Window to Linux
    8. Connections and Caveats
      1. No Transaction Support
      2. Expect Speed Hits
      3. Debugging is Terrible
      4. Keep the API Current
      5. Where to Find the VBScript XML-RPC Library
      6. Where to Find the COM XML-RPC Library
  12. 8. XML-RPC and the Web Services Landscape
    1. The Web Services Vision
    2. Public XML-RPC Services
    3. Design Considerations for Any XML-RPC Application
      1. Debugging
      2. Network Latency
      3. Documentation
      4. Logging
      5. Authentication and Authorization
      6. Payloads: Big and Secret
      7. Statelessness
    4. Beyond XML-RPC
      1. SOAP: Simple Object Access Protocol
      2. UDDI: Universal Description, Discovery, and Integration of Business for the Web
      3. WSDL: Web Services Description Language
      4. W3C XML Protocol Activity
      5. BXXP: Blocks eXtensible eXchange Protocol
    5. Protocol Design Choices
    6. XML-RPC and Web Services
  13. A. The XML You Need for XML-RPC
    1. What is XML?
    2. Anatomy of an XML Document
      1. Elements and Attributes
      2. Name Syntax
      3. Well-Formed
      5. Entity References
      6. Character References
    3. Character Encodings
      1. Unicode Encoding Schemes
      2. Other Character Encodings
    4. Validity
      1. Document Type Definitions (DTDs)
        1. Element type declarations
        2. Attribute list declarations
      2. Putting It Together
    5. Tools for Processing XML
      1. Selecting a Parser
      2. XSLT Processors
    6. Is That All There Is?
  14. B. The HTTP You Need for XML-RPC
    1. A Bit About TCP/IP
    2. HTTP at the Start of the Web
    3. Adding Two-Way Communications
      1. A Richer Set of Headers
      2. POST: the Key to XML-RPC
    4. Making Two-Way Communications Efficient
    5. Making the Infrastructure Do Something Different
    6. Infrastructure Details
      1. MIME Types
      2. HTTPS, VPNs, and Other Security Measures
      3. Things XML-RPC Leaves Out
  15. Index
  16. About the Authors
  17. Colophon
  18. Special Upgrade Offer
  19. Copyright