80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
require_once 'framework/fwk.php';
|
|
|
|
class SinterneController extends Zend_Controller_Action
|
|
{
|
|
|
|
public function init()
|
|
{
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
// 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
|
|
try {
|
|
$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->setObject($proxy);
|
|
$server->setClassmap($classmap);
|
|
$server->handle();
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('log')->err("Sinterne - ".$e->getMessage());
|
|
}
|
|
}
|
|
exit;
|
|
}
|
|
} |