Login   Register  
PHP Classes
elePHPant
Icontem

File: README.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ivan Ristic  >  XML-RPC Class Server  >  README.txt  >  Download  
File: README.txt
Role: ???
Content type: text/plain
Description: Read this first
Class: XML-RPC Class Server
Turns any PHP class into an XML-RPC server
Author: By
Last change:
Date: 2002-05-09 19:53
Size: 3,239 bytes
 

Contents

Class file image Download
XCS v1.0 (XML-RPC Class Server for PHP)
Copyright (C) 2002 Ivan Ristic, ivanr@webkreator.com

XCS homepage is at: http://www.webkreator.com/php/techniques/instant-webservices-with-php-and-xml-rpc.html

1. Description
--------------

This script ('xcs.php') will enable you to use
the power of XML-RPC by exposing the methods of any class
found in the same directory with the script.

You only need to place the script in the directory of
your choice, and to construct the URL properly. The purpose
of the URL is to address the object and supply the
constructor data. For example, the following URL

  http://localhost/xcs.php/test/42

is equivalent to

  include('./class.test.php');
  $object = new Test('42');

The URL is sufficient to instantiate the object, and now
you can continue to use XML-RPC as usual to invoke a
method on the object.

The name of the class is mandatory. There can be any
number of constructor parameters. Please note that XCS
uses the XML-RPC extension as described here
http://www.php.net/manual/en/ref.xmlrpc.php


2. Private methods
------------------

PHP does not have private methods but, in a typical
class, you will want to prevent the outside world from
calling all methods. This is supported. If the name
of the method begins with an underscore, the method
will be considered to be private.


3. GET simulation
-----------------

Testing XML-RPC software can be difficult because you
can't use the browser and the GET method. With XCS, you
can use the GET method and, in some simple cases, it
will simulate the POST payload for you.

Here is an example:

http://localhost/xcs.php/test/42?_method=sayhello&name=Ivan

There is one special parameter, "_method" and it needs
to contain the name of the method. All other GET parameters
will be treated as parameters for the payload. The response
will be a standard XML-RPC response.


4. Examples
-----------

Files

  class.test.php	// a class sitting on the server
  class.remotest.php	// local class, the proxy for the class test
  test.php		// example how to call remote objects
  xmlrpc-utils.php	// the utils class from the XML-RPC distribution
  
are usage examples. If you execute the script 'test.php' from
your browser, it will attempt to invoke the remote object over
HTTP. It will actually try to call the same server using the
environment variables SERVER_NAME and REQUEST_URI.


5. TODO
-------

Some other things I want to do:

 * Move all error messages to the XML-RPC style
 
 * Automatic proxy class generation; This can work with other
   XML-RPC services but possibly not with this one as I
   didn't find a way to extract method parameters. The
   other solution is to standardise on javadoc style
   of documentation and then write the parser for that
 
 * Escape method names with GET simulation
 
 * Automatically lowercase method names
 
 * Create the ultimate XML-RPC proxy class; this is not
   possible yet, but it will be at some point in future
 
   http://www.php.net/manual/en/ref.overload.php
   
 * Improve error handling and logging
   
 * Improve security
 
 * See if the concept can be extended to cover SOAP too