Generate the WSDL file from a class using a Zend component

Matthew Weier O’Phinney answers a very common question;

“Is there a way to generate the WSDL file from a class using a Zend component?”

Yes — via Zend_Soap_Autodiscover:

http://framework.zend.com/manual/en/zend.soap.autodiscovery.html

A typical workflow is to do the following:


if ('GET' == $_SERVER['HTTP_METHOD']) {
$server = new Zend_Soap_Autodiscover();
} else {
$server = new Zend_Soap_Server();
}

$server->setClass('SomeClass');
echo $server->handle();

Basically, you handle GET requests as a request for the WSDL, and anything else as a SOAP request.