webservice->location); $this->webservices = $config->webservices->toArray(); if ( !empty($login) && !empty($password) ){ $this->login = $login; $this->password = $password; } else { $auth = Zend_Auth::getInstance(); $user = $auth->getIdentity(); $this->login = $user->getLogin(); $this->password = $user->getPassword(); $this->nbReponses = $user->getNbRep(); if ( $user->checkModeEdition() ) { $this->toNotCache = true; } } } /** * setLog * @param string $page * @param string $siret * @param string $id * @param string $ref */ public function setLog ($page, $siret, $id=0, $ref = '') { $params = new stdClass(); $params->page = $idClient; $params->siret = $siret; $params->id = $id; $params->ref = $ref; $client = $this->loadClient('interne'); try { $reponse = $client->setLog($params); return true; } catch (SoapFault $fault) { $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); return false; } } /** * getInfosLogin * @param string $login * @param string $ipUtilisateur */ public function getInfosLogin($login, $ipUtilisateur = '') { $params = new stdClass(); $params->login = $login; $params->ipUtilisateur = $ipUtilisateur; try { $client = $this->loadClient('gestion'); $reponse = $client->getInfosLogin($params); return $reponse->getInfosLoginResult; } catch (SoapFault $fault) { if ($fault->faultcode=='0900'){ return $fault->faultstring; } else { $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); return false; } } } /** * soaperror * @param string $method * @param soapfault $fault * @param string $requete * @param string $reponse */ protected function soaperror($method, $fault, $requete, $reponse) { $message = ''; $message.= 'Erreur SOAP - Code : '.$fault->faultcode.' - Message : '.$fault->faultstring; $message.= ' - Utilisateur : '.$this->login; $message.= "\n"; $message.= "Method : ".$method.", File :".$fault->getFile().", Ligne : ".$fault->getLine(); $message.= "\n"; $message.= "Detail :\n".$fault->getTraceAsString(); $message.= "\n\n"; $message.= "Requete :\n ".$requete."\n"; $message.= "Reponse :\n ".$reponse."\n"; $configuration = Zend_Registry::get('configuration'); require_once 'Scores/Mail.php'; $mail = new Mail(); $mail->setSubject('[ERREUR SOAP] - '.$configuration->server->name.' -'.date('Ymd')); $mail->setBodyTexte($message); $mail->setFrom('supportdev'); $mail->addToKey('supportdev'); $mail->send(); } /** * loadClient * @param unknown_type $webservice */ protected function loadClient($webservice) { $wsdl = $this->webservices[$webservice]['wsdl']; $options = $this->webservices[$webservice]['options']; $options['features'] = SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS; $options['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE; $options['login'] = $this->login; $options['password'] = $this->password; if (APPLICATION_ENV != 'production'){ $options['cache_wsdl'] = WSDL_CACHE_NONE; } $options['trace'] = true; $options['encoding'] = 'utf-8'; $client = new SoapClient($wsdl, $options); return $client; } }