Miscellaneous

  Home arrow Miscellaneous arrow Page 7 - Remote Procedure Calls with PEAR::XML-...
MISCELLANEOUS

Remote Procedure Calls with PEAR::XML-RPC
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2004-01-29

    Table of Contents:
  • Remote Procedure Calls with PEAR::XML-RPC
  • The Example Script
  • An XML_RPC Exchange
  • Client Rewritten Example
  • Client Sending
  • Client Receiving
  • Server Rewritten Example
  • Distributed Function Requirements
  • Inside the Function
  • Map and Send
  • The Output
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Remote Procedure Calls with PEAR::XML-RPC - Server Rewritten Example


    (Page 7 of 12 )

    Now it's time to explore a server component capable of handling the XML-RPC message. PEAR::XML-RPC also provides us an easy way to do this:

    <?php
    require_once("XML/RPC/Server.php");

    $getnamelength_sig = array(array("int", "string", "string"));
    $getnamelength_doc = "Accepts two string parameters, joins them and then returns the length of the resulting string.";

    function getnamelength($msg) {

      $name1 = $msg->getParam(0);
      $name2 = $msg->getParam(1);

      $length = strlen($name1->scalarval() . $name2->scalarval());

      $result = new XML_RPC_Value( $length, "int");

      return new XML_RPC_Response($result);
    }

    $map = array("getNameLength" => 
                    array("function"  => "getnamelength",
                          "signature" => $getnamelength_sig,
                          "docstring" => $getnamelength_doc));
    new XML_RPC_Server($map);

    The XML/RPC/Server.php class is included from the PEAR library. The server class imports the functionality of XML/RPC.php, so you only need just the one include.

    <?php
    require_once("XML/RPC/Server.php");
    ?>

    More Miscellaneous Articles
    More By bluephoenix

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


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