/** * Set the Class the SOAP server will use * * @param string $class Class Name * @param string $namespace Class Namspace - Not Used * @param array $argv Arguments to instantiate the class - Not Used */ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); $port = $wsdl->addPortType($class . 'Port'); $binding = $wsdl->addBinding($class . 'Binding', 'tns:' . $class . 'Port'); $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; }
/** * Register a class with the server * * @param string $class * @param string $namespace Ignored * @param mixed $argv Ignored * @return Zend\Json\Server */ public function setClass($class, $namespace = '', $argv = null) { $argv = null; if (3 < func_num_args()) { $argv = func_get_args(); $argv = array_slice($argv, 3); } $reflection = Reflection::reflectClass($class, $argv, $namespace); foreach ($reflection->getMethods() as $method) { $definition = $this->_buildSignature($method, $class); $this->_addMethodServiceMap($definition); } return $this; }
public function testReflectClassThrowsExceptionOnInvalidParameter() { $this->setExpectedException('Zend\\Server\\Reflection\\Exception\\InvalidArgumentException', 'Invalid class or object passed to attachClass'); $reflection = Reflection\Reflection::reflectClass(false); }
/** * Attach class methods as XMLRPC method handlers * * $class may be either a class name or an object. Reflection is done on the * class or object to determine the available public methods, and each is * attached to the server as an available method; if a $namespace has been * provided, that namespace is used to prefix the XMLRPC method names. * * Any additional arguments beyond $namespace will be passed to a method at * invocation. * * @param string|object $class * @param string $namespace Optional * @param mixed $argv Optional arguments to pass to methods * @return void * @throws Zend\XmlRpc\Server\Exception on invalid input */ public function setClass($class, $namespace = '', $argv = null) { if (is_string($class) && !class_exists($class)) { throw new Server\Exception\InvalidArgumentException('Invalid method class', 610); } $argv = null; if (2 < func_num_args()) { $argv = func_get_args(); $argv = array_slice($argv, 2); } $dispatchable = Reflection\Reflection::reflectClass($class, $argv, $namespace); foreach ($dispatchable->getMethods() as $reflection) { $this->_buildSignature($reflection, $class); } }
/** * Create XML definition on an AMF service class * * @param string $serviceClass Service class name * @param array $options invocation options * @return string XML with service class introspection */ public function introspect($serviceClass, $options = array()) { $this->_options = $options; if (strpbrk($serviceClass, '\\/<>')) { return $this->_returnError('Invalid service name'); } // Transform com.foo.Bar into com\foo\Bar $serviceClass = str_replace('.', '\\', $serviceClass); // Introspect! if (!class_exists($serviceClass)) { if (!$this->_loadClass($serviceClass)) { return $this->_returnError('Invalid service name; class does not exist'); } } $serv = $this->_xml->createElement('service-description'); $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008'); $this->_types = $this->_xml->createElement('types'); $this->_ops = $this->_xml->createElement('operations'); $r = \Zend\Server\Reflection\Reflection::reflectClass($serviceClass); $this->_addService($r, $this->_ops); $serv->appendChild($this->_types); $serv->appendChild($this->_ops); $this->_xml->appendChild($serv); return $this->_xml->saveXML(); }
/** * Attach a class or object to the server * * Class may be either a class name or an instantiated object. Reflection * is done on the class or object to determine the available public * methods, and each is attached to the server as and available method. If * a $namespace has been provided, that namespace is used to prefix * AMF service call. * * @param string|object $class * @param string $namespace Optional * @param mixed $arg Optional arguments to pass to a method * @return Zend\Amf\Server * @throws Zend\Amf\Server\Exception on invalid input */ public function setClass($class, $namespace = '', $argv = null) { if (is_string($class) && !class_exists($class)){ throw new Exception\InvalidArgumentException('Invalid method or class'); } elseif (!is_string($class) && !is_object($class)) { throw new Exception\InvalidArgumentException('Invalid method or class; must be a classname or object'); } $argv = null; if (2 < func_num_args()) { $argv = array_slice(func_get_args(), 2); } // Use the class name as the name space by default. if ($namespace == '') { $namespace = is_object($class) ? get_class($class) : $class; } $this->_classAllowed[is_object($class) ? get_class($class) : $class] = true; $this->_methods[] = Reflection\Reflection::reflectClass($class, $argv, $namespace); $this->_buildDispatchTable(); return $this; }
/** * reflectClass() test; test namespaces */ public function testReflectClass2() { $reflection = Reflection\Reflection::reflectClass('ZendTest\\Server\\ReflectionTestClass', false, 'zsr'); $this->assertEquals('zsr', $reflection->getNamespace()); }