diff --git a/webservice/classes/soap/WSHelper.class.php b/webservice/classes/soap/WSHelper.class.php index a7e82cb..5bd0058 100755 --- a/webservice/classes/soap/WSHelper.class.php +++ b/webservice/classes/soap/WSHelper.class.php @@ -1,183 +1,183 @@ -uri = $uri; - $this->setWSDLCacheFolder($_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/wsdl/"); - if($class) $this->setClass($class); - } - - /** - * Adds the given class name to the list of classes - * to be included in the documentation/WSDL/Request handlers - * @param string - * @return void - */ - public function setClass($name){ - $this->name = $name; - $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; - } - - public function setWSDLCacheFolder($folder) { - $this->wsdlFolder = $folder; - //reset wsdlfile - $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; - } - /** - * Sets the persistence level for the soap class - */ - public function setPersistence($persistence) { - $this->persistence = $persistence; - } - - /** - * Handles everything. Makes sure the webservice is handled, - * documentations is generated, or the wsdl is generated, - * according to the page request - * @return void - */ - public function handle(){ - if(substr($_SERVER['QUERY_STRING'], -4) == 'wsdl'){ - $this->showWSDL(); - }elseif(isset($GLOBALS['HTTP_RAW_POST_DATA']) && strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0){ - $this->handleRequest(); - }else{ - $this->createDocumentation(); - } - } - /** - * Checks if the current WSDL is up-to-date, regenerates if necessary and outputs the WSDL - * @return void - */ - public function showWSDL(){ - //check if it's a legal webservice class - if(!in_array($this->name, $this->classNameArr)) - throw new Exception("No valid webservice class."); - - //@TODO: nog een mooie oplossing voor het cachen zoeken - header("Content-type: text/xml"); - if($this->useWSDLCache && file_exists($this->wsdlfile)){ - readfile($this->wsdlfile); - }else{ - //make sure to refresh PHP WSDL cache system - ini_set("soap.wsdl_cache_enabled",0); - echo $this->createWSDL(); - } - } - - private function createWSDL(){ - $this->class = new IPReflectionClass($this->name); - $wsdl = new WSDLStruct($this->uri, "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?class=".$this->name, $this->type, $this->use); - $wsdl->setService($this->class); - - try { - $gendoc = $wsdl->generateDocument(); - } catch (WSDLException $exception) { - $exception->Display(); - exit(); - } - - $fh = fopen($this->wsdlfile, "w+"); - fwrite($fh, $gendoc); - fclose($fh); - - return $gendoc; - } - - /** - * Lets the native PHP5 soap implementation handle the request - * after registrating the class - * @return void - */ - private function handleRequest(){ - //check if it's a legal webservice class - if(!in_array($this->name, $this->classNameArr)) - throw new Exception("No valid webservice class."); - - //check cache - //if(!file_exists($this->wsdlfile)) - $this->createWSDL(); - - $options = Array('actor' => $this->actor, 'classmap' => $this->structureMap); - - header("Content-type: text/xml"); - $this->server = new SoapServer($this->wsdlfile, $options); - $this->server->setClass($this->name); - $this->server->setPersistence($this->persistence); - - use_soap_error_handler(true); - $this->server->handle(); - } - - /** - * @param string code - * @param string string - * @param string actor - * @param mixed details - * @param string name - * @return void - */ - public function fault($code, $string, $actor, $details, $name='') { - return $this->server->fault($code, $string, $actor, $details, $name); - } - - /** - * Generates the documentations for the webservice usage. - * @TODO: "int", "boolean", "double", "float", "string", "void" - * @param string Template filename - * @return void - */ - public function createDocumentation($template="classes/soap/templates/docclass.xsl") { - if(!is_file($template)) - throw new WSException("Could not find the template file: '$template'"); - $this->class = new IPReflectionClass($this->name); - $xtpl = new IPXSLTemplate($template); - $documentation = Array(); - $documentation['menu'] = Array(); - //loop menu items - sort($this->classNameArr); - foreach($this->classNameArr as $className) { - $documentation['menu'][] = new IPReflectionClass($className); - } - - if($this->class){ - $this->class->properties = $this->class->getProperties(false, false); - $this->class->methods = $this->class->getMethods(false, false); - foreach((array)$this->class->methods as $method) { - $method->params = $method->getParameters(); - } - - $documentation['class'] = $this->class; - } - echo $xtpl->execute($documentation); - } -} +uri = $uri; + $this->setWSDLCacheFolder($_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/wsdl/"); + if($class) $this->setClass($class); + } + + /** + * Adds the given class name to the list of classes + * to be included in the documentation/WSDL/Request handlers + * @param string + * @return void + */ + public function setClass($name){ + $this->name = $name; + $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; + } + + public function setWSDLCacheFolder($folder) { + $this->wsdlFolder = $folder; + //reset wsdlfile + $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; + } + /** + * Sets the persistence level for the soap class + */ + public function setPersistence($persistence) { + $this->persistence = $persistence; + } + + /** + * Handles everything. Makes sure the webservice is handled, + * documentations is generated, or the wsdl is generated, + * according to the page request + * @return void + */ + public function handle(){ + if(substr($_SERVER['QUERY_STRING'], -4) == 'wsdl'){ + $this->showWSDL(); + }elseif(isset($GLOBALS['HTTP_RAW_POST_DATA']) && strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0){ + $this->handleRequest(); + }else{ + $this->createDocumentation(); + } + } + /** + * Checks if the current WSDL is up-to-date, regenerates if necessary and outputs the WSDL + * @return void + */ + public function showWSDL(){ + //check if it's a legal webservice class + if(!in_array($this->name, $this->classNameArr)) + throw new Exception("No valid webservice class."); + + //@TODO: nog een mooie oplossing voor het cachen zoeken + header("Content-type: text/xml"); + if($this->useWSDLCache && file_exists($this->wsdlfile)){ + readfile($this->wsdlfile); + }else{ + //make sure to refresh PHP WSDL cache system + ini_set("soap.wsdl_cache_enabled",0); + echo $this->createWSDL(); + } + } + + private function createWSDL(){ + $this->class = new IPReflectionClass($this->name); + $wsdl = new WSDLStruct($this->uri, "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?class=".$this->name, $this->type, $this->use); + $wsdl->setService($this->class); + + try { + $gendoc = $wsdl->generateDocument(); + } catch (WSDLException $exception) { + $exception->Display(); + exit(); + } + + $fh = fopen($this->wsdlfile, "w+"); + fwrite($fh, $gendoc); + fclose($fh); + + return $gendoc; + } + + /** + * Lets the native PHP5 soap implementation handle the request + * after registrating the class + * @return void + */ + private function handleRequest(){ + //check if it's a legal webservice class + if(!in_array($this->name, $this->classNameArr)) + throw new Exception("No valid webservice class."); + + //check cache + //if(!file_exists($this->wsdlfile)) + $this->createWSDL(); + + $options = Array('actor' => $this->actor, 'classmap' => $this->structureMap); + + header("Content-type: text/xml"); + $this->server = new SoapServer($this->wsdlfile, $options); + $this->server->setClass($this->name); + $this->server->setPersistence($this->persistence); + + use_soap_error_handler(true); + $this->server->handle(); + } + + /** + * @param string code + * @param string string + * @param string actor + * @param mixed details + * @param string name + * @return void + */ + public function fault($code, $string, $actor, $details, $name='') { + return $this->server->fault($code, $string, $actor, $details, $name); + } + + /** + * Generates the documentations for the webservice usage. + * @TODO: "int", "boolean", "double", "float", "string", "void" + * @param string Template filename + * @return void + */ + public function createDocumentation($template="classes/soap/templates/docclass.xsl") { + if(!is_file($template)) + throw new WSException("Could not find the template file: '$template'"); + $this->class = new IPReflectionClass($this->name); + $xtpl = new IPXSLTemplate($template); + $documentation = Array(); + $documentation['menu'] = Array(); + //loop menu items + sort($this->classNameArr); + foreach($this->classNameArr as $className) { + $documentation['menu'][] = new IPReflectionClass($className); + } + + if($this->class){ + $this->class->properties = $this->class->getProperties(false, false); + $this->class->methods = $this->class->getMethods(false, false); + foreach((array)$this->class->methods as $method) { + $method->params = $method->getParameters(); + } + + $documentation['class'] = $this->class; + } + echo $xtpl->execute($documentation); + } +} ?> \ No newline at end of file diff --git a/webservice/classes/soap/templates/str.replace.function.xsl b/webservice/classes/soap/templates/str.replace.function.xsl index 5d74e86..626e549 100755 --- a/webservice/classes/soap/templates/str.replace.function.xsl +++ b/webservice/classes/soap/templates/str.replace.function.xsl @@ -1,105 +1,105 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: function implementation of str:replace() relies on exsl:node-set(). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ERROR: function implementation of str:replace() relies on exsl:node-set(). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/webservice/tests/annotations.php b/webservice/tests/annotations.php index e10ef44..a0ee1ff 100755 --- a/webservice/tests/annotations.php +++ b/webservice/tests/annotations.php @@ -1,44 +1,44 @@ -'you'); - */ -class something{ - /** - * @var string - * @Controller(type => DefaultController::TYPE_PLAIN, length => 100) - */ - public $propertyA; - - /** - * @var string - * @Controller(type => DefaultController::TYPE_HTML, length => 100) - */ - public function methodB () { - return "aap"; - } -} - -/* Annotation example */ -$rel = new IPReflectionClass("something"); -$properties = $rel->getProperties(); -$methods = $rel->getMethods(); - -var_dump($rel->getAnnotation("ann1", "stdClass")); - -$property = $properties["propertyA"]; -$ann = $property->getAnnotation("Controller", "DefaultController"); -var_dump($ann); - -$method = $methods["methodB"]; -$ann = $method->getAnnotation("Controller", "DefaultController"); -var_dump($ann); +'you'); + */ +class something{ + /** + * @var string + * @Controller(type => DefaultController::TYPE_PLAIN, length => 100) + */ + public $propertyA; + + /** + * @var string + * @Controller(type => DefaultController::TYPE_HTML, length => 100) + */ + public function methodB () { + return "aap"; + } +} + +/* Annotation example */ +$rel = new IPReflectionClass("something"); +$properties = $rel->getProperties(); +$methods = $rel->getMethods(); + +var_dump($rel->getAnnotation("ann1", "stdClass")); + +$property = $properties["propertyA"]; +$ann = $property->getAnnotation("Controller", "DefaultController"); +var_dump($ann); + +$method = $methods["methodB"]; +$ann = $method->getAnnotation("Controller", "DefaultController"); +var_dump($ann); ?> \ No newline at end of file