PEAR Articles

  Home arrow PEAR Articles arrow Using XML_RPC2 with PEAR

Using XML_RPC2 with PEAR
By: Chris Moyer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1

    Table of Contents:
  • Using XML_RPC2 with PEAR
  • Creating an XML-RPC Client
  • Creating an XML-RPC Server
  • Cached Results



    Using XML_RPC2 with PEAR

    (Page 1 of 4 )

    In this final part of a four-part series that explores PEAR, you will learn about the XML-RPC protocol, which is very useful when it comes to building web services. It is surprisingly simple, both to install and to use. You'll learn how to create a client and more.

    About XML-RPC

    XML-RPC is an XML-based protocol which allows various languages to inter-operate in a standards-based manner. The protocol encapsulates the data of method calls in a simple XML format which can then be easily transmitted over HTTP. Many popular sites provide a web service which uses this protocol. The ability to consume these services, or provide APIs of your own, will give you many options when seeking to have your site work with others.

    XML-RPC is often considered the predecessor to SOAP and originated in 1998. It was originally created by Dave Winer of Userland, with the help of Microsoft. While many organizations have moved to provide SOAP or other interfaces, quite a few have maintained XML-RPC, as it is often seen as a nice, light weight, and simple solution.

    The specification for XML-RPC is very minimal, detailing only a handful of data types and a simple syntax for calling methods. The included data types are explained in this table:

    Data Type

    XML-RPC Translation

    PHP Equivalent



    boolean: TRUE, FALSE



    double: 3.14



    int: 42


    <string>Simple String</string>

    string: "Simple String"


    <nil />






    date('c') (added in PHP5)
















    Non-associative array:















    <name>The Answer</name>






    associative array:


    'pi' => 3.14,

    'The Answer' => 42


    As you can see, the XML-RPC protocol allows a variety of simple and complex data structures to be converted into a simple XML syntax. This simplicity allows a variety of languages and platforms to easily inter-operate, sending simple XML snippets back and forth and translating them easily into native data structures.

    Installing XML_RPC2

    PEAR provides a convenient package for accessing and creating XML-RPC services, XML_RPC2. To use the following examples, you'll need to install the package.

    > sudo pear install XML_RPC2

    downloading XML_RPC2-1.0.2.tgz ...

    Starting to download XML_RPC2-1.0.2.tgz (49,025 bytes)

    .............done: 49,025 bytes

    install ok: channel://

    Assuming you get the "install ok" message, you're ready to go! The XML_RPC2 files have been installed in your directory, and can be included in your applications.

    More PEAR Articles Articles
    More By Chris Moyer

    blog comments powered by Disqus


    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning

    Developer Shed Affiliates


    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap