100 lines
2.7 KiB
PHP
100 lines
2.7 KiB
PHP
<?php
|
|
ini_set("soap.wsdl_cache_enabled", "0");
|
|
|
|
class ServiceController extends Zend_Controller_Action
|
|
{
|
|
private $wsdlName = 'WsEntreprise';
|
|
private $wsdlVersion = '0.1';
|
|
|
|
public function init()
|
|
{
|
|
/* Initialize action controller here */
|
|
$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/WsEntreprise.php';
|
|
require_once 'WsScore/WrappedServiceProxy.php';
|
|
|
|
$fichierWsdl = $this->wsdlName.'-'.$this->wsdlVersion.'.wsdl';
|
|
|
|
// Fourniture du wsdl
|
|
if (isset($_GET['wsdl'])){
|
|
if (file_exists($fichierWsdl)){
|
|
if (!headers_sent()) {
|
|
header('Content-Type: text/xml');
|
|
}
|
|
echo file_get_contents($fichierWsdl);
|
|
} else {
|
|
echo "Erreur WSDL ! ";
|
|
}
|
|
|
|
// Génération du wsdl
|
|
} elseif ( isset($_GET['wsdl-generate']) || isset($_GET['wsdl-auto']) ){
|
|
|
|
// Définition du webservice
|
|
$wsdl = new Zend_Soap_AutoDiscover();
|
|
$wsdl->setOperationBodyStyle( array('use' => 'literal') );
|
|
$wsdl->setBindingStyle( array('style' => 'document') );
|
|
// Inspecte la classe retourner la description
|
|
$wsdl->setClass('WsEntreprise');
|
|
|
|
// Enregistrement du WSDL dans un fichier
|
|
if ( isset($_GET['wsdl-generate']) ){
|
|
$wsdl->dump($fichierWsdl);
|
|
echo 'Génération du WSDL Terminé';
|
|
// Envoi sur la sortie standard le wsdl
|
|
} elseif ( isset($_GET['wsdl-auto']) ) {
|
|
$wsdl->handle();
|
|
}
|
|
|
|
// Fourniture du service
|
|
} else {
|
|
|
|
//file_put_contents( 'dlw.log', file_get_contents("php://input") );
|
|
|
|
$classmap = array(
|
|
'IdentiteType' => 'IdentiteType',
|
|
'IdentiteReturnType' => 'IdentiteReturnType',
|
|
'IdentiteResultType' => 'IdentiteResultType',
|
|
'GeoInfos' => 'GeoInfos',
|
|
'IdentiteBilan' => 'IdentiteBilan',
|
|
'IdentiteBourse' => 'IdentiteBourse',
|
|
'ErrorType' => 'ErrorType',
|
|
);
|
|
|
|
//Gérer les authentifications
|
|
//Renvoyer une erreur soap
|
|
|
|
// traitement
|
|
try {
|
|
$hostName = $this->getRequest()->getHttpHost();
|
|
|
|
$server = new Zend_Soap_Server('http://'.$hostName.'/service?wsdl-auto');
|
|
$proxy = new WrappedService_Proxy('WsEntreprise', array(), array('wrappedParts' => true));
|
|
$server->setObject($proxy);
|
|
$server->setClassmap($classmap);
|
|
$server->handle();
|
|
|
|
} catch (Zend_Exception $e) {
|
|
//Enregistrement des erreurs
|
|
/*
|
|
* $e->getMessage()
|
|
* $e->getCode()
|
|
* $e->getFile()
|
|
* $e->getLine()
|
|
*/
|
|
}
|
|
}
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|
|
|