From d4f8dedfcae7dbe56bef2f8bc3741bde560a7dd2 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Tue, 21 Feb 2006 19:51:23 +0000 Subject: [PATCH] - SOAP interface for PHP git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@165 a67ec6bc-e5d5-0310-a910-815c51eb3124 --- backend/gvadm/soapserver.py | 6 ++--- php/.htaccess | 2 ++ php/SOAPRequester.php | 48 +++++++++++++++++++++++++++++++++++++ php/TestSOAPRequester.php | 40 +++++++++++++++++++++++++++++++ php/runtests.php | 14 +++++++++++ 5 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 php/.htaccess create mode 100644 php/SOAPRequester.php create mode 100644 php/TestSOAPRequester.php create mode 100644 php/runtests.php diff --git a/backend/gvadm/soapserver.py b/backend/gvadm/soapserver.py index 42a30a5..65993df 100644 --- a/backend/gvadm/soapserver.py +++ b/backend/gvadm/soapserver.py @@ -11,9 +11,9 @@ class GnuviechAdminSOAPServer(SOAPServer): """ SOAP Server class for the gnuviech administration tool backend """ - def echo(self, s): - self.logger.debug("calling echo with " + s) - return s + s + def echo(self, param0): + self.logger.debug("calling echo with " + param0) + return param0 + param0 def __init__(self): SOAPServer.__init__(self, ("127.0.0.1", 8080)) diff --git a/php/.htaccess b/php/.htaccess new file mode 100644 index 0000000..f565327 --- /dev/null +++ b/php/.htaccess @@ -0,0 +1,2 @@ +# configuration for PEAR +php_value include_path "/home/jan/pear/php/" \ No newline at end of file diff --git a/php/SOAPRequester.php b/php/SOAPRequester.php new file mode 100644 index 0000000..2a348b2 --- /dev/null +++ b/php/SOAPRequester.php @@ -0,0 +1,48 @@ + + * @version $Id$ + */ +require_once('SOAP/Client.php'); + +/** + * SOAP requester. + */ +class SOAPRequester { + /** + * SOAP_Client-Instanz. + * @access private + */ + var $soapclient; + + /** + * Constructor expecting a settings array. + * @param settings with options protocol, hostname, portnumber, path + * @access public + */ + function SOAPRequester($settings) { + $this->soapclient = new SOAP_Client(sprintf("%s://%s:%d/%s", + $settings['protocol'], + $settings['hostname'], + $settings['portnumber'], + $settings['path'])); + } + + /** + * Calls the echo method at the remote SOAP server. + * @param String parameter + * @return twice the String if the remote call is successful + */ + function callecho($param) { + $options = array('trace' => 1); + + $ret = $this->soapclient->call('echo', + $params = array('param0' => $param), + $options); + + return $ret; + } +} +?> \ No newline at end of file diff --git a/php/TestSOAPRequester.php b/php/TestSOAPRequester.php new file mode 100644 index 0000000..c3fabdc --- /dev/null +++ b/php/TestSOAPRequester.php @@ -0,0 +1,40 @@ + + * @version $Id$ + */ +require_once('PHPUnit.php'); +require_once('SOAPRequester.php'); + +/** + * TestCase for SOAPRequester. + */ +class TestSOAPRequester extends PHPUnit_TestCase { + /** + * SOAPRequester-Instanz. + */ + var $requester; + + /** + * Sets up the test case. + * @see PHPUnit_TestCase#setUp() + */ + function setUp() { + $settings = array('protocol' => 'http', + 'hostname' => 'localhost', + 'portnumber' => 8080, + 'path' => ''); + $this->requester = new SOAPRequester($settings); + } + + /** + * Tests the SOAPRequester class's callEcho method. + * @see SOAPRequester#callEcho(string) + */ + function testCallEcho() { + $result = $this->requester->callEcho('Test'); + $this->assertEquals('TestTest', $result); + } +} +?> \ No newline at end of file diff --git a/php/runtests.php b/php/runtests.php new file mode 100644 index 0000000..0bb19f4 --- /dev/null +++ b/php/runtests.php @@ -0,0 +1,14 @@ + + * @version $Id$ + */ +require_once('TestSOAPRequester.php'); +require_once('PHPUnit.php'); + +$suite = new PHPUnit_TestSuite('TestSOAPRequester'); +$result = PHPUnit::run($suite); + +printf($result->toHTML()); +?> \ No newline at end of file