webservice/batch/genwsdl.php
2011-02-07 14:50:52 +00:00

84 lines
2.2 KiB
PHP

#!/usr/bin/php
<?php
//error_reporting(E_ALL & ~E_NOTICE);
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
require_once realpath(dirname(__FILE__)).'/../config/config.php';
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Displays usage information.",
'all' => "Créer les WSDL à l'installation.",
'version=s' => "Re-Créer le WSDL associé à la version X.X.X",
'host=s' => "Le nom de domaine à requéter pour générer les WSDL correctement (sans http://)."
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
//Génération des WSDL
if (isset($opts->all) && isset($opts->host))
{
$configServiceVersions = new Zend_Config_Ini('WsScore/Entreprise/Versions.ini');
foreach( $configServiceVersions->toArray() as $section => $params ){
$version = $section;
echo "Version $version";
if ($params['actif']==1){
echo " Traitement...\n";
echo genereWSDL($opts->host, $version);
}
echo "\n";
}
}
if (isset($opts->version) && isset($opts->host)){
echo genereWSDL($opts->host, $opts->version);
echo "\n";
}
function genereWSDL($host, $version){
$uri = 'http://'.$host.'/entreprise/v'.$version.'?wsdl-generate';
$client = new Zend_Http_Client($uri, array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
));
$response = $client->request('GET');
return $response->getBody();
}