Extending the TestlinkXMLRPCServer class

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
rtessier
TestLink user
Posts: 9
Joined: Wed Jan 20, 2010 6:31 pm

Extending the TestlinkXMLRPCServer class

Post by rtessier »

Here's a suggestion I've found really useful for our deployment of the Testlink XML-RPC server.

I've split xmlrpc.php into two files: xmlrpc_class.php which includes the class definition and xmlrpc.php which has the following two lines:

require_once("xmlrpc_class.php");
$XMLRPCServer = new TestlinkXMLRCPServer();

Then, I modified the TestlinkXMLRPCServer constructor to accept an optional array of methods:

...
public function __construct($callbacks = array()) {
...

Finally, I added the following line right before calling the IXR_Server constructor:

...
$this->methods += $callbacks;
...

This allows a subclass to add its own methods without modifying the base class. This is very useful for me to add methods that I need but aren't yet implemented in the base class. These "extended" methods could then eventually be submitted for inclusion in the base class. in which case the base class definition would override the subclass definition.

i.e.

class MyClass extends TestlinkXMLRPCServer {
public funtion __construct() {
$callbacks = array( 'tl.getTestSuiteIDByName' => 'this:getTestSuiteIDByName' );
parent::__construct($callbacks);
}

public function getTestSuiteIDByName() {
...
}
}

Please consider adding this change to the API, I believe it could be very useful for many people.

Keep up the good work!
Robin
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Post by fman »

Please: submit this into mantis as feature request
Post Reply