I am in a dilemma. I have condemned the usage of Zend_Soap_Server (or any other webservice server handler) inside a Model-View-Controller application before. Still I get questions about my old Zend\_Soap\_Server and Zend\_Soap\_AutoDiscover example not working in the MVC scenario. The following example provides you with a working Soap server inside a Zend_Controller_Action, although I discourage the use of it and would suggest using a dedicated script outside the dispatching process to gain multitudes of performance, which webservices often require.
require_once "/path/to/HelloWorldService.php";
class MyDiscouragedSoapServerController extends Zend_Controller_Action
{
public function serverAction()
{
$server = new Zend_Soap_Server("http://example.com/pathto/wsdl");
$server->setClass('HelloWorldService');
$server->handle();
}
public function wsdlAction()
{
$wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setUri('http://example.com/pathto/server');
$wsdl->setClass('HelloWorldService');
$wsdl->handle();
}
}
Now all you have to do is create two routes, one that makes http://example.com/pathto/server** point to MyDiscouragedSoapServerController::serverAction and the other route that makes http://example.com/pathto/wsdl** point to MyDiscouragedSoapServerController::wsdlAction. The wrong version (Version Mismatch) error comes from sending a request for the WSDL file to the actual Soap Server, which he doesn't like.