Minahito
minah****@users*****
2006年 6月 28日 (水) 14:44:14 JST
Index: xoops2jp/html/class/XCube_Service.class.php diff -u xoops2jp/html/class/XCube_Service.class.php:1.1.2.3 xoops2jp/html/class/XCube_Service.class.php:1.1.2.4 --- xoops2jp/html/class/XCube_Service.class.php:1.1.2.3 Mon Jan 2 21:41:35 2006 +++ xoops2jp/html/class/XCube_Service.class.php Wed Jun 28 14:44:14 2006 @@ -1,4 +1,8 @@ <?php +/** + * @package XCube + * @version $Id: XCube_Service.class.php,v 1.1.2.4 2006/06/28 05:44:14 minahito Exp $ + */ /** * *An experiment class* @@ -7,24 +11,50 @@ */ class XCube_Service { - var $mOperations=array(); - var $mErrorStr=null; + var $mOperations = array(); + var $mErrorStr = null; function XCube_Service() { } + + function prepare() + { + } - function register($name,$in=false,$out=false) + function register($name, $in=false, $out=false) { - $this->mOperations[$name]=array( - "name"=>$name, - "in"=>$in, - "out"=>$out); + $this->mOperations[$name] = array( + "name" => $name, + "in" => $in, + "out" => $out + ); } function setError($message) { - $this->mErrorStr=$message; + $this->mErrorStr = $message; + } + + /** + * Return public URL of WSDL. If the public service doesn't exist, return + * null. + * + * @return string + */ + function getWSDLUrl() + { + return null; + } + + /** + * If this instance is outer web service, return true. + * + * @return bool + */ + function isOuterService() + { + return false; } } @@ -33,37 +63,18 @@ * This class is the adapter of a service class. * I give a caller the interface that resembled NUSOAP. */ -class XCube_ServiceClient +class XCube_AbstractServiceClient { var $mService; var $mClientErrorStr; - function XCube_ServiceClient($point) + function XCube_AbstractServiceClient(&$service) { - if(is_object($point)) - $this->mService=&$point; + $this->mService =& $service; } - function &call($operation,&$parameters) + function call() { - $ret =null; - - $this->mClientErrorStr=null; - - if(!is_object($this->mService)) { - $this->mClientErrorStr="This instance is not connected to service"; - return $ret; - } - - $methodName="do".ucfirst($operation); - if(method_exists($this->mService,$methodName)) { - $ret = call_user_func(array($this->mService,$methodName),$parameters); - return $ret; - } - else { - $this->mClientErrorStr="operation $operation not present."; - return $ret; - } } function getOperationData($operation) @@ -81,4 +92,37 @@ } } +class XCube_ServiceClienet extends XCube_AbstractServiceClient +{ + function call() + { + $this->mClientErrorStr = null; + + if(!is_object($this->mService)) { + $this->mClientErrorStr = "This instance is not connected to service"; + return null; + } + + $args = func_get_args(); + $operation = array_shift($args); + + if (isset($this->mService->mOperations[$operation])) { + $callback = null; + if (strstr($operation, ".") !== false) { + $tmp = explode(".", $operation); + $callback = array($tmp[0], $tmp[1]); + } + else { + $callback = array($this->mService, $operation); + } + + return call_user_func_array($callback, $args); + } + else { + $this->mClientErrorStr = "operation $operation not present."; + return null; + } + } +} + ?> \ No newline at end of file