array( 'ws' => 'entreprise/v0.8?wsdl', 'form' => 'getIdentite', ), ); public function init() { $auth = Zend_Auth::getInstance(); $this->_username = $auth->getIdentity()->username; $this->_hash = $auth->getIdentity()->hash; } public function indexAction() { //Liste $tabMethods = array(); foreach($this->methods as $method => $element){ $url = $this->view->url(array( 'controller' => 'demo', 'action' => 'method', 'name' => $method, )); $tabMethods[] = array( 'nom' => $method, 'url' => $url, ); } $this->view->assign('methods', $tabMethods); } public function methodAction() { $method = $this->_getParam('name',''); $this->view->assign('method', $method); //Affichage du formulaire if (array_key_exists($method, $this->methods)){ $class = 'Scores_Ws_Form_'.ucfirst($method); if (class_exists($class)){ $form = new $class; $form->addElement('hidden', 'method', array( 'value' => $method, )); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); $form->populate($formData); } $this->view->assign('form', $form); } else { $this->view->assign('message',"Impossible d'afficher le formulaire !"); } } } public function requeteAction() { if ($this->_request->isPost()) { $formData = $this->_request->getPost(); $method = $formData['method']; $class = 'Scores_Ws_Form_'.ucfirst($method); if (class_exists($class)) { $form = new $class; if ($form->isValid($formData)) { $method = $formData['method']; $siret = $formData['siret']; $accesWs = $this->methods[$method]['ws']; $hostName = $this->getRequest()->getHttpHost(); $options = array( 'login' => $this->_username, 'password' => $this->_hash, 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS ); $client = new Zend_Soap_Client('http://'.$hostName.'/'.$accesWs, $options); $params = new StdClass(); $params->siret = $siret; try { $reponse = $client->getIdentite($params); } catch (Zend_Soap_Client_Exception $e) { $reponse = $e->getMessage(); } $soap = array( 'requete' => $params, 'reponse' => $reponse, ); $this->view->assign('soap',$soap); $xml = array( 'requete' => $client->getLastRequest(), 'reponse' => $client->getLastResponse() ); $this->view->assign('xml',$xml); } else { $this->_forward('method', 'demo', null, array('name'=> 'getIdentite')); } } } } }