cvs: pear /Services_Webservice/vacation Webservice.php package.xml /Services_Webservice/vacation/Webservice Common.php Definition.php Exception.php
ReST.php SOAP.php /Services_Webservice/vacation/Webservice/Definition DISCO.php Exception.php HTML.php WSDL.php /Services_Webservice/vacation/tests
test_01.php test_02.php
| From: | Manfred Weber | Date: | Thu, 28 Dec 2006 10:19:14 +0000 |
| Subject: | cvs: pear /Services_Webservice/vacation Webservice.php package.xml /Services_Webservice/vacation/Webservice Common.php Definition.php Exception.php ReST.php SOAP.php /Services_Webservice/vacation/Webservice/Definition DISCO.php Exception.php HTML.php WSDL.php /Services_Webservice/vacation/tests test_01.php test_02.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-43864@lists.php.net to get a copy of this message | ||
crafics Thu Dec 28 10:19:14 2006 UTC
Added files:
/pear/Services_Webservice/vacation Webservice.php package.xml
/pear/Services_Webservice/vacation/Webservice Common.php
Definition.php
Exception.php
ReST.php SOAP.php
/pear/Services_Webservice/vacation/Webservice/Definition DISCO.php
Exception.php
HTML.php
WSDL.php
/pear/Services_Webservice/vacation/tests test_01.php test_02.php
Log:
- just a backup
http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice.php +++ pear/Services_Webservice/vacation/Webservice.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Webservice.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR::Services_Webservice * * The PEAR::Services_Webservice class creates web services from your classes * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ abstract class Services_Webservice { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Protocol of the web service * * @var string * @access public */ public $protocol; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $_classname; /** * Class instance used by the web service * * @var object * @access protected */ protected $_classnameInstance = null; /** * Parameter for the user's web service class * * @var array * @access protected */ protected $_initParams = null; /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options * @access protected * @throws Services_Webservice_NotClassException */ protected function __construct($class, $namespace, $options = null) { if (is_object($class)) { $this->_classname = $class->get_class(); $this->_classnameInstance =& $class; } elseif (is_string($class)) { $this->_classname = $class; } else { throw new Services_Webservice_NotClassException( 'Expected a class name or instance.'); } if (trim($namespace) == '') { $namespace = 'http://example.org/'; } $this->namespace = $namespace; $this->protocol = 'http'; } /** * Returns a Services_Webservice server instance to handle incoming * requests. * * @param string $driver backend service type (for now only SOAP) * @var object|string $class * @var string $namespace * @var array $options * @access public * @throws Services_Webservice_UnknownDriverException * @throws Services_Webservice_NotClassException */ public function &factory($driver, $class, $namespace, $options = null) { $backend = 'Services_Webservice_' . $driver; include_once 'Services/Webservice/' . basename($driver) . '.php'; if (!class_exists($backend)) { require_once 'Services/Webservice/Exception.php'; throw Services_Webservice_UnknownDriverException('Unknown backend driver: ' . $driver); } $instance = new $backend($class, $namespace, $options); return $instance; } /** * Initializes web service * * The parameters passed to this method will be passed to your class * constructor * * @access public */ public function init() { $this->_initParams = func_get_args(); } /** * Automatically handles the incoming request * * The result depends on how the service was called and which backend * is used. * @access public */ abstract public function handle(); } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/package.xml?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/package.xml +++ pear/Services_Webservice/vacation/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> <name>Services_Webservice</name> <summary>Create web services and description (WSDL, DISCO, and info. page)</summary> <description> This package helps you easily create web services (SOAP). </description> <license>PHP License</license> <maintainers> <maintainer> <user>crafics</user> <name>Manfred Weber</name> <email>crafics@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>jausions</user> <name>Philippe Jausions</name> <email>Philippe.Jausions@11abacus.com</email> <role>lead</role> </maintainer> <maintainer> <user>mfonda</user> <name>Matthew Fonda</name> <email>mfonda@php.net</email> <role>developer</role> </maintainer> </maintainers> <release> <version>0.5.0</version> <state>alpha</state> <date>2005-08-12</date> <notes> Package restructuration: - New Services_Webservice_Definition helper classes, - New factory() method, - New backend driver-based service types (only SOAP for now.) BC Breaks: - Change in parameters for constructor! - $description is not public anymore, - Exceptions are thrown if docblocks are missing, invalid or incomplete for class, methods and properties declarations, - Don't extend Service_Webservice base class anymore. Support for short and long description docblock. Extended info page with complex type definitions. </notes> <filelist> <dir name="/" baseinstalldir="Services"> <file role="php">Webservice.php</file> <dir name="Webservice" role="php"> <file>Exception.php</file> <file>Definition.php</file> <file>Common.php</file> <file>ReST.php</file> <file>SOAP.php</file> <dir name="Definition" role="php"> <file>Exception.php</file> <file>DISCO.php</file> <file>HTML.php</file> <file>WSDL.php</file> </dir> </dir> </dir> <dir name="tests" role="test" baseinstalldir="Services/Webservice"> <file>test_01.php</file> </dir> </filelist> </release> <changelog> <release> <version>0.4.0</version> <state>alpha</state> <date>2005-07-24</date> <notes> - new WSDL model </notes> </release> <release> <version>0.3.1</version> <state>alpha</state> <date>2005-07-19</date> <notes> - Improved infopage (HTML) - method descriptions support (docblock parsing) </notes> </release> </changelog> <deps> <dep type="ext" rel="has">soap</dep> <dep type="php" rel="ge" version="5.1.0b2" /> </deps> </package> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Common.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Common.php +++ pear/Services_Webservice/vacation/Webservice/Common.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Common.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice.php'; /** * Services_Webservice implementation for common PHP-written backend * * The PEAR::Services_Webservice class creates web services from your classes * * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ * @todo Add input/output filters that will decode/encode the data from/to * a specified format (eventually nest filters) */ class Services_Webservice_Common extends Services_Webservice { /** * Handles the method call itself * * @param string $methodName the method to call with the payload * @access protected * @webservice.hidden * @throws Services_Webservice_IllegalCallException * @todo Add payload to method calls * @todo Fix the passing of parameters to the user's class constructor */ protected function _handle($methodName) { require_once 'Services/Webservice/Definition.php'; $definition = new Services_Webservice_Definition($this->_classname, $this->namespace); $definition->protocol = $this->protocol; if (!$definition->isMethodExposed($method, $static)) { require_once 'Services/Webservice/Exception.php'; throw new Services_Webservice_IllegalCallException('Unknown web service resource'); } if ($static) { echo call_user_func_array(array($this->_classname, $methodName)); } else { if (!is_object($this->_classnameInstance)) { if (!is_null($this->_initParams)) { $this->_classnameInstance = new $this->_classname($this->_initParams); } else { $this->_classnameInstance = new $this->_classname(); } } echo call_user_func_array(array(&$this->_classnameInstance, $methodName)); } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition.php +++ pear/Services_Webservice/vacation/Webservice/Definition.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose class as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Definition.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition /** * Include exception class declarations */ require_once 'Services/Webservice/Definition/Exception.php'; /** * Class to perform the introspection of the web service * * Uses Reflection API and parses docblock comments to do introspection * of the class's methods. * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Description of the web service * * @var string * @access protected */ protected $description; /** * Simple WSDL types * * @var array * @access protected */ protected $_simpleTypes = array( 'string', 'int', 'float', 'bool', 'double', 'integer', 'boolean', 'varstring', 'varint', 'varfloat', 'varbool', 'vardouble', 'varinteger', 'varboolean'); /** * Classes are parsed into this struct * * @var array * @access protected */ protected $_wsdlStruct; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $_classname; /** * Exclude these methods from web service * * @var array * @access protected */ protected $_hiddenMethods; /** * Some user-overwritten URIs * * @var array * @access protected */ protected $_URI = array(); /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options not currently used * @access public * @throws Services_Webservice_Definition_NotClassException */ public function __construct($class, $namespace, $options = null) { if (is_object($class)) { $this->_classname = $class->get_class(); } elseif (is_string($class)) { $this->_classname = $class; } else { throw new Services_Webservice_Definition_NotClassException( 'Expected a class name or instance.'); } if (trim($namespace) != '') { $this->namespace = $namespace; } else { $this->namespace = 'http://example.org/'; } $this->_wsdlStruct = array(); $this->_hiddenMethods = array( '__construct', '__destruct', '__call', '__get', '__set', '__sleep', '__wakeup', $this->_classname); } // }}} // {{{ intoStruct() /** * Parses classes into struct * * @access protected */ protected function intoStruct() { static $done = false; if (!$done) { $this->classMethodsIntoStruct(); $this->classStructDispatch(); $done = true; } } // }}} // {{{ getStruct() /** * Returns the structure of classes as parsed by intoStruct * * @return array * @access public */ public function getStruct() { $this->intoStruct(); return $this->_wsdlStruct; } // }}} // {{{ getClassName() /** * Returns the name of the class being defined * * @return string the nane of the class being introspected * @access public */ public function getClassName() { return $this->_classname; } // }}} // {{{ setURI() /** * Sets some URIs * * Allows to override the default value for some URI set in the definition * Currently documented URI identifier: * - WSDL : URI of the WSDL as it should be made public * - DISCO : URI of the DISCO as it should be made public * - doc : URI of the documentation page * - service: Base URI of the service * * @param string|array $name URI identifier or array of URI * @param string $URI * @access public */ public function setURI($name, $URI = null) { if (is_array($name)) { $this->_URI = array_merge($this->_URI, $name); } elseif (trim($name) && $URI) { $this->_URI[$name] = $URI; } } // }}} // {{{ getURI() /** * Returns some URIs * * @param string $name URI identifier or array of URI identifiers * @return mixed an array of found URIs if $name is an array, * a string if $name is a string, * or and NULL if $name is not found * @access public * @see setURI() */ public function getURI($name = null) { if (is_array($name)) { return array_intersect_key($this->_URI, array_flip($name)); } elseif (isset($this->_URI[$name])) { return $this->_URI[$name]; } return null; } // }}} // {{{ __call() /** * Returns web service definition in requested format * * Catch-all for toWSDL(), toHTML() and toDISCO() * * @param string $name method's name being actually called * @param array * @return string * @access public * @throws Services_Webservice_Definition_UnknownFormatException * @throws Services_Webservice_Definition_Exception */ public function __call($name, $arg) { list($format) = sscanf($name, 'to%s'); include_once 'Services/Webservice/Definition/' . basename($format) . '.php'; $class = 'Services_Webservice_Definition_' . $format; if (!class_exists($class)) { throw new Services_Webservice_Definition_UnknownFormatException( 'Unknown definition format.'); } $formatter = new $class($this); return $formatter->toString(); } // }}} // {{{ classStructDispatch() /** * Dispatches types * * @access protected * @throws Services_Webservice_Definition_Exception */ protected function classStructDispatch() { foreach ($this->_wsdlStruct[$this->_classname]['method'] as $method) { foreach ($method['var'] as $var){ if (($var['class'] == 1 && $var['length'] == 0) || ($var['class'] == 1 && $var['length'] > 0)) { $this->classPropertiesIntoStruct($var['type']); } if (($var['array'] == 1 && $var['length'] > 0) || ($var['class'] == 1 && $var['length'] > 0)) { $_typensSource = ''; for ($i = $var['length']; $i > 0; --$i) { $_typensSource .= 'ArrayOf'; $this->_wsdlStruct['array'][$_typensSource . $var['type']] = substr($_typensSource, 0, strlen($_typensSource) - 7) . $var['type']; } } } } } // }}} // {{{ classPropertiesIntoStruct() /** * Parses classes properties into struct * * @var string * @access private * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_IncompleteDocCommentException */ protected function classPropertiesIntoStruct($className) { if (!isset($this->_wsdlStruct[$className])) { $class = new ReflectionClass($className); $properties = $class->getProperties(); $this->_wsdlStruct['class'][$className]['property'] = array(); for ($i = 0; $i < count($properties); ++$i) { if ($properties[$i]->isPublic()) { $propertyName = $properties[$i]->getName(); try { $docComments = $this->_parseDocBlock($properties[$i]->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $className . '::' . $propertyName . ' property docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException( 'Empty or missing docblock comment for ' . $className . '::' . $propertyName . ' property.'); } // Skip property? if (isset($docComments['webservice.hidden'])) { continue; } $_properties =& $this->_wsdlStruct['class'][$className]['property'][$propertyName]; // Deprecated? if (isset($docComments['deprecated'])) { $_properties['deprecated'] = true; } // Description $_properties['description'] = @$docComments['shortDescription']; if (!isset($docComments['var'])) { throw new Services_Webservice_Definition_IncompleteDocCommentException('@var missing in docblock comment for ' . $className . '::' . $propertyName . ' property.'); } $var = $docComments['var']; $_cleanType = str_replace('[]', '', $var[0][0], $_length); $_typens = str_repeat('ArrayOf', $_length); $_properties['type'] = $_cleanType; $_properties['wsdltype'] = $_typens . $_cleanType; $_properties['length'] = $_length; $_properties['array'] = ($_length > 0 && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $isObject = (!in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_properties['class'] = $isObject; if ($isObject == true) { $this->classPropertiesIntoStruct($_cleanType); } if ($_length > 0) { $_typensSource = ''; for ($j = $_length; $j > 0; --$j) { $_typensSource .= 'ArrayOf'; $this->_wsdlStruct['array'][$_typensSource.$_cleanType] = substr($_typensSource, 0, strlen($_typensSource) - 7) . $_cleanType; } } } } } } // }}} // {{{ classMethodsIntoStruct() /** * Parses classes methods into struct * * @access protected * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_DocCommentMismatchException * @throws Services_Webservice_Definition_Exception */ protected function classMethodsIntoStruct() { $class = new ReflectionClass($this->_classname); $docComments = $this->_parseDocBlock($class->getDocComment()); if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('Empty or missing docblock for ' . $this->_classname . ' class'); } $this->_wsdlStruct['service']['description'] = $docComments['shortDescription']; $methods = $class->getMethods(); foreach ($methods as $method) { $methodName = $method->getName(); if ($method->isPublic() && !$method->isAbstract() && !$method->isConstructor() && !$method->isDestructor() && !in_array($methodName, $this->_hiddenMethods)) { try { $docComments = $this->_parseDocBlock($method->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $this->_classname . '::' . $methodName . '() docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('empty or missing docblock for ' . $this->_classname . '::' . $methodName . '() method'); } // Skip method? if (isset($docComments['webservice.hidden'])) { continue; } // Deprecated? if (isset($docComments['deprecated'])) { $this->_wsdlStruct[$this->_classname]['method'][$methodName]['deprecated'] = true; } // Static? if (isset($docComments['static']) || $method->isStatic()) { $this->_wsdlStruct[$this->_classname]['method'][$methodName]['static'] = true; } // Description $this->_wsdlStruct[$this->_classname]['method'][$methodName]['description'] = @$docComments['shortDescription']; // Params $param = (array) @$docComments['param']; $params = $method->getParameters(); if (count($params) != count($param)) { throw new Services_Webservice_Definition_DocCommentMismatchException( 'Docblock comment doesn\'t match ' . $this->_classname . '::' . $methodName . '() signature'); } for ($i = 0; $i < count($params); ++$i) { // Type hint if ($_class = $params[$i]->getClass()) { $_type = $_class->getName(); if ($_type != $param[$i][0]) { throw new Services_Webservice_Definition_DocCommentMismatchException('Docblock comment doesn\'t match ' . $this->_classname . '::' . $methodName . '() type hints'); } } else { $_type = $param[$i][0]; } $_cleanType = str_replace('[]', '', $_type, $_length); $_typens = str_repeat('ArrayOf', $_length); $_var =& $this->_wsdlStruct[$this->_classname]['method'][$methodName]['var'][$i]; $_var['name'] = $params[$i]->getName(); $_var['wsdltype'] = $_typens . $_cleanType; $_var['type'] = $_cleanType; $_var['length'] = $_length; $_var['array'] = ($_length > 0 && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $_var['class'] = (!in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_var['param'] = true; } // return if ($return = @$docComments['return']) { $_cleanType = str_replace('[]', '', $return[0][0], $_length); } else { $_cleanType = 'void'; $_length = 0; } $_typens = str_repeat('ArrayOf', $_length); $_var =& $this->_wsdlStruct[$this->_classname]['method'][$methodName]['var'][$i]; $_var['wsdltype'] = $_typens . $_cleanType; $_var['type'] = $_cleanType; $_var['length'] = $_length; $_var['array'] = ($_length > 0 && $_cleanType != 'void' && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $_var['class'] = ($_cleanType != 'void' && !in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_var['return'] = true; } } } /** * Parses a docblock comment * * @param string $comments * @return array * @access protected * @throws Services_Webservice_Definition_InvalidDocCommentException */ protected function _parseDocBlock($comments) { $comments = explode("\n", $comments); $info = array(); $tag = ''; $lastTag = 0; $shortDesc = array(); $longDesc = ''; $inDesc = 'short'; foreach ($comments as $line) { $line = ltrim(trim($line), "/* \t"); if ($line && $line{0} == '@') { $inDesc = false; $line = explode(' ', strtr($line, "\t", ' '), 2); $tag = substr(array_shift($line), 1); $attr = trim(@$line[0]); switch ($tag) { case 'return': case 'var': if (isset($info[$tag])) { throw new Services_Webservice_Definition_InvalidDocCommentException('Only 1 @' . $tag . ' doctag allowed in docblock'); } // No "break" here. This is intentional! case 'param': if (!$attr) { throw new Services_Webservice_Definition_InvalidDocCommentException('Incomplete @' . $tag . ' docblock tag'); } $attr = explode(' ', $attr, 2); break; } $info[$tag][] = $attr; $lastTag = count($info[$tag]) - 1; } elseif ($inDesc) { switch ($inDesc) { case 'short': if ($line == '' || $line == '.') { if ($shortDesc) { $inDesc = 'long'; } continue 2; } elseif (count($shortDesc) < 3) { $shortDesc[] = $line; if (substr($line, -1) == '.') { $inDesc = 'long'; } break; } else { $line = array_pop($shortDesc) . "\n" . $line; $line = array_pop($shortDesc) . "\n" . $line; $inDesc = 'long'; } // No "break" here. This is intentional! case 'long': $longDesc .= $line . "\n"; break; } } elseif ($line != '') { // Multiline tag $info[$tag][$lastTag] .= "\n" . $line; } } if ($shortDesc) { $info['shortDescription'] = implode("\n", $shortDesc); } if (trim($longDesc)) { $info['longDescription'] = $longDesc; } return $info; } /** * Checks if a given method is exposed for the web service * * @param string $methodName method name to check accessibility for * @param boolean &$isStatic if method is exposed and is static, this * by-reference variable will be set to TRUE. * @return boolean TRUE if exposed, FALSE otherwise * @access public * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_Exception */ public function isMethodExposed($methodName, &$isStatic = null) { if ($this->_wsdlStruct) { if (isset($this->_wsdlStruct[$this->_classname][$methodName])) { $isStatic = isset($this->_wsdlStruct[$this->_classname][$methodName]['static']); return true; } return false; } if (in_array($methodName, $this->_hiddenMethods)) { return false; } $class = new ReflectionClass($this->_classname); if (!$class->hasMethod($methodName)) { return false; } $method = $class->getMethod($methodName); if (!$method->isPublic() || $method->isAbstract() || $method->isConstructor() || $method->isDestructor()) { return false; } try { $docComments = $this->_parseDocBlock($method->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $this->_classname . '::' . $methodName . '() docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('empty or missing docblock for ' . $this->_classname . '::' . $methodName . '() method'); } // Skip method? if (isset($docComments['webservice.hidden'])) { return false; } $isStatic = $method->isStatic(); return true; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Exception.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Exception.php +++ pear/Services_Webservice/vacation/Webservice/Exception.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Exception classes for Services_Webservice package * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservices * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Exception.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR base exception class */ require_once 'PEAR/Exception.php'; /** * Base exception for Services_Webservice_Definition package */ class Services_Webservice_Exception extends PEAR_Exception { } /** * Exception class for Invalid driver */ class Services_Webservice_UnknownDriverException extends Services_Webservice_Exception { } /** * Exception class for Invalid class parameter for constructor/factory */ class Services_Webservice_NotClassException extends Services_Webservice_Exception { } /** * Exception class for call on methods that are not exposed to the web service or don't exist */ class Services_Webservice_IllegalCallException extends Services_Webservice_Exception { } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/ReST.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/ReST.php +++ pear/Services_Webservice/vacation/Webservice/ReST.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: ReST.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice/Common.php'; /** * Services_Webservice implementation for ReST backend * * The method call is done through PATH_INFO * * The PEAR::Services_Webservice class creates web services from your classes * * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ class Services_Webservice_ReST extends Services_Webservice_Common { /** * Automatically handles the incoming request * * The result depends on how the service was called * If a method name is passed as the PATH_INFO, it is used to call it. * If the method was not exposed as a web service method, a 404 HTTP * status is returned. * Otherwise, returns an HTML information page. * * @access public * @todo Add payload to method calls * @todo Fix the passing of parameters to the user's class constructor */ public function handle() { if (isset($_SERVER['PATH_INFO'])) { $method = $_SERVER['PATH_INFO']; try { $this->_handle($method); } catch (Services_Webservice_IllegalCallException $e) { header('HTTP/1.0 404 Not Found'); } } else { header('Content-Type: text/html'); echo $definition->toHTML(); } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/SOAP.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/SOAP.php +++ pear/Services_Webservice/vacation/Webservice/SOAP.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: SOAP.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice.php'; /** * Services_Webservice implementation for SOAP backend * * The PEAR::Services_Webservice class creates web services from your classes * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ class Services_Webservice_SOAP extends Services_Webservice { /** * SOAP-server options of the web service * * @var array * @access protected */ protected $soapServerOptions = array(); /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options * @access public */ public function __construct($class, $namespace, $options = null) { $this->soapServerOptions['uri'] = isset($options['uri']) ? $options['uri'] : $this->namespace; $this->soapServerOptions['encoding'] = isset($options['encoding']) ? $options['encoding'] : SOAP_ENCODED; parent::__construct($class, $namespace, $options); } // }}} // {{{ handle() /** * Automatically handles the incoming request * * The result depends on how the service was called * If the query string is "WSDL" returns the WSDL document * If the query string is "DISCO" returns the DISCO document * If the payload is not empty, SOAP call is handled by the SOAP server * Otherwise, returns an HTML information page * * @access public */ public function handle() { $action = strtoupper(@$_SERVER['QUERY_STRING']); switch ($action) { case 'WSDL': case 'DISCO': header('Content-Type: text/xml'); break; default: if (isset($_SERVER['HTTP_SOAPACTION'])) { $action = null; } else { header('Content-Type: text/html'); $action = 'HTML'; } } if ($action) { require_once 'Services/Webservice/Definition.php'; $definition = new Services_Webservice_Definition($this->_classname, $this->namespace); $definition->protocol = $this->protocol; echo $definition->{'to' . $action}(); } else { $this->createServer(); } } // }}} // {{{ createServer() /** * Creates the SOAP-server * * Creates the SOAP server using the PHP SOAP extension, * and automatically handle the call. * * @access private */ private function createServer() { $server = new SoapServer(null, $this->soapServerOptions); $params = $this->_initParams; array_unshift($this->_classname, $params); call_user_func_array(array(&$server, 'SetClass'), $params); $server->handle(); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php +++ pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: DISCO.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_DISCO /** * Format web service DISCO information * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_DISCO { /** * Namespace of the web service * * @var string * @access protected */ protected $namespace; /** * Protocol of the web service * * @var string * @access protected */ protected $protocol; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $classname; /** * SOAP schema related URIs * * @access private */ const SOAP_XML_SCHEMA_VERSION = 'http://www.w3.org/2001/XMLSchema'; const SOAP_XML_SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance'; const SCHEMA_DISCO = 'http://schemas.xmlsoap.org/disco/'; const SCHEMA_DISCO_SCL = 'http://schemas.xmlsoap.org/disco/scl/'; const SCHEMA_DISCO_SOAP = 'http://schemas.xmlsoap.org/disco/soap/'; /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->namespace = $definition->namespace; $this->protocol = $definition->protocol; $this->classname = $definition->getClassName(); $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns service DISCO information * * @access public * @return string */ public function toString() { $disco = new DOMDocument('1.0' ,'utf-8'); $disco_discovery = $disco->createElement('discovery'); $disco_discovery->setAttribute('xmlns:xsi', self::SOAP_XML_SCHEMA_INSTANCE); $disco_discovery->setAttribute('xmlns:xsd', self::SOAP_XML_SCHEMA_VERSION); $disco_discovery->setAttribute('xmlns', self::SCHEMA_DISCO); $disco_contractref = $disco->createElement('contractRef'); if ($urlService = $this->_parser->getURI('service')) { $urlBase = $urlService; } else { $urlBase = $this->protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; } if ($urlWSDL = $this->_parser->getURI('WSDL')) { $disco_contractref->setAttribute('ref', $urlWSDL); } else { $disco_contractref->setAttribute('ref', $urlBase . '?wsdl'); } if ($urlDoc = $this->_parser->getURI('doc')) { $disco_contractref->setAttribute('docRef', $urlDoc); } else { $disco_contractref->setAttribute('docRef', $urlBase); } $disco_contractref->setAttribute('xmlns', self::SCHEMA_DISCO_SCL); $disco_soap = $disco->createElement('soap'); $disco_soap->setAttribute('address', $urlBase); $disco_soap->setAttribute('xmlns:q1', $this->namespace); $disco_soap->setAttribute('binding', 'q1:' . $this->classname); $disco_soap->setAttribute('xmlns', self::SCHEMA_DISCO_SCL); $disco_contractref->appendChild($disco_soap); $disco_discovery->appendChild($disco_contractref); $disco->appendChild($disco_discovery); return $disco->saveXML(); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/Exception.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/Exception.php +++ pear/Services_Webservice/vacation/Webservice/Definition/Exception.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Exception classes for Services_Webservice_Definition package * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservices * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Exception.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR base exception class */ require_once 'PEAR/Exception.php'; /** * Base exception for Services_Webservice_Definition package */ class Services_Webservice_Definition_Exception extends PEAR_Exception { } /** * Exception calls for Invalid class parameter for constructor */ class Services_Webservice_Definition_NotClassException extends Services_Webservice_Definition_Exception { } /** * Exception class for Unknown definition format */ class Services_Webservice_Definition_UnknownFormatException extends Services_Webservice_Definition_Exception { } /** * Exception class for Missing docblock comment */ class Services_Webservice_Definition_NoDocCommentException extends Services_Webservice_Definition_Exception { } /** * Exception class for Mismatched docblock comment */ class Services_Webservice_Definition_DocCommentMismatchException extends Services_Webservice_Definition_Exception { } /** * Exception class for invalid docblock comment */ class Services_Webservice_Definition_InvalidDocCommentException extends Services_Webservice_Definition_Exception { } /** * Exception class for incomplete docblock comment */ class Services_Webservice_Definition_IncompleteDocCommentException extends Services_Webservice_Definition_Exception { } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/HTML.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/HTML.php +++ pear/Services_Webservice/vacation/Webservice/Definition/HTML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: HTML.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_HTML /** * Format web service information in HTML * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_HTML { /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns info-site in HTML format * * @access public * @return string */ public function toString() { $wsdlStruct = $this->_parser->getStruct(); $namespace = $this->_parser->namespace; $classname = $this->_parser->getClassName(); if (trim($wsdlStruct['service']['description']) == '') { $description = 'My example service description'; } else { $description = $wsdlStruct['service']['description']; } if (!($urlWSDL = $this->_parser->getURI('WSDL'))) { $urlWSDL = htmlentities($_SERVER['PHP_SELF']) . '?wsdl'; } if (!($urlDISCO = $this->_parser->getURI('DISCO'))) { $urlDISCO = htmlentities($_SERVER['PHP_SELF']) . '?DISCO'; } $css = ' body { margin: 0px; padding: 10px; font-family: sans-serif; } #header { background-color: #339900; color: #FFFFFF; padding: 5px 10px; margin: -10px; } h1 { font-size: xx-large; color: #CCFF99; } #header p { font-size: large; } dt { margin-top: 1em; font-weight: bold; } ..description { padding-left: 1.5em; margin-bottom: 1.5em; } a:link { color: #006600; } a:visited { color: #030; } a:hover { color: #003300; } li.deprecated { color: #A0A0A0; } span.deprecated { font-weight: bold; }..type { font-family: Courier New, Courier, fixed; } dd ul { margin-left: 0px; padding-left: 0px; } '; $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>' . $classname . ' Web Service</title> <meta name="generator" content="PEAR::Services_Webservice @version@" /> <style type="text/css"> ' . $css . ' </style> </head> <body> <div id="header"> <h1>' . $classname . '</h1> <p>' . htmlspecialchars($description) . '</p> </div> <p>The following operations are supported. For a formal <acronym title="Simple Object Access Protocol">SOAP</acronym> definition, please review the <a href="' . $urlWSDL . '">Service Description</a>.</p> <ul>'; foreach ($wsdlStruct[$classname]['method'] as $methodName => $method) { $paramValue = array(); foreach ($method['var'] as $methodVars) { if (isset($methodVars['param'])) { $paramValue[] = $methodVars['type'] . str_repeat('[]', $methodVars['length']); } } $returnValue = array(); foreach ($method['var'] as $methodVars) { if (isset($methodVars['return'])) { $returnValue[] = $methodVars['type'] . str_repeat('[]', $methodVars['length']); } } $html .= sprintf('<li%s><samp><var class="returnedValue">%s</var> <b class="functionName">%s</b>( <var class="parameter">%s</var> )</samp>%s%s</li>' , ((empty($method['deprecated'])) ? '' : ' class="deprecated"') , implode(',', $returnValue) , $methodName , implode('</var> , <var class="parameter">', $paramValue) , ((empty($method['deprecated'])) ? '' : ('<br /><span class="description deprecated">This operation is deprecated!</span>')) , ((empty($method['description'])) ? '' : ('<br /><span class="description">' . htmlspecialchars($method['description']) . '</span>'))); } $html .= '</ul> <p><a href="' . $urlDISCO . '">DISCO</a> makes it possible for clients to reflect against endpoints to discover services and their associated <acronym title="Web Service Description Language">WSDL</acronym> documents.</p>'; if (strncmp($namespace, 'http://example.org', 18) === 0) { $html .= ' <p class="warning"><strong>This web service is using http://example.org/ as its default namespace.<br /> Recommendation: Change the default namespace before the <acronym title="eXtensible Markup Language">XML</acronym> Web service is made public.</strong></p> <p>Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web. http://example.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.<br /> Your XML Web service should be identified by a namespace that you control. For example, you can use your company`s Internet domain name as part of the namespace. Although many XML Web service namespaces look like <acronym title="Uniform Resource Locators">URLs</acronym>, they need not point to actual resources on the Web. (XML Web service namespaces are <acronym title="Uniform Resouce Identifiers">URIs</acronym>.)</p> <p>For more details on XML namespaces, see the <acronym title="World Wide Web Consortium">W3C</acronym> recommendation on <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.<br /> For more details on <acronym title="Web Service Description Language">WSDL</acronym>, see the <a href="http://www.w3.org/TR/wsdl">WSDL Specification</a>.<br /> For more details on URIs, see <a href="http://www.ietf.org/rfc/rfc2396.txt"><acronym title="Request For Comment">RFC</acronym> 2396</a>.</p> <p><small>Powered by PEAR <a href="http://pear.php.net/">http://pear.php.net</a></small></p>'; } if ($wsdlStruct['class']) { $html .= '<h2>Complex Types Definitions</h2>'; foreach ($wsdlStruct['class'] as $class => $properties) { $html .= '<h3 class="type">' . $class . '</h3><ul class="properties">'; foreach ($properties['property'] as $propertyName => $property) { $html .= '<li' . ((empty($property['deprecated'])) ? '' : ' class="deprecated"') . '><var class="property">' . $propertyName . '</var> <span class="type">' . $property['type'] . ((!$property['array']) ? '' : str_repeat('[]', $property['length'])) . '</span>' . ((empty($property['deprecated'])) ? '' : '<br /><span class="description deprecated">This element is deprecated!</span>') . ((empty($property['description'])) ? '' : '<br /><span class="description">' . htmlspecialchars($property['description']) . '</span>') . '</li>'; } $html .= '</ul>'; } } $html .= '</body></html>'; return $html; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php +++ pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: WSDL.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_WSDL /** * Generator of WSDL document * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_WSDL { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Protocol of the web service * * @var string * @access public */ public $protocol; /** * SOAP schema related URIs * * @access private */ const SOAP_XML_SCHEMA_VERSION = 'http://www.w3.org/2001/XMLSchema'; const SOAP_XML_SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance'; const SOAP_SCHEMA_ENCODING = 'http://schemas.xmlsoap.org/soap/encoding/'; const SOAP_XML_SCHEMA_MIME = 'http://schemas.xmlsoap.org/wsdl/mime/'; const SOAP_ENVELOP = 'http://schemas.xmlsoap.org/soap/envelope/'; const SCHEMA_SOAP_HTTP = 'http://schemas.xmlsoap.org/soap/http'; const SCHEMA_SOAP = 'http://schemas.xmlsoap.org/wsdl/soap/'; const SCHEMA_WSDL = 'http://schemas.xmlsoap.org/wsdl/'; const SCHEMA_WSDL_HTTP = 'http://schemas.xmlsoap.org/wsdl/http/'; /** * Simple WSDL types * * @var array * @access private */ private $_simpleTypes = array( 'string', 'int', 'float', 'bool', 'double', 'integer', 'boolean', 'varstring', 'varint', 'varfloat', 'varbool', 'vardouble', 'varinteger', 'varboolean'); /** * Classes are parsed into this struct * * @var array * @access private */ private $_wsdlStruct; /** * WSDL DOM root node * * The WSDL DOM object * * @var object * @access private */ private $_wsdl; /** * WSDL-definitions DOM node * * @var object * @access private */ private $_wsdlDefinitions; /** * Name of the class from which to create a web service from * * @var string * @access private */ private $classname; /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->namespace = $definition->namespace; $this->protocol = $definition->protocol; $this->classname = $definition->getClassName(); $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns the WSDL document * * @access public * @return string */ public function toString() { $this->_wsdlStruct = $this->_parser->getStruct(); $this->_wsdl = new DOMDocument('1.0' ,'utf-8'); $this->createWSDLDefinitions(); $this->createWSDLTypes(); $this->createWSDLMessages(); $this->createWSDLPortType(); $this->createWSDLBinding(); $this->createWSDLService(); return $this->_wsdl->saveXML(); } // }}} // {{{ createWSDLDefinitions() /** * Creates the definition node * * @return void */ protected function createWSDLDefinitions() { /* <definitions name="myService" targetNamespace="urn:myService" xmlns:typens="urn:myService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> */ $this->_wsdlDefinitions = $this->_wsdl->createElement('definitions'); $this->_wsdlDefinitions->setAttribute('name', $this->classname); $this->_wsdlDefinitions->setAttribute('targetNamespace', 'urn:'.$this->classname); $this->_wsdlDefinitions->setAttribute('xmlns:typens', 'urn:'.$this->classname); $this->_wsdlDefinitions->setAttribute('xmlns:xsd', self::SOAP_XML_SCHEMA_VERSION); $this->_wsdlDefinitions->setAttribute('xmlns:soap', self::SCHEMA_SOAP); $this->_wsdlDefinitions->setAttribute('xmlns:soapenc', self::SOAP_SCHEMA_ENCODING); $this->_wsdlDefinitions->setAttribute('xmlns:wsdl', self::SCHEMA_WSDL); $this->_wsdlDefinitions->setAttribute('xmlns', self::SCHEMA_WSDL); //$this->_wsdlDefinitions->setAttribute('xmlns:mime', self::SOAP_XML_SCHEMA_MIME); //$this->_wsdlDefinitions->setAttribute('xmlns:tns', $this->namespace); //$this->_wsdlDefinitions->setAttribute('xmlns:http', self::SCHEMA_WSDL_HTTP); $this->_wsdl->appendChild($this->_wsdlDefinitions); } // }}} // {{{ createWSDLTypes() /** * Creates the types node * * @return void */ protected function createWSDLTypes() { /* <types> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:myService"/> </types> */ $types = $this->_wsdl->createElement('types'); $schema = $this->_wsdl->createElement('xsd:schema'); $schema->setAttribute('xmlns', self::SOAP_XML_SCHEMA_VERSION ); $schema->setAttribute('targetNamespace', 'urn:'.$this->classname); $types->appendChild($schema); // array /* <xsd:complexType name="ArrayOfclassC"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:classC[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> */ if (isset($this->_wsdlStruct['array'])) { foreach ($this->_wsdlStruct['array'] as $source => $target) { //<s:complexType name="ArrayOfArrayOfInt"> //<s:sequence> //<s:element minOccurs="0" maxOccurs="unbounded" name="ArrayOfInt" nillable="true" type="tns:ArrayOfInt"/> //</s:sequence> $complexType = $this->_wsdl->createElement('xsd:complexType'); $complexContent = $this->_wsdl->createElement('xsd:complexContent'); $restriction = $this->_wsdl->createElement('xsd:restriction'); $attribute = $this->_wsdl->createElement('xsd:attribute'); $restriction->appendChild($attribute); $complexContent->appendChild($restriction); $complexType->appendChild($complexContent); $schema->appendChild($complexType); $complexType->setAttribute('name', $source); $restriction->setAttribute('base', 'soapenc:Array'); $attribute->setAttribute('ref', 'soapenc:arrayType'); try { $class = new ReflectionClass($target); } catch (Exception $e) { } if(in_array($target, $this->_simpleTypes)){ $attribute->setAttribute('wsdl:arrayType', 'xsd:' . $target . '[]'); }elseif(isset($class)){ $attribute->setAttribute('wsdl:arrayType', 'typens:' . $target . '[]'); }else{ $attribute->setAttribute('wsdl:arrayType', 'typens:' . $target . '[]'); } unset($class); } } // class /* <xsd:complexType name="classB"> <xsd:all> <xsd:element name="classCArray" type="typens:ArrayOfclassC" /> </xsd:all> </xsd:complexType> */ if (isset($this->_wsdlStruct['class'])) { foreach ($this->_wsdlStruct['class'] as $className => $classProperty) { $complextype = $this->_wsdl->createElement('xsd:complexType'); $complextype->setAttribute('name', $className); $sequence = $this->_wsdl->createElement('xsd:all'); $complextype->appendChild($sequence); $schema->appendChild($complextype); foreach ($classProperty['property'] as $classPropertyName => $classPropertyValue) { $element = $this->_wsdl->createElement('xsd:element'); $element->setAttribute('name', $classPropertyName); $element->setAttribute('type', ((in_array($classPropertyValue['wsdltype'], $this->_simpleTypes)) ? 'xsd:' : 'typens:') . $classPropertyValue['wsdltype']); $sequence->appendChild($element); } } } $this->_wsdlDefinitions->appendChild($types); } // }}} // {{{ createWSDLMessages() /** * Creates the messages node * * @return void */ protected function createWSDLMessages() { /* <message name="hello"> <part name="i" type="xsd:int"/> <part name="j" type="xsd:string"/> </message> <message name="helloResponse"> <part name="helloResponse" type="xsd:string"/> </message> */ foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $method) { $messageInput = $this->_wsdl->createElement('message'); $messageInput->setAttribute('name', $methodName); $messageOutput = $this->_wsdl->createElement('message'); $messageOutput->setAttribute('name', $methodName . 'Response'); $this->_wsdlDefinitions->appendChild($messageInput); $this->_wsdlDefinitions->appendChild($messageOutput); foreach ($method['var'] as $methodVars) { if (isset($methodVars['param'])) { $part = $this->_wsdl->createElement('part'); $part->setAttribute('name', $methodVars['name']); $part->setAttribute('type', (($methodVars['array'] != 1 && $methodVars['class'] != 1) ? 'xsd:' : 'typens:') . $methodVars['wsdltype']); $messageInput->appendChild($part); } if (isset($methodVars['return']) && $methodVars['type'] != 'void') { $part = $this->_wsdl->createElement('part'); $part->setAttribute('name', $methodName.'Response'); //$methodVars['wsdltype']); $part->setAttribute('type', (($methodVars['array'] != 1 && $methodVars['class'] != 1) ? 'xsd:' : 'typens:') . $methodVars['wsdltype']); $messageOutput->appendChild($part); } } } } // }}} // {{{ createWSDLBinding() /** * Create the binding node * * @return void */ protected function createWSDLBinding() { /* <binding name="myServiceBinding" type="typens:myServicePort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="hello"> <soap:operation soapAction="urn:myServiceAction"/> <input> <soap:body use="encoded" namespace="urn:myService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" namespace="urn:myService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> */ $binding = $this->_wsdl->createElement('binding'); $binding->setAttribute('name', $this->classname . 'Binding'); $binding->setAttribute('type', 'typens:' . $this->classname . 'Port'); $soap_binding = $this->_wsdl->createElement('soap:binding'); $soap_binding->setAttribute('style', 'rpc'); $soap_binding->setAttribute('transport', self::SCHEMA_SOAP_HTTP); $binding->appendChild($soap_binding); foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $methodVars) { $operation = $this->_wsdl->createElement('operation'); $operation->setAttribute('name', $methodName); $binding->appendChild($operation); $soap_operation = $this->_wsdl->createElement('soap:operation'); $soap_operation->setAttribute('soapAction', 'urn:' . $this->classname.'Action'); $operation->appendChild($soap_operation); $input = $this->_wsdl->createElement('input'); $output = $this->_wsdl->createElement('output'); $operation->appendChild($input); $operation->appendChild($output); $soap_body = $this->_wsdl->createElement('soap:body'); $soap_body->setAttribute('use', 'encoded'); $soap_body->setAttribute('namespace', 'urn:' . $this->namespace); $soap_body->setAttribute('encodingStyle', self::SOAP_SCHEMA_ENCODING ); $input->appendChild($soap_body); $soap_body = $this->_wsdl->createElement('soap:body'); $soap_body->setAttribute('use', 'encoded'); $soap_body->setAttribute('namespace', 'urn:' . $this->namespace); $soap_body->setAttribute('encodingStyle', self::SOAP_SCHEMA_ENCODING ); $output->appendChild($soap_body); } $this->_wsdlDefinitions->appendChild($binding); } // }}} // {{{ createWSDLPortType() /** * Creates the portType node * * @return void */ protected function createWSDLPortType() { /* <portType name="myServicePort"> <operation name="hello"> <input message="typens:hello"/> <output message="typens:helloResponse"/> </operation> </portType> */ $portType = $this->_wsdl->createElement('portType'); $portType->setAttribute('name', $this->classname.'Port'); foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $methodVars) { $operation = $this->_wsdl->createElement('operation'); $operation->setAttribute('name', $methodName); $portType->appendChild($operation); $documentation = $this->_wsdl->createElement('documentation'); $documentation->appendChild($this->_wsdl->createTextNode($methodVars['description'])); $operation->appendChild($documentation); $input = $this->_wsdl->createElement('input'); $output = $this->_wsdl->createElement('output'); $input->setAttribute('message', 'typens:' . $methodName ); $output->setAttribute('message', 'typens:' . $methodName . 'Response'); $operation->appendChild($input); $operation->appendChild($output); } $this->_wsdlDefinitions->appendChild($portType); } // }}} // {{{ createWSDLService() /** * Creates the service node * * @return void */ protected function createWSDLService() { /* <service name="myService"> <port name="myServicePort" binding="typens:myServiceBinding"> <soap:address location="http://dschini.org/test1.php"/> </port> </service> */ $service = $this->_wsdl->createElement('service'); $service->setAttribute('name', $this->classname); $documentation = $this->_wsdl->createElement('documentation'); $documentation->appendChild($this->_wsdl->createTextNode($this->_wsdlStruct['service']['description'])); $service->appendChild($documentation); $port = $this->_wsdl->createElement('port'); $port->setAttribute('name', $this->classname . 'Port'); $port->setAttribute('binding', 'typens:' . $this->classname . 'Binding'); $address = $this->_wsdl->createElement('soap:address'); if (!($urlService = $this->_parser->getURI('service'))) { $urlService = $this->protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; } $address->setAttribute('location', $urlService); $port->appendChild($address); $service->appendChild($port); $this->_wsdlDefinitions->appendChild($service); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/tests/test_01.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/tests/test_01.php +++ pear/Services_Webservice/vacation/tests/test_01.php <?PHP include_once('Services/Webservice.php'); /** * My first service with PEAR::Services_Webservice, * it rocks! * * Long description of service */ class myService { /** * This function prints out "hello!" * We also added a DOM-node to the WSDL-file * portType-operation-documentation. * * What about multiline comments? * I am a long description of the operation * * @param int * @param string[][] * @param classB * @return classC[][][] */ public function hello($i, $j, classB $k) { } /** * This function prints out hello2 * * @param int * @param string[][] * @param classB[][][] * @param classC */ public function hello2($a, $b, $c, $d) { } /** * @deprecated * @return string */ public function failMe() { } } class classB { /** * 3D coordinates * @var int[][][] */ public $a; /** * @var classC[][][] */ public $b; } class classC { /** * Ah ha! * @var classD */ public $a; } class classD { /** * Use "c" instead * @var classE[][][][] * @deprecated */ public $a; /** * @var classE[][][][] * @webservice.hidden */ public $b; /** * @var int[][][][] */ public $c; } class classE { /** * @var int */ public $a; } $myService =& Services_Webservice::factory('SOAP', 'myService', "http://example.org", array('uri' => 'http://example.org', 'encoding' => SOAP_ENCODED)); $myService->handle(); ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/tests/test_02.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/tests/test_02.php +++ pear/Services_Webservice/vacation/tests/test_02.php <?php include_once('Services/Webservice.php'); class myService extends Services_Webservice { /** * Says "Hello!" * * @param int * @return string */ public function hello($i ) { //create some logic here return 'myString'; } } $myService = new myService( 'myService', 'example webservice description', array('uri' => 'myService', 'encoding' => SOAP_ENCODED,'soap_version' => SOAP_1_2) ); $myService->handle(); ?>
http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice.php +++ pear/Services_Webservice/vacation/Webservice.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Webservice.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR::Services_Webservice * * The PEAR::Services_Webservice class creates web services from your classes * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ abstract class Services_Webservice { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Protocol of the web service * * @var string * @access public */ public $protocol; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $_classname; /** * Class instance used by the web service * * @var object * @access protected */ protected $_classnameInstance = null; /** * Parameter for the user's web service class * * @var array * @access protected */ protected $_initParams = null; /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options * @access protected * @throws Services_Webservice_NotClassException */ protected function __construct($class, $namespace, $options = null) { if (is_object($class)) { $this->_classname = $class->get_class(); $this->_classnameInstance =& $class; } elseif (is_string($class)) { $this->_classname = $class; } else { throw new Services_Webservice_NotClassException( 'Expected a class name or instance.'); } if (trim($namespace) == '') { $namespace = 'http://example.org/'; } $this->namespace = $namespace; $this->protocol = 'http'; } /** * Returns a Services_Webservice server instance to handle incoming * requests. * * @param string $driver backend service type (for now only SOAP) * @var object|string $class * @var string $namespace * @var array $options * @access public * @throws Services_Webservice_UnknownDriverException * @throws Services_Webservice_NotClassException */ public function &factory($driver, $class, $namespace, $options = null) { $backend = 'Services_Webservice_' . $driver; include_once 'Services/Webservice/' . basename($driver) . '.php'; if (!class_exists($backend)) { require_once 'Services/Webservice/Exception.php'; throw Services_Webservice_UnknownDriverException('Unknown backend driver: ' . $driver); } $instance = new $backend($class, $namespace, $options); return $instance; } /** * Initializes web service * * The parameters passed to this method will be passed to your class * constructor * * @access public */ public function init() { $this->_initParams = func_get_args(); } /** * Automatically handles the incoming request * * The result depends on how the service was called and which backend * is used. * @access public */ abstract public function handle(); } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/package.xml?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/package.xml +++ pear/Services_Webservice/vacation/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> <name>Services_Webservice</name> <summary>Create web services and description (WSDL, DISCO, and info. page)</summary> <description> This package helps you easily create web services (SOAP). </description> <license>PHP License</license> <maintainers> <maintainer> <user>crafics</user> <name>Manfred Weber</name> <email>crafics@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>jausions</user> <name>Philippe Jausions</name> <email>Philippe.Jausions@11abacus.com</email> <role>lead</role> </maintainer> <maintainer> <user>mfonda</user> <name>Matthew Fonda</name> <email>mfonda@php.net</email> <role>developer</role> </maintainer> </maintainers> <release> <version>0.5.0</version> <state>alpha</state> <date>2005-08-12</date> <notes> Package restructuration: - New Services_Webservice_Definition helper classes, - New factory() method, - New backend driver-based service types (only SOAP for now.) BC Breaks: - Change in parameters for constructor! - $description is not public anymore, - Exceptions are thrown if docblocks are missing, invalid or incomplete for class, methods and properties declarations, - Don't extend Service_Webservice base class anymore. Support for short and long description docblock. Extended info page with complex type definitions. </notes> <filelist> <dir name="/" baseinstalldir="Services"> <file role="php">Webservice.php</file> <dir name="Webservice" role="php"> <file>Exception.php</file> <file>Definition.php</file> <file>Common.php</file> <file>ReST.php</file> <file>SOAP.php</file> <dir name="Definition" role="php"> <file>Exception.php</file> <file>DISCO.php</file> <file>HTML.php</file> <file>WSDL.php</file> </dir> </dir> </dir> <dir name="tests" role="test" baseinstalldir="Services/Webservice"> <file>test_01.php</file> </dir> </filelist> </release> <changelog> <release> <version>0.4.0</version> <state>alpha</state> <date>2005-07-24</date> <notes> - new WSDL model </notes> </release> <release> <version>0.3.1</version> <state>alpha</state> <date>2005-07-19</date> <notes> - Improved infopage (HTML) - method descriptions support (docblock parsing) </notes> </release> </changelog> <deps> <dep type="ext" rel="has">soap</dep> <dep type="php" rel="ge" version="5.1.0b2" /> </deps> </package> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Common.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Common.php +++ pear/Services_Webservice/vacation/Webservice/Common.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Common.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice.php'; /** * Services_Webservice implementation for common PHP-written backend * * The PEAR::Services_Webservice class creates web services from your classes * * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ * @todo Add input/output filters that will decode/encode the data from/to * a specified format (eventually nest filters) */ class Services_Webservice_Common extends Services_Webservice { /** * Handles the method call itself * * @param string $methodName the method to call with the payload * @access protected * @webservice.hidden * @throws Services_Webservice_IllegalCallException * @todo Add payload to method calls * @todo Fix the passing of parameters to the user's class constructor */ protected function _handle($methodName) { require_once 'Services/Webservice/Definition.php'; $definition = new Services_Webservice_Definition($this->_classname, $this->namespace); $definition->protocol = $this->protocol; if (!$definition->isMethodExposed($method, $static)) { require_once 'Services/Webservice/Exception.php'; throw new Services_Webservice_IllegalCallException('Unknown web service resource'); } if ($static) { echo call_user_func_array(array($this->_classname, $methodName)); } else { if (!is_object($this->_classnameInstance)) { if (!is_null($this->_initParams)) { $this->_classnameInstance = new $this->_classname($this->_initParams); } else { $this->_classnameInstance = new $this->_classname(); } } echo call_user_func_array(array(&$this->_classnameInstance, $methodName)); } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition.php +++ pear/Services_Webservice/vacation/Webservice/Definition.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose class as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Definition.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition /** * Include exception class declarations */ require_once 'Services/Webservice/Definition/Exception.php'; /** * Class to perform the introspection of the web service * * Uses Reflection API and parses docblock comments to do introspection * of the class's methods. * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Description of the web service * * @var string * @access protected */ protected $description; /** * Simple WSDL types * * @var array * @access protected */ protected $_simpleTypes = array( 'string', 'int', 'float', 'bool', 'double', 'integer', 'boolean', 'varstring', 'varint', 'varfloat', 'varbool', 'vardouble', 'varinteger', 'varboolean'); /** * Classes are parsed into this struct * * @var array * @access protected */ protected $_wsdlStruct; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $_classname; /** * Exclude these methods from web service * * @var array * @access protected */ protected $_hiddenMethods; /** * Some user-overwritten URIs * * @var array * @access protected */ protected $_URI = array(); /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options not currently used * @access public * @throws Services_Webservice_Definition_NotClassException */ public function __construct($class, $namespace, $options = null) { if (is_object($class)) { $this->_classname = $class->get_class(); } elseif (is_string($class)) { $this->_classname = $class; } else { throw new Services_Webservice_Definition_NotClassException( 'Expected a class name or instance.'); } if (trim($namespace) != '') { $this->namespace = $namespace; } else { $this->namespace = 'http://example.org/'; } $this->_wsdlStruct = array(); $this->_hiddenMethods = array( '__construct', '__destruct', '__call', '__get', '__set', '__sleep', '__wakeup', $this->_classname); } // }}} // {{{ intoStruct() /** * Parses classes into struct * * @access protected */ protected function intoStruct() { static $done = false; if (!$done) { $this->classMethodsIntoStruct(); $this->classStructDispatch(); $done = true; } } // }}} // {{{ getStruct() /** * Returns the structure of classes as parsed by intoStruct * * @return array * @access public */ public function getStruct() { $this->intoStruct(); return $this->_wsdlStruct; } // }}} // {{{ getClassName() /** * Returns the name of the class being defined * * @return string the nane of the class being introspected * @access public */ public function getClassName() { return $this->_classname; } // }}} // {{{ setURI() /** * Sets some URIs * * Allows to override the default value for some URI set in the definition * Currently documented URI identifier: * - WSDL : URI of the WSDL as it should be made public * - DISCO : URI of the DISCO as it should be made public * - doc : URI of the documentation page * - service: Base URI of the service * * @param string|array $name URI identifier or array of URI * @param string $URI * @access public */ public function setURI($name, $URI = null) { if (is_array($name)) { $this->_URI = array_merge($this->_URI, $name); } elseif (trim($name) && $URI) { $this->_URI[$name] = $URI; } } // }}} // {{{ getURI() /** * Returns some URIs * * @param string $name URI identifier or array of URI identifiers * @return mixed an array of found URIs if $name is an array, * a string if $name is a string, * or and NULL if $name is not found * @access public * @see setURI() */ public function getURI($name = null) { if (is_array($name)) { return array_intersect_key($this->_URI, array_flip($name)); } elseif (isset($this->_URI[$name])) { return $this->_URI[$name]; } return null; } // }}} // {{{ __call() /** * Returns web service definition in requested format * * Catch-all for toWSDL(), toHTML() and toDISCO() * * @param string $name method's name being actually called * @param array * @return string * @access public * @throws Services_Webservice_Definition_UnknownFormatException * @throws Services_Webservice_Definition_Exception */ public function __call($name, $arg) { list($format) = sscanf($name, 'to%s'); include_once 'Services/Webservice/Definition/' . basename($format) . '.php'; $class = 'Services_Webservice_Definition_' . $format; if (!class_exists($class)) { throw new Services_Webservice_Definition_UnknownFormatException( 'Unknown definition format.'); } $formatter = new $class($this); return $formatter->toString(); } // }}} // {{{ classStructDispatch() /** * Dispatches types * * @access protected * @throws Services_Webservice_Definition_Exception */ protected function classStructDispatch() { foreach ($this->_wsdlStruct[$this->_classname]['method'] as $method) { foreach ($method['var'] as $var){ if (($var['class'] == 1 && $var['length'] == 0) || ($var['class'] == 1 && $var['length'] > 0)) { $this->classPropertiesIntoStruct($var['type']); } if (($var['array'] == 1 && $var['length'] > 0) || ($var['class'] == 1 && $var['length'] > 0)) { $_typensSource = ''; for ($i = $var['length']; $i > 0; --$i) { $_typensSource .= 'ArrayOf'; $this->_wsdlStruct['array'][$_typensSource . $var['type']] = substr($_typensSource, 0, strlen($_typensSource) - 7) . $var['type']; } } } } } // }}} // {{{ classPropertiesIntoStruct() /** * Parses classes properties into struct * * @var string * @access private * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_IncompleteDocCommentException */ protected function classPropertiesIntoStruct($className) { if (!isset($this->_wsdlStruct[$className])) { $class = new ReflectionClass($className); $properties = $class->getProperties(); $this->_wsdlStruct['class'][$className]['property'] = array(); for ($i = 0; $i < count($properties); ++$i) { if ($properties[$i]->isPublic()) { $propertyName = $properties[$i]->getName(); try { $docComments = $this->_parseDocBlock($properties[$i]->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $className . '::' . $propertyName . ' property docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException( 'Empty or missing docblock comment for ' . $className . '::' . $propertyName . ' property.'); } // Skip property? if (isset($docComments['webservice.hidden'])) { continue; } $_properties =& $this->_wsdlStruct['class'][$className]['property'][$propertyName]; // Deprecated? if (isset($docComments['deprecated'])) { $_properties['deprecated'] = true; } // Description $_properties['description'] = @$docComments['shortDescription']; if (!isset($docComments['var'])) { throw new Services_Webservice_Definition_IncompleteDocCommentException('@var missing in docblock comment for ' . $className . '::' . $propertyName . ' property.'); } $var = $docComments['var']; $_cleanType = str_replace('[]', '', $var[0][0], $_length); $_typens = str_repeat('ArrayOf', $_length); $_properties['type'] = $_cleanType; $_properties['wsdltype'] = $_typens . $_cleanType; $_properties['length'] = $_length; $_properties['array'] = ($_length > 0 && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $isObject = (!in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_properties['class'] = $isObject; if ($isObject == true) { $this->classPropertiesIntoStruct($_cleanType); } if ($_length > 0) { $_typensSource = ''; for ($j = $_length; $j > 0; --$j) { $_typensSource .= 'ArrayOf'; $this->_wsdlStruct['array'][$_typensSource.$_cleanType] = substr($_typensSource, 0, strlen($_typensSource) - 7) . $_cleanType; } } } } } } // }}} // {{{ classMethodsIntoStruct() /** * Parses classes methods into struct * * @access protected * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_DocCommentMismatchException * @throws Services_Webservice_Definition_Exception */ protected function classMethodsIntoStruct() { $class = new ReflectionClass($this->_classname); $docComments = $this->_parseDocBlock($class->getDocComment()); if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('Empty or missing docblock for ' . $this->_classname . ' class'); } $this->_wsdlStruct['service']['description'] = $docComments['shortDescription']; $methods = $class->getMethods(); foreach ($methods as $method) { $methodName = $method->getName(); if ($method->isPublic() && !$method->isAbstract() && !$method->isConstructor() && !$method->isDestructor() && !in_array($methodName, $this->_hiddenMethods)) { try { $docComments = $this->_parseDocBlock($method->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $this->_classname . '::' . $methodName . '() docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('empty or missing docblock for ' . $this->_classname . '::' . $methodName . '() method'); } // Skip method? if (isset($docComments['webservice.hidden'])) { continue; } // Deprecated? if (isset($docComments['deprecated'])) { $this->_wsdlStruct[$this->_classname]['method'][$methodName]['deprecated'] = true; } // Static? if (isset($docComments['static']) || $method->isStatic()) { $this->_wsdlStruct[$this->_classname]['method'][$methodName]['static'] = true; } // Description $this->_wsdlStruct[$this->_classname]['method'][$methodName]['description'] = @$docComments['shortDescription']; // Params $param = (array) @$docComments['param']; $params = $method->getParameters(); if (count($params) != count($param)) { throw new Services_Webservice_Definition_DocCommentMismatchException( 'Docblock comment doesn\'t match ' . $this->_classname . '::' . $methodName . '() signature'); } for ($i = 0; $i < count($params); ++$i) { // Type hint if ($_class = $params[$i]->getClass()) { $_type = $_class->getName(); if ($_type != $param[$i][0]) { throw new Services_Webservice_Definition_DocCommentMismatchException('Docblock comment doesn\'t match ' . $this->_classname . '::' . $methodName . '() type hints'); } } else { $_type = $param[$i][0]; } $_cleanType = str_replace('[]', '', $_type, $_length); $_typens = str_repeat('ArrayOf', $_length); $_var =& $this->_wsdlStruct[$this->_classname]['method'][$methodName]['var'][$i]; $_var['name'] = $params[$i]->getName(); $_var['wsdltype'] = $_typens . $_cleanType; $_var['type'] = $_cleanType; $_var['length'] = $_length; $_var['array'] = ($_length > 0 && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $_var['class'] = (!in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_var['param'] = true; } // return if ($return = @$docComments['return']) { $_cleanType = str_replace('[]', '', $return[0][0], $_length); } else { $_cleanType = 'void'; $_length = 0; } $_typens = str_repeat('ArrayOf', $_length); $_var =& $this->_wsdlStruct[$this->_classname]['method'][$methodName]['var'][$i]; $_var['wsdltype'] = $_typens . $_cleanType; $_var['type'] = $_cleanType; $_var['length'] = $_length; $_var['array'] = ($_length > 0 && $_cleanType != 'void' && in_array($_cleanType, $this->_simpleTypes)) ? true : false; $_var['class'] = ($_cleanType != 'void' && !in_array($_cleanType, $this->_simpleTypes) && new ReflectionClass($_cleanType)) ? true : false; $_var['return'] = true; } } } /** * Parses a docblock comment * * @param string $comments * @return array * @access protected * @throws Services_Webservice_Definition_InvalidDocCommentException */ protected function _parseDocBlock($comments) { $comments = explode("\n", $comments); $info = array(); $tag = ''; $lastTag = 0; $shortDesc = array(); $longDesc = ''; $inDesc = 'short'; foreach ($comments as $line) { $line = ltrim(trim($line), "/* \t"); if ($line && $line{0} == '@') { $inDesc = false; $line = explode(' ', strtr($line, "\t", ' '), 2); $tag = substr(array_shift($line), 1); $attr = trim(@$line[0]); switch ($tag) { case 'return': case 'var': if (isset($info[$tag])) { throw new Services_Webservice_Definition_InvalidDocCommentException('Only 1 @' . $tag . ' doctag allowed in docblock'); } // No "break" here. This is intentional! case 'param': if (!$attr) { throw new Services_Webservice_Definition_InvalidDocCommentException('Incomplete @' . $tag . ' docblock tag'); } $attr = explode(' ', $attr, 2); break; } $info[$tag][] = $attr; $lastTag = count($info[$tag]) - 1; } elseif ($inDesc) { switch ($inDesc) { case 'short': if ($line == '' || $line == '.') { if ($shortDesc) { $inDesc = 'long'; } continue 2; } elseif (count($shortDesc) < 3) { $shortDesc[] = $line; if (substr($line, -1) == '.') { $inDesc = 'long'; } break; } else { $line = array_pop($shortDesc) . "\n" . $line; $line = array_pop($shortDesc) . "\n" . $line; $inDesc = 'long'; } // No "break" here. This is intentional! case 'long': $longDesc .= $line . "\n"; break; } } elseif ($line != '') { // Multiline tag $info[$tag][$lastTag] .= "\n" . $line; } } if ($shortDesc) { $info['shortDescription'] = implode("\n", $shortDesc); } if (trim($longDesc)) { $info['longDescription'] = $longDesc; } return $info; } /** * Checks if a given method is exposed for the web service * * @param string $methodName method name to check accessibility for * @param boolean &$isStatic if method is exposed and is static, this * by-reference variable will be set to TRUE. * @return boolean TRUE if exposed, FALSE otherwise * @access public * @throws Services_Webservice_Definition_NoDocCommentException * @throws Services_Webservice_Definition_Exception */ public function isMethodExposed($methodName, &$isStatic = null) { if ($this->_wsdlStruct) { if (isset($this->_wsdlStruct[$this->_classname][$methodName])) { $isStatic = isset($this->_wsdlStruct[$this->_classname][$methodName]['static']); return true; } return false; } if (in_array($methodName, $this->_hiddenMethods)) { return false; } $class = new ReflectionClass($this->_classname); if (!$class->hasMethod($methodName)) { return false; } $method = $class->getMethod($methodName); if (!$method->isPublic() || $method->isAbstract() || $method->isConstructor() || $method->isDestructor()) { return false; } try { $docComments = $this->_parseDocBlock($method->getDocComment()); } catch (Services_Webservice_Definition_Exception $e) { throw new Services_Webservice_Definition_Exception('Error in ' . $this->_classname . '::' . $methodName . '() docblock', $e); } if (!$docComments) { throw new Services_Webservice_Definition_NoDocCommentException('empty or missing docblock for ' . $this->_classname . '::' . $methodName . '() method'); } // Skip method? if (isset($docComments['webservice.hidden'])) { return false; } $isStatic = $method->isStatic(); return true; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Exception.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Exception.php +++ pear/Services_Webservice/vacation/Webservice/Exception.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Exception classes for Services_Webservice package * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservices * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Exception.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR base exception class */ require_once 'PEAR/Exception.php'; /** * Base exception for Services_Webservice_Definition package */ class Services_Webservice_Exception extends PEAR_Exception { } /** * Exception class for Invalid driver */ class Services_Webservice_UnknownDriverException extends Services_Webservice_Exception { } /** * Exception class for Invalid class parameter for constructor/factory */ class Services_Webservice_NotClassException extends Services_Webservice_Exception { } /** * Exception class for call on methods that are not exposed to the web service or don't exist */ class Services_Webservice_IllegalCallException extends Services_Webservice_Exception { } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/ReST.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/ReST.php +++ pear/Services_Webservice/vacation/Webservice/ReST.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: ReST.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice/Common.php'; /** * Services_Webservice implementation for ReST backend * * The method call is done through PATH_INFO * * The PEAR::Services_Webservice class creates web services from your classes * * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ class Services_Webservice_ReST extends Services_Webservice_Common { /** * Automatically handles the incoming request * * The result depends on how the service was called * If a method name is passed as the PATH_INFO, it is used to call it. * If the method was not exposed as a web service method, a 404 HTTP * status is returned. * Otherwise, returns an HTML information page. * * @access public * @todo Add payload to method calls * @todo Fix the passing of parameters to the user's class constructor */ public function handle() { if (isset($_SERVER['PATH_INFO'])) { $method = $_SERVER['PATH_INFO']; try { $this->_handle($method); } catch (Services_Webservice_IllegalCallException $e) { header('HTTP/1.0 404 Not Found'); } } else { header('Content-Type: text/html'); echo $definition->toHTML(); } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/SOAP.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/SOAP.php +++ pear/Services_Webservice/vacation/Webservice/SOAP.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Easy Web Service creation * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: SOAP.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * Include parent class */ require_once 'Services/Webservice.php'; /** * Services_Webservice implementation for SOAP backend * * The PEAR::Services_Webservice class creates web services from your classes * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version @version@ */ class Services_Webservice_SOAP extends Services_Webservice { /** * SOAP-server options of the web service * * @var array * @access protected */ protected $soapServerOptions = array(); /** * Constructor * * @var object|string $class * @var string $namespace * @var array $options * @access public */ public function __construct($class, $namespace, $options = null) { $this->soapServerOptions['uri'] = isset($options['uri']) ? $options['uri'] : $this->namespace; $this->soapServerOptions['encoding'] = isset($options['encoding']) ? $options['encoding'] : SOAP_ENCODED; parent::__construct($class, $namespace, $options); } // }}} // {{{ handle() /** * Automatically handles the incoming request * * The result depends on how the service was called * If the query string is "WSDL" returns the WSDL document * If the query string is "DISCO" returns the DISCO document * If the payload is not empty, SOAP call is handled by the SOAP server * Otherwise, returns an HTML information page * * @access public */ public function handle() { $action = strtoupper(@$_SERVER['QUERY_STRING']); switch ($action) { case 'WSDL': case 'DISCO': header('Content-Type: text/xml'); break; default: if (isset($_SERVER['HTTP_SOAPACTION'])) { $action = null; } else { header('Content-Type: text/html'); $action = 'HTML'; } } if ($action) { require_once 'Services/Webservice/Definition.php'; $definition = new Services_Webservice_Definition($this->_classname, $this->namespace); $definition->protocol = $this->protocol; echo $definition->{'to' . $action}(); } else { $this->createServer(); } } // }}} // {{{ createServer() /** * Creates the SOAP-server * * Creates the SOAP server using the PHP SOAP extension, * and automatically handle the call. * * @access private */ private function createServer() { $server = new SoapServer(null, $this->soapServerOptions); $params = $this->_initParams; array_unshift($this->_classname, $params); call_user_func_array(array(&$server, 'SetClass'), $params); $server->handle(); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php +++ pear/Services_Webservice/vacation/Webservice/Definition/DISCO.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: DISCO.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_DISCO /** * Format web service DISCO information * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_DISCO { /** * Namespace of the web service * * @var string * @access protected */ protected $namespace; /** * Protocol of the web service * * @var string * @access protected */ protected $protocol; /** * Name of the class from which to create a web service from * * @var string * @access protected */ protected $classname; /** * SOAP schema related URIs * * @access private */ const SOAP_XML_SCHEMA_VERSION = 'http://www.w3.org/2001/XMLSchema'; const SOAP_XML_SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance'; const SCHEMA_DISCO = 'http://schemas.xmlsoap.org/disco/'; const SCHEMA_DISCO_SCL = 'http://schemas.xmlsoap.org/disco/scl/'; const SCHEMA_DISCO_SOAP = 'http://schemas.xmlsoap.org/disco/soap/'; /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->namespace = $definition->namespace; $this->protocol = $definition->protocol; $this->classname = $definition->getClassName(); $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns service DISCO information * * @access public * @return string */ public function toString() { $disco = new DOMDocument('1.0' ,'utf-8'); $disco_discovery = $disco->createElement('discovery'); $disco_discovery->setAttribute('xmlns:xsi', self::SOAP_XML_SCHEMA_INSTANCE); $disco_discovery->setAttribute('xmlns:xsd', self::SOAP_XML_SCHEMA_VERSION); $disco_discovery->setAttribute('xmlns', self::SCHEMA_DISCO); $disco_contractref = $disco->createElement('contractRef'); if ($urlService = $this->_parser->getURI('service')) { $urlBase = $urlService; } else { $urlBase = $this->protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; } if ($urlWSDL = $this->_parser->getURI('WSDL')) { $disco_contractref->setAttribute('ref', $urlWSDL); } else { $disco_contractref->setAttribute('ref', $urlBase . '?wsdl'); } if ($urlDoc = $this->_parser->getURI('doc')) { $disco_contractref->setAttribute('docRef', $urlDoc); } else { $disco_contractref->setAttribute('docRef', $urlBase); } $disco_contractref->setAttribute('xmlns', self::SCHEMA_DISCO_SCL); $disco_soap = $disco->createElement('soap'); $disco_soap->setAttribute('address', $urlBase); $disco_soap->setAttribute('xmlns:q1', $this->namespace); $disco_soap->setAttribute('binding', 'q1:' . $this->classname); $disco_soap->setAttribute('xmlns', self::SCHEMA_DISCO_SCL); $disco_contractref->appendChild($disco_soap); $disco_discovery->appendChild($disco_contractref); $disco->appendChild($disco_discovery); return $disco->saveXML(); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/Exception.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/Exception.php +++ pear/Services_Webservice/vacation/Webservice/Definition/Exception.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Exception classes for Services_Webservice_Definition package * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservices * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Exception.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ /** * PEAR base exception class */ require_once 'PEAR/Exception.php'; /** * Base exception for Services_Webservice_Definition package */ class Services_Webservice_Definition_Exception extends PEAR_Exception { } /** * Exception calls for Invalid class parameter for constructor */ class Services_Webservice_Definition_NotClassException extends Services_Webservice_Definition_Exception { } /** * Exception class for Unknown definition format */ class Services_Webservice_Definition_UnknownFormatException extends Services_Webservice_Definition_Exception { } /** * Exception class for Missing docblock comment */ class Services_Webservice_Definition_NoDocCommentException extends Services_Webservice_Definition_Exception { } /** * Exception class for Mismatched docblock comment */ class Services_Webservice_Definition_DocCommentMismatchException extends Services_Webservice_Definition_Exception { } /** * Exception class for invalid docblock comment */ class Services_Webservice_Definition_InvalidDocCommentException extends Services_Webservice_Definition_Exception { } /** * Exception class for incomplete docblock comment */ class Services_Webservice_Definition_IncompleteDocCommentException extends Services_Webservice_Definition_Exception { } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/HTML.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/HTML.php +++ pear/Services_Webservice/vacation/Webservice/Definition/HTML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: HTML.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_HTML /** * Format web service information in HTML * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_HTML { /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns info-site in HTML format * * @access public * @return string */ public function toString() { $wsdlStruct = $this->_parser->getStruct(); $namespace = $this->_parser->namespace; $classname = $this->_parser->getClassName(); if (trim($wsdlStruct['service']['description']) == '') { $description = 'My example service description'; } else { $description = $wsdlStruct['service']['description']; } if (!($urlWSDL = $this->_parser->getURI('WSDL'))) { $urlWSDL = htmlentities($_SERVER['PHP_SELF']) . '?wsdl'; } if (!($urlDISCO = $this->_parser->getURI('DISCO'))) { $urlDISCO = htmlentities($_SERVER['PHP_SELF']) . '?DISCO'; } $css = ' body { margin: 0px; padding: 10px; font-family: sans-serif; } #header { background-color: #339900; color: #FFFFFF; padding: 5px 10px; margin: -10px; } h1 { font-size: xx-large; color: #CCFF99; } #header p { font-size: large; } dt { margin-top: 1em; font-weight: bold; } ..description { padding-left: 1.5em; margin-bottom: 1.5em; } a:link { color: #006600; } a:visited { color: #030; } a:hover { color: #003300; } li.deprecated { color: #A0A0A0; } span.deprecated { font-weight: bold; }..type { font-family: Courier New, Courier, fixed; } dd ul { margin-left: 0px; padding-left: 0px; } '; $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>' . $classname . ' Web Service</title> <meta name="generator" content="PEAR::Services_Webservice @version@" /> <style type="text/css"> ' . $css . ' </style> </head> <body> <div id="header"> <h1>' . $classname . '</h1> <p>' . htmlspecialchars($description) . '</p> </div> <p>The following operations are supported. For a formal <acronym title="Simple Object Access Protocol">SOAP</acronym> definition, please review the <a href="' . $urlWSDL . '">Service Description</a>.</p> <ul>'; foreach ($wsdlStruct[$classname]['method'] as $methodName => $method) { $paramValue = array(); foreach ($method['var'] as $methodVars) { if (isset($methodVars['param'])) { $paramValue[] = $methodVars['type'] . str_repeat('[]', $methodVars['length']); } } $returnValue = array(); foreach ($method['var'] as $methodVars) { if (isset($methodVars['return'])) { $returnValue[] = $methodVars['type'] . str_repeat('[]', $methodVars['length']); } } $html .= sprintf('<li%s><samp><var class="returnedValue">%s</var> <b class="functionName">%s</b>( <var class="parameter">%s</var> )</samp>%s%s</li>' , ((empty($method['deprecated'])) ? '' : ' class="deprecated"') , implode(',', $returnValue) , $methodName , implode('</var> , <var class="parameter">', $paramValue) , ((empty($method['deprecated'])) ? '' : ('<br /><span class="description deprecated">This operation is deprecated!</span>')) , ((empty($method['description'])) ? '' : ('<br /><span class="description">' . htmlspecialchars($method['description']) . '</span>'))); } $html .= '</ul> <p><a href="' . $urlDISCO . '">DISCO</a> makes it possible for clients to reflect against endpoints to discover services and their associated <acronym title="Web Service Description Language">WSDL</acronym> documents.</p>'; if (strncmp($namespace, 'http://example.org', 18) === 0) { $html .= ' <p class="warning"><strong>This web service is using http://example.org/ as its default namespace.<br /> Recommendation: Change the default namespace before the <acronym title="eXtensible Markup Language">XML</acronym> Web service is made public.</strong></p> <p>Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web. http://example.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.<br /> Your XML Web service should be identified by a namespace that you control. For example, you can use your company`s Internet domain name as part of the namespace. Although many XML Web service namespaces look like <acronym title="Uniform Resource Locators">URLs</acronym>, they need not point to actual resources on the Web. (XML Web service namespaces are <acronym title="Uniform Resouce Identifiers">URIs</acronym>.)</p> <p>For more details on XML namespaces, see the <acronym title="World Wide Web Consortium">W3C</acronym> recommendation on <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.<br /> For more details on <acronym title="Web Service Description Language">WSDL</acronym>, see the <a href="http://www.w3.org/TR/wsdl">WSDL Specification</a>.<br /> For more details on URIs, see <a href="http://www.ietf.org/rfc/rfc2396.txt"><acronym title="Request For Comment">RFC</acronym> 2396</a>.</p> <p><small>Powered by PEAR <a href="http://pear.php.net/">http://pear.php.net</a></small></p>'; } if ($wsdlStruct['class']) { $html .= '<h2>Complex Types Definitions</h2>'; foreach ($wsdlStruct['class'] as $class => $properties) { $html .= '<h3 class="type">' . $class . '</h3><ul class="properties">'; foreach ($properties['property'] as $propertyName => $property) { $html .= '<li' . ((empty($property['deprecated'])) ? '' : ' class="deprecated"') . '><var class="property">' . $propertyName . '</var> <span class="type">' . $property['type'] . ((!$property['array']) ? '' : str_repeat('[]', $property['length'])) . '</span>' . ((empty($property['deprecated'])) ? '' : '<br /><span class="description deprecated">This element is deprecated!</span>') . ((empty($property['description'])) ? '' : '<br /><span class="description">' . htmlspecialchars($property['description']) . '</span>') . '</li>'; } $html .= '</ul>'; } } $html .= '</body></html>'; return $html; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php +++ pear/Services_Webservice/vacation/Webservice/Definition/WSDL.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ /** * Class introspection to expose as web service * * PHP 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Webservice * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: WSDL.php,v 1.1 2006/12/28 10:19:14 crafics Exp $ * @link http://pear.php.net/package/Services_Webservice */ // {{{ class Services_Webservice_Definition_WSDL /** * Generator of WSDL document * * @author Manfred Weber <weber@mayflower.de> * @author Philippe Jausions <Philippe.Jausions@11abacus.com> * @package Services_Webservices * @version */ class Services_Webservice_Definition_WSDL { /** * Namespace of the web service * * @var string * @access public */ public $namespace; /** * Protocol of the web service * * @var string * @access public */ public $protocol; /** * SOAP schema related URIs * * @access private */ const SOAP_XML_SCHEMA_VERSION = 'http://www.w3.org/2001/XMLSchema'; const SOAP_XML_SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance'; const SOAP_SCHEMA_ENCODING = 'http://schemas.xmlsoap.org/soap/encoding/'; const SOAP_XML_SCHEMA_MIME = 'http://schemas.xmlsoap.org/wsdl/mime/'; const SOAP_ENVELOP = 'http://schemas.xmlsoap.org/soap/envelope/'; const SCHEMA_SOAP_HTTP = 'http://schemas.xmlsoap.org/soap/http'; const SCHEMA_SOAP = 'http://schemas.xmlsoap.org/wsdl/soap/'; const SCHEMA_WSDL = 'http://schemas.xmlsoap.org/wsdl/'; const SCHEMA_WSDL_HTTP = 'http://schemas.xmlsoap.org/wsdl/http/'; /** * Simple WSDL types * * @var array * @access private */ private $_simpleTypes = array( 'string', 'int', 'float', 'bool', 'double', 'integer', 'boolean', 'varstring', 'varint', 'varfloat', 'varbool', 'vardouble', 'varinteger', 'varboolean'); /** * Classes are parsed into this struct * * @var array * @access private */ private $_wsdlStruct; /** * WSDL DOM root node * * The WSDL DOM object * * @var object * @access private */ private $_wsdl; /** * WSDL-definitions DOM node * * @var object * @access private */ private $_wsdlDefinitions; /** * Name of the class from which to create a web service from * * @var string * @access private */ private $classname; /** * Class analyzer (introspection) * * @var object Instance of Service_Webservice_Definition * @access private */ private $_parser; /** * Constructor * * @var object $definition * @access public */ public function __construct(Services_Webservice_Definition &$definition) { $this->namespace = $definition->namespace; $this->protocol = $definition->protocol; $this->classname = $definition->getClassName(); $this->_parser =& $definition; } // }}} // {{{ toString() /** * Returns the WSDL document * * @access public * @return string */ public function toString() { $this->_wsdlStruct = $this->_parser->getStruct(); $this->_wsdl = new DOMDocument('1.0' ,'utf-8'); $this->createWSDLDefinitions(); $this->createWSDLTypes(); $this->createWSDLMessages(); $this->createWSDLPortType(); $this->createWSDLBinding(); $this->createWSDLService(); return $this->_wsdl->saveXML(); } // }}} // {{{ createWSDLDefinitions() /** * Creates the definition node * * @return void */ protected function createWSDLDefinitions() { /* <definitions name="myService" targetNamespace="urn:myService" xmlns:typens="urn:myService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> */ $this->_wsdlDefinitions = $this->_wsdl->createElement('definitions'); $this->_wsdlDefinitions->setAttribute('name', $this->classname); $this->_wsdlDefinitions->setAttribute('targetNamespace', 'urn:'.$this->classname); $this->_wsdlDefinitions->setAttribute('xmlns:typens', 'urn:'.$this->classname); $this->_wsdlDefinitions->setAttribute('xmlns:xsd', self::SOAP_XML_SCHEMA_VERSION); $this->_wsdlDefinitions->setAttribute('xmlns:soap', self::SCHEMA_SOAP); $this->_wsdlDefinitions->setAttribute('xmlns:soapenc', self::SOAP_SCHEMA_ENCODING); $this->_wsdlDefinitions->setAttribute('xmlns:wsdl', self::SCHEMA_WSDL); $this->_wsdlDefinitions->setAttribute('xmlns', self::SCHEMA_WSDL); //$this->_wsdlDefinitions->setAttribute('xmlns:mime', self::SOAP_XML_SCHEMA_MIME); //$this->_wsdlDefinitions->setAttribute('xmlns:tns', $this->namespace); //$this->_wsdlDefinitions->setAttribute('xmlns:http', self::SCHEMA_WSDL_HTTP); $this->_wsdl->appendChild($this->_wsdlDefinitions); } // }}} // {{{ createWSDLTypes() /** * Creates the types node * * @return void */ protected function createWSDLTypes() { /* <types> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:myService"/> </types> */ $types = $this->_wsdl->createElement('types'); $schema = $this->_wsdl->createElement('xsd:schema'); $schema->setAttribute('xmlns', self::SOAP_XML_SCHEMA_VERSION ); $schema->setAttribute('targetNamespace', 'urn:'.$this->classname); $types->appendChild($schema); // array /* <xsd:complexType name="ArrayOfclassC"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:classC[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> */ if (isset($this->_wsdlStruct['array'])) { foreach ($this->_wsdlStruct['array'] as $source => $target) { //<s:complexType name="ArrayOfArrayOfInt"> //<s:sequence> //<s:element minOccurs="0" maxOccurs="unbounded" name="ArrayOfInt" nillable="true" type="tns:ArrayOfInt"/> //</s:sequence> $complexType = $this->_wsdl->createElement('xsd:complexType'); $complexContent = $this->_wsdl->createElement('xsd:complexContent'); $restriction = $this->_wsdl->createElement('xsd:restriction'); $attribute = $this->_wsdl->createElement('xsd:attribute'); $restriction->appendChild($attribute); $complexContent->appendChild($restriction); $complexType->appendChild($complexContent); $schema->appendChild($complexType); $complexType->setAttribute('name', $source); $restriction->setAttribute('base', 'soapenc:Array'); $attribute->setAttribute('ref', 'soapenc:arrayType'); try { $class = new ReflectionClass($target); } catch (Exception $e) { } if(in_array($target, $this->_simpleTypes)){ $attribute->setAttribute('wsdl:arrayType', 'xsd:' . $target . '[]'); }elseif(isset($class)){ $attribute->setAttribute('wsdl:arrayType', 'typens:' . $target . '[]'); }else{ $attribute->setAttribute('wsdl:arrayType', 'typens:' . $target . '[]'); } unset($class); } } // class /* <xsd:complexType name="classB"> <xsd:all> <xsd:element name="classCArray" type="typens:ArrayOfclassC" /> </xsd:all> </xsd:complexType> */ if (isset($this->_wsdlStruct['class'])) { foreach ($this->_wsdlStruct['class'] as $className => $classProperty) { $complextype = $this->_wsdl->createElement('xsd:complexType'); $complextype->setAttribute('name', $className); $sequence = $this->_wsdl->createElement('xsd:all'); $complextype->appendChild($sequence); $schema->appendChild($complextype); foreach ($classProperty['property'] as $classPropertyName => $classPropertyValue) { $element = $this->_wsdl->createElement('xsd:element'); $element->setAttribute('name', $classPropertyName); $element->setAttribute('type', ((in_array($classPropertyValue['wsdltype'], $this->_simpleTypes)) ? 'xsd:' : 'typens:') . $classPropertyValue['wsdltype']); $sequence->appendChild($element); } } } $this->_wsdlDefinitions->appendChild($types); } // }}} // {{{ createWSDLMessages() /** * Creates the messages node * * @return void */ protected function createWSDLMessages() { /* <message name="hello"> <part name="i" type="xsd:int"/> <part name="j" type="xsd:string"/> </message> <message name="helloResponse"> <part name="helloResponse" type="xsd:string"/> </message> */ foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $method) { $messageInput = $this->_wsdl->createElement('message'); $messageInput->setAttribute('name', $methodName); $messageOutput = $this->_wsdl->createElement('message'); $messageOutput->setAttribute('name', $methodName . 'Response'); $this->_wsdlDefinitions->appendChild($messageInput); $this->_wsdlDefinitions->appendChild($messageOutput); foreach ($method['var'] as $methodVars) { if (isset($methodVars['param'])) { $part = $this->_wsdl->createElement('part'); $part->setAttribute('name', $methodVars['name']); $part->setAttribute('type', (($methodVars['array'] != 1 && $methodVars['class'] != 1) ? 'xsd:' : 'typens:') . $methodVars['wsdltype']); $messageInput->appendChild($part); } if (isset($methodVars['return']) && $methodVars['type'] != 'void') { $part = $this->_wsdl->createElement('part'); $part->setAttribute('name', $methodName.'Response'); //$methodVars['wsdltype']); $part->setAttribute('type', (($methodVars['array'] != 1 && $methodVars['class'] != 1) ? 'xsd:' : 'typens:') . $methodVars['wsdltype']); $messageOutput->appendChild($part); } } } } // }}} // {{{ createWSDLBinding() /** * Create the binding node * * @return void */ protected function createWSDLBinding() { /* <binding name="myServiceBinding" type="typens:myServicePort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="hello"> <soap:operation soapAction="urn:myServiceAction"/> <input> <soap:body use="encoded" namespace="urn:myService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" namespace="urn:myService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> */ $binding = $this->_wsdl->createElement('binding'); $binding->setAttribute('name', $this->classname . 'Binding'); $binding->setAttribute('type', 'typens:' . $this->classname . 'Port'); $soap_binding = $this->_wsdl->createElement('soap:binding'); $soap_binding->setAttribute('style', 'rpc'); $soap_binding->setAttribute('transport', self::SCHEMA_SOAP_HTTP); $binding->appendChild($soap_binding); foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $methodVars) { $operation = $this->_wsdl->createElement('operation'); $operation->setAttribute('name', $methodName); $binding->appendChild($operation); $soap_operation = $this->_wsdl->createElement('soap:operation'); $soap_operation->setAttribute('soapAction', 'urn:' . $this->classname.'Action'); $operation->appendChild($soap_operation); $input = $this->_wsdl->createElement('input'); $output = $this->_wsdl->createElement('output'); $operation->appendChild($input); $operation->appendChild($output); $soap_body = $this->_wsdl->createElement('soap:body'); $soap_body->setAttribute('use', 'encoded'); $soap_body->setAttribute('namespace', 'urn:' . $this->namespace); $soap_body->setAttribute('encodingStyle', self::SOAP_SCHEMA_ENCODING ); $input->appendChild($soap_body); $soap_body = $this->_wsdl->createElement('soap:body'); $soap_body->setAttribute('use', 'encoded'); $soap_body->setAttribute('namespace', 'urn:' . $this->namespace); $soap_body->setAttribute('encodingStyle', self::SOAP_SCHEMA_ENCODING ); $output->appendChild($soap_body); } $this->_wsdlDefinitions->appendChild($binding); } // }}} // {{{ createWSDLPortType() /** * Creates the portType node * * @return void */ protected function createWSDLPortType() { /* <portType name="myServicePort"> <operation name="hello"> <input message="typens:hello"/> <output message="typens:helloResponse"/> </operation> </portType> */ $portType = $this->_wsdl->createElement('portType'); $portType->setAttribute('name', $this->classname.'Port'); foreach ($this->_wsdlStruct[$this->classname]['method'] as $methodName => $methodVars) { $operation = $this->_wsdl->createElement('operation'); $operation->setAttribute('name', $methodName); $portType->appendChild($operation); $documentation = $this->_wsdl->createElement('documentation'); $documentation->appendChild($this->_wsdl->createTextNode($methodVars['description'])); $operation->appendChild($documentation); $input = $this->_wsdl->createElement('input'); $output = $this->_wsdl->createElement('output'); $input->setAttribute('message', 'typens:' . $methodName ); $output->setAttribute('message', 'typens:' . $methodName . 'Response'); $operation->appendChild($input); $operation->appendChild($output); } $this->_wsdlDefinitions->appendChild($portType); } // }}} // {{{ createWSDLService() /** * Creates the service node * * @return void */ protected function createWSDLService() { /* <service name="myService"> <port name="myServicePort" binding="typens:myServiceBinding"> <soap:address location="http://dschini.org/test1.php"/> </port> </service> */ $service = $this->_wsdl->createElement('service'); $service->setAttribute('name', $this->classname); $documentation = $this->_wsdl->createElement('documentation'); $documentation->appendChild($this->_wsdl->createTextNode($this->_wsdlStruct['service']['description'])); $service->appendChild($documentation); $port = $this->_wsdl->createElement('port'); $port->setAttribute('name', $this->classname . 'Port'); $port->setAttribute('binding', 'typens:' . $this->classname . 'Binding'); $address = $this->_wsdl->createElement('soap:address'); if (!($urlService = $this->_parser->getURI('service'))) { $urlService = $this->protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; } $address->setAttribute('location', $urlService); $port->appendChild($address); $service->appendChild($port); $this->_wsdlDefinitions->appendChild($service); } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/tests/test_01.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/tests/test_01.php +++ pear/Services_Webservice/vacation/tests/test_01.php <?PHP include_once('Services/Webservice.php'); /** * My first service with PEAR::Services_Webservice, * it rocks! * * Long description of service */ class myService { /** * This function prints out "hello!" * We also added a DOM-node to the WSDL-file * portType-operation-documentation. * * What about multiline comments? * I am a long description of the operation * * @param int * @param string[][] * @param classB * @return classC[][][] */ public function hello($i, $j, classB $k) { } /** * This function prints out hello2 * * @param int * @param string[][] * @param classB[][][] * @param classC */ public function hello2($a, $b, $c, $d) { } /** * @deprecated * @return string */ public function failMe() { } } class classB { /** * 3D coordinates * @var int[][][] */ public $a; /** * @var classC[][][] */ public $b; } class classC { /** * Ah ha! * @var classD */ public $a; } class classD { /** * Use "c" instead * @var classE[][][][] * @deprecated */ public $a; /** * @var classE[][][][] * @webservice.hidden */ public $b; /** * @var int[][][][] */ public $c; } class classE { /** * @var int */ public $a; } $myService =& Services_Webservice::factory('SOAP', 'myService', "http://example.org", array('uri' => 'http://example.org', 'encoding' => SOAP_ENCODED)); $myService->handle(); ?> http://cvs.php.net/viewvc.cgi/pear/Services_Webservice/vacation/tests/test_02.php?view=markup&rev=1.1 Index: pear/Services_Webservice/vacation/tests/test_02.php +++ pear/Services_Webservice/vacation/tests/test_02.php <?php include_once('Services/Webservice.php'); class myService extends Services_Webservice { /** * Says "Hello!" * * @param int * @return string */ public function hello($i ) { //create some logic here return 'myString'; } } $myService = new myService( 'myService', 'example webservice description', array('uri' => 'myService', 'encoding' => SOAP_ENCODED,'soap_version' => SOAP_1_2) ); $myService->handle(); ?>