note 101258 deleted from class.soapserver by bjori

From: Date: Mon, 06 Dec 2010 15:09:48 +0000
Subject: note 101258 deleted from class.soapserver by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174652@lists.php.net to get a copy of this message
Note Submitter: Guile Reason: bad code ---- Here is simple class that allows to use Zend_Soap_Server with Soap headers <?php /** * Class extending the Zend_Soap_Server that allow to add customized header * It overloads the constructor and the __getSoap method */ class My_SoapServer extends Zend_Soap_Server { /** * * @var array Array of SoapHeader to add to the SoapServer instance */ protected $headers; /** * Instanciate an instance * @param string $wsdl URL of the WSDL where services are described * @param array $options Options that SoapServer instance will handle */ public function __construct($wsdl = null, array $options = null) { $this->headers = array(); parent::__construct($wsdl, $options); } /** * Add a SoapHeader to the soap answer * @param SoapHeader $header Header to send with the SOAP answer inside the XML */ public function addSoapHeader(SoapHeader $header) { $this->headers[] = $header; } /** * Method overload that adds SoapHeader to the SoapServer instance * @return SoapServer The instance of the SoapServer use for handling response */ protected function __getSoap() { $soap = parent::__getSoap(); foreach ($this->headers as $header) { $soap->addSoapHeader($header); } return $soap; } } ?>

« previous php.notes (#174652) next »