Use class of Zend where proxy is integrated to deliver .NET compatible service

This commit is contained in:
Michael RICOIS 2012-06-01 15:17:49 +00:00
parent bbfe653421
commit 6b699461ea

View File

@ -3,35 +3,31 @@ require_once 'framework/fwk.php';
class ServiceController extends Zend_Controller_Action
{
public function init(){}
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();
//Nom du service
$serviceName = $request->getParam('service', 'Entreprise');
//Get the service name, make sure the string is in lower case
$serviceName = strtolower($request->getParam('service', 'Entreprise'));
//Chemin du fichier de configuration des versions
$pathServiceVersion = 'WsScore/'.ucfirst($serviceName).'/Versions.ini';
//ClassName and Directory with first letter capitalized
$serviceClassName = ucfirst($serviceName);
//Service spécifique client
if (strtolower($serviceName) == 'clients') {
$client = $request->getParam('client', '');
//Liste des clients
//path of file where versions of service is store
$pathServiceVersion = 'WsScore/'.$serviceClassName.'/Versions.ini';
//Customize service for customers
if ('clients' == $serviceName ) {
$client = strtolower($request->getParam('client', ''));
$clientClassName = ucfirst($client);
//Get list of customers
$clients = array();
$listeClients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach ( $listeClients->toArray() as $section => $params ){
if ($params['actif']){
if ($params['actif']) {
$clients[] = $section;
}
}
@ -39,7 +35,7 @@ class ServiceController extends Zend_Controller_Action
echo 'Service clients introuvable !';
exit;
}
$pathServiceVersion = 'WsScore/Clients/'.ucfirst($client).'/Versions.ini';
$pathServiceVersion = 'WsScore/Clients/'.$clientClassName.'/Versions.ini';
}
// Liste des versions
@ -65,9 +61,9 @@ class ServiceController extends Zend_Controller_Action
}
// Charger les classes et les types pour le service suivant la version
if (strtolower($serviceName) == 'clients') {
$pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';
if ('clients' == $serviceName) {
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Entreprise.php';
//Gestion du mode de génération du wsdl
if ( APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
@ -78,10 +74,10 @@ class ServiceController extends Zend_Controller_Action
}
//On redéfini le nom du service
$serviceName = 'Entreprise';
$fichierWsdl = ucfirst($client).'-'.$serviceName.'-'.$version.'.wsdl';
$fichierWsdl = $clientClassName.'-'.$serviceName.'-'.$version.'.wsdl';
} else {
$pathServiceClassIni = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.ini';
$pathServiceClassPhp = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.php';
$pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/'.$serviceClassName.'.ini';
$pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/'.$serviceClassName.'.php';
//Gestion du mode de génération du wsdl
if ( APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
@ -90,7 +86,7 @@ class ServiceController extends Zend_Controller_Action
} else {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl';
}
$fichierWsdl = ucfirst($serviceName).'-'.$version.'.wsdl';
$fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
}
//Génération du tableau de mapping
@ -121,7 +117,7 @@ class ServiceController extends Zend_Controller_Action
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$wsdl->setOperationBodyStyle( array('use' => 'literal') );
$wsdl->setBindingStyle( array('style' => 'document') );
$wsdl->setClass(ucfirst($serviceName));
$wsdl->setClass($serviceClassName);
// Enregistrement du WSDL dans un fichier
if ( isset($_GET['wsdl-generate']) ) {
@ -154,12 +150,13 @@ class ServiceController extends Zend_Controller_Action
$hostName = $this->getRequest()->getHttpHost();
$server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl);
}
$proxy = new WrappedService_Proxy(ucfirst($serviceName), array(), array('wrappedParts' => true));
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
$server->setClassmap($classmap);
$server->setEncoding('UTF-8');
$server->registerFaultException(array('WsScores_Exception'));
$server->setObject($proxy);
$server->setWsiCompliant(true);
$server->setObject(new $serviceClassName());
$server->handle();
//Pour débuggage ultime