From b4acea6de5f35ef63e2c9921492912f21d95b48d Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 30 Mar 2017 17:11:36 +0200 Subject: [PATCH] Traitement HTTPS --- application/controllers/ServiceController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 78078734..8dd482f7 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -78,6 +78,7 @@ class ServiceController extends Zend_Controller_Action } else { $pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl'; } + $pathServiceUri = 'clients/'.$client.'/v'.$version; // --- On redéfini le nom du service $serviceClassName = 'Entreprise'; $fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl'; @@ -92,6 +93,7 @@ class ServiceController extends Zend_Controller_Action } else { $pathServiceUrl = $serviceName.'/v'.$version.'?wsdl'; } + $pathServiceUri = $serviceName.'/v'.$version; $fichierWsdl = $serviceClassName.'-'.$version.'.wsdl'; } @@ -104,6 +106,11 @@ class ServiceController extends Zend_Controller_Action // --- Get hostname - add compatibility with Reverse Proxy $hostName = $request->getHttpHost(); $hostScheme = $request->getScheme(); + $http = new Zend_Controller_Request_Http(); + $proxyScheme = $http->getHeader('X-Forwarded-Proto'); + if ($proxyScheme == 'https') { + $hostScheme = 'https'; + } $fichierWsdl = $hostName . '-' . $hostScheme . '-' . $fichierWsdl; $c = Zend_registry::get('config'); $wsdlPath = $c->profil->path->shared . '/wsdl'; @@ -124,6 +131,10 @@ class ServiceController extends Zend_Controller_Action $wsdl->setBindingStyle(array('style' => 'document')); $wsdl->setClass($serviceClassName); + if ($hostScheme == 'https') { + $wsdl->setUri($hostScheme.'://'.$hostName.'/'.$pathServiceUri); + } + // --- Enregistrement du WSDL dans un fichier if (isset($_GET['wsdl-generate'])) { if (file_exists($wsdlPath . '/' . $fichierWsdl)) { @@ -131,7 +142,6 @@ class ServiceController extends Zend_Controller_Action } $wsdl->dump($wsdlPath . '/' . $fichierWsdl); echo "Le fichier $fichierWsdl a été généré"; - // --- Génération/Fourniture du wsdl } elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) { $wsdl->dump($wsdlPath . '/' . $fichierWsdl);