*/
class WsdlGeneratingSoapServer extends SoapServer {
/**
* The class that can be used to handle the request.
* @var String
*/
protected $sClass;
/**
* The functions that can be used to handle the request.
*/
protected $aFunctions = array();
/**
* (PHP 5 >= 5.0.1)
* Sets the class which handles SOAP requests
* @link http://php.net/manual/en/soapserver.setclass.php
* @param string $class_name
* The name of the exported class. *
* @param string $args [optional]* These optional parameters will be passed to the default class constructor * during object creation. *
* @return void */ public function setClass($class_name, $args = null) { parent::setClass($class_name, $args); /* * Set the class. */ $this->sClass = $class_name; } /** * (PHP 5 >= 5.2.0)* The object to handle the requests. *
* @return void */ public function setObject($object) { parent::setObject($object); /* * Set the class of the object. * We don't need to set the object (Zend_Soap_AutoDiscover wouldn't even know what to do with that), * as it doesn't matter. */ $this->sClass = get_class($object); } /** * (PHP 5 >= 5.0.1)* To export one function, pass the function name into this parameter as * a string. *
** To export several functions, pass an array of function names. *
** To export all the functions, pass a special constant SOAP_FUNCTIONS_ALL. *
** functions must receive all input arguments in the same * order as defined in the WSDL file (They should not receive any output parameters * as arguments) and return one or more values. To return several values they must * return an array with named output parameters. *
* @return void */ public function addFunction($functions) { parent::addFunction($functions); /* * Add the function(s) to our functions array. */ if (is_array($functions)) { foreach ($functions AS $function) { $this->aFunctions[] = $function; } } else { $this->aFunctions[] = $functions; } } /** * (PHP 5 >= 5.0.1)* The SOAP request. If this argument is omitted, the request is assumed to be * in the raw POST data of the HTTP request. *
* @return void */ public function handle($soap_request = null) { /* * Do they want us to generate a WSDL? */ if (isset($_GET['wsdl'])) { $oAutoDiscover = new Zend_Soap_AutoDiscover(); if (isset($this->sClass)) { $oAutoDiscover->setClass($this->sClass); } foreach ($this->aFunctions AS $sFunction) { $oAutoDiscover->addFunction($sFunction); } $oAutoDiscover->handle(); } else { parent::handle($soap_request); } } } ?>