Suppression autre controller pour gérer les services
This commit is contained in:
parent
9601aba66b
commit
ce3fdcb6ef
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
class SclientsController extends Zend_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
require_once 'Zend/Exception.php';
|
||||
require_once 'Zend/Soap/AutoDiscover.php';
|
||||
require_once 'Zend/Soap/Server.php';
|
||||
require_once 'WsScore/WrappedServiceProxy.php';
|
||||
|
||||
$request = $this->getRequest();
|
||||
$client = $request->getParam('client', '');
|
||||
|
||||
//Liste des clients
|
||||
$clients = array();
|
||||
$listeClients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
|
||||
foreach ( $listeClients->toArray() as $section => $params ){
|
||||
if ($params['actif']){
|
||||
$clients[] = $section;
|
||||
}
|
||||
}
|
||||
if (!in_array($client, $clients)){
|
||||
echo '...';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Liste des versions
|
||||
$serviceVersions = array();
|
||||
$configServiceVersions = new Zend_Config_Ini('WsScore/Clients/'.$client.'/Versions.ini');
|
||||
foreach ( $configServiceVersions->toArray() as $section => $params ){
|
||||
$serviceVersions[$section] = $params;
|
||||
if ($params['defaut']) {
|
||||
$defautVersion = $section;
|
||||
}
|
||||
}
|
||||
|
||||
$version = $request->getParam('version', 'v'.$defautVersion);
|
||||
$version = substr($version, 1);
|
||||
|
||||
if (empty($version)) { $version = $defautVersion; }
|
||||
|
||||
// Version inexistante
|
||||
if ( !array_key_exists($version, $serviceVersions) ) {
|
||||
echo "Version inexistante.";
|
||||
exit;
|
||||
}
|
||||
// Version désactivé
|
||||
if ( !$serviceVersions[$version]['actif'] ) {
|
||||
echo "Version désactivée.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Charger les classes et les types pour le service suivant la version
|
||||
$pathClassService = 'WsScore/Clients/'.$client.'/v'.$version.'/';
|
||||
$wsConfig = new Zend_Config_Ini($pathClassService.'Entreprise.ini');
|
||||
foreach($wsConfig->Type->toArray() as $Type){
|
||||
$classmap[$Type] = $Type;
|
||||
}
|
||||
require_once $pathClassService.'Entreprise.php';
|
||||
// @todo : modifier le nom du fichier
|
||||
$fichierWsdl = 'Entreprise-'.$clients.'-'.$version.'.wsdl';
|
||||
|
||||
// Génération/Founiture du wsdl
|
||||
if ( isset($_GET['wsdl']) && file_exists($fichierWsdl) ) {
|
||||
|
||||
if (!headers_sent()) {
|
||||
header('Content-Type: text/xml');
|
||||
}
|
||||
echo file_get_contents($fichierWsdl);
|
||||
|
||||
} elseif ( isset($_GET['wsdl']) && !file_exists($fichierWsdl)
|
||||
|| isset($_GET['wsdl-generate'])
|
||||
|| isset($_GET['wsdl-auto']) ) {
|
||||
|
||||
// Définition du webservice
|
||||
$wsdl = new Zend_Soap_AutoDiscover();
|
||||
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
|
||||
$wsdl->setOperationBodyStyle( array('use' => 'literal') );
|
||||
$wsdl->setBindingStyle( array('style' => 'document') );
|
||||
$wsdl->setClass('Entreprise');
|
||||
|
||||
// Enregistrement du WSDL dans un fichier
|
||||
if ( isset($_GET['wsdl-generate']) ) {
|
||||
|
||||
if (file_exists($fichierWsdl)) {
|
||||
unlink($fichierWsdl);
|
||||
}
|
||||
$wsdl->dump($fichierWsdl);
|
||||
echo "Le fichier $fichierWsdl a été généré";
|
||||
|
||||
} elseif (isset($_GET['wsdl']) && !file_exists($fichierWsdl)) {
|
||||
$wsdl->dump($fichierWsdl);
|
||||
if (!headers_sent()) {
|
||||
header('Content-Type: text/xml');
|
||||
}
|
||||
echo file_get_contents($fichierWsdl);
|
||||
|
||||
// Envoi sur la sortie standard le wsdl
|
||||
} elseif ( isset($_GET['wsdl-auto']) ){
|
||||
$wsdl->handle();
|
||||
}
|
||||
|
||||
// Fourniture du service
|
||||
} else {
|
||||
|
||||
// traitement
|
||||
if (APPLICATION_ENV == 'production' && file_exists($fichierWsdl)) {
|
||||
// @todo Vérifier la présence du fichier sinon envoyer erreur
|
||||
$server = new Zend_Soap_Server($fichierWsdl);
|
||||
} else {
|
||||
$hostName = $this->getRequest()->getHttpHost();
|
||||
$server = new Zend_Soap_Server('http://'.$hostName.'/clients/'.$client.'?wsdl-auto');
|
||||
}
|
||||
$proxy = new WrappedService_Proxy('Entreprise', array(), array('wrappedParts' => true));
|
||||
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
|
||||
$server->setClassmap($classmap);
|
||||
$server->setEncoding('UTF-8');
|
||||
$server->setObject($proxy);
|
||||
$server->handle();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
require_once 'framework/fwk.php';
|
||||
|
||||
class SinterneController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
// action body
|
||||
require_once 'Zend/Exception.php';
|
||||
require_once 'Zend/Soap/AutoDiscover.php';
|
||||
require_once 'Zend/Soap/Server.php';
|
||||
require_once 'WsScore/WrappedServiceProxy.php';
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Liste des versions
|
||||
$configServiceVersions = new Zend_Config_Ini('WsScore/Interne/Versions.ini');
|
||||
foreach( $configServiceVersions->toArray() as $section => $params ){
|
||||
$serviceVersions[$section] = $params;
|
||||
if ($params['defaut']) {
|
||||
$defautVersion = $section;
|
||||
}
|
||||
}
|
||||
|
||||
$version = $request->getParam('version', 'v'.$defautVersion);
|
||||
$version = substr($version, 1);
|
||||
|
||||
// Version inexistante
|
||||
if ( !array_key_exists($version, $serviceVersions) ) {
|
||||
echo "Version inexistante.";
|
||||
exit;
|
||||
}
|
||||
// Version désactivé
|
||||
if ( !$serviceVersions[$version]['actif'] ) {
|
||||
echo "Version désactivée.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Charger les classes et les types pour le service suivant la version
|
||||
$pathClassService = 'WsScore/Interne/v'.$version.'/';
|
||||
$wsConfig = new Zend_Config_Ini($pathClassService.'Interne.ini');
|
||||
foreach($wsConfig->Type->toArray() as $Type){
|
||||
$classmap[$Type] = $Type;
|
||||
}
|
||||
require_once $pathClassService.'Interne.php';
|
||||
|
||||
// Fourniture du wsdl
|
||||
if (isset($_GET['wsdl'])) {
|
||||
// Définition du webservice
|
||||
$wsdl = new Zend_Soap_AutoDiscover();
|
||||
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
|
||||
$wsdl->setOperationBodyStyle( array('use' => 'literal') );
|
||||
$wsdl->setBindingStyle( array('style' => 'document') );
|
||||
$wsdl->setClass('Interne');
|
||||
$wsdl->handle();
|
||||
}
|
||||
// Fourniture du service
|
||||
else {
|
||||
|
||||
// traitement
|
||||
$hostName = $this->getRequest()->getHttpHost();
|
||||
$server = new Zend_Soap_Server('http://'.$hostName.'/interne/v'.$version.'?wsdl');
|
||||
$proxy = new WrappedService_Proxy('Interne', array(), array('wrappedParts' => true));
|
||||
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
|
||||
$server->setClassmap($classmap);
|
||||
$server->setEncoding('UTF-8');
|
||||
$server->setObject($proxy);
|
||||
$server->handle();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user