Extending the TestlinkXMLRPCServer class

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

Extending the TestlinkXMLRPCServer class

Postby rtessier » Wed Jan 20, 2010 7:00 pm

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
rtessier
TestLink user
 
Posts: 9
Joined: Wed Jan 20, 2010 6:31 pm

Postby fman » Fri Jan 22, 2010 8:33 pm

Please: submit this into mantis as feature request
fman
Member of TestLink Community
 
Posts: 3088
Joined: Tue Nov 15, 2005 7:19 am


Return to XML-RPC API



Who is online

Users browsing this forum: No registered users and 9 guests

cron