Mise en place de l'affichage des exemples de code
This commit is contained in:
parent
5a072fd44b
commit
c9c4e2ce4e
@ -38,13 +38,38 @@ class IndexController extends Zend_Controller_Action
|
||||
$this->view->assign('serviceTypes', $tabServiceTypes);
|
||||
}
|
||||
|
||||
|
||||
public function codeAction()
|
||||
{
|
||||
$langage = $this->_getParam('langage','');
|
||||
$langage = strtolower($this->_getParam('langage',''));
|
||||
$element = $this->_getParam('element','');
|
||||
|
||||
$fichier = APPLICATION_PATH . '/../public/code/'.$element.'-'.$langage.'.txt';
|
||||
if (file_exists($fichier)){
|
||||
$sourceCode = file_get_contents($fichier);
|
||||
|
||||
require_once 'geshi/geshi.php';
|
||||
$geshi = new GeSHi($sourceCode, $langage);
|
||||
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
|
||||
$sourceHighlight = $geshi->parse_code();
|
||||
|
||||
$this->view->assign('langage', strtoupper($langage));
|
||||
$this->view->assign('code', $sourceHighlight);
|
||||
} else {
|
||||
$this->view->assign('langage', 'Erreur');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testAction()
|
||||
{
|
||||
/*
|
||||
* Un champ select proposera les différentes méthodes du webservice
|
||||
* Suivant le choix on affichera le formulaire adéquate pour ensuite
|
||||
* le traité
|
||||
* On effectuera la requête soap approprié pour afficher le résultat au
|
||||
* client
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,82 +1,2 @@
|
||||
<?php
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<h2>PHP</h2>
|
||||
<pre>
|
||||
$wsdl = 'http://hostname/service?wsdl';
|
||||
$options = array(
|
||||
'login' => $login,
|
||||
'password' => md5($login.'|'.$password)
|
||||
);
|
||||
$client = new SoapClient($wsdl, $options);
|
||||
|
||||
$parameters = new stdClass();
|
||||
$parameters->siret = '552144503';
|
||||
$parameters->id = 0;
|
||||
$parameters->forceVerif = false;
|
||||
$result = $client->getIdentite($parameters);
|
||||
|
||||
var_dump($result);
|
||||
</pre>
|
||||
|
||||
<h2>Perl</h2>
|
||||
<pre>
|
||||
Générer les méthodes à partir du WSDL grâce à l'utilitaire wsdl2perl
|
||||
|
||||
wsdl2perl -p Entreprise -b . http://hostname/service?wsdl
|
||||
|
||||
Modifier pour inclure l'authentification http basique
|
||||
|
||||
-> proxy('http://login:md5(login|password)@hostname/service')
|
||||
|
||||
Puis intérroger le service,
|
||||
|
||||
use EntrepriseInterfaces::entreprisesService::entreprisesPort;
|
||||
use EntrepriseElements::IdentiteRequest;
|
||||
my $service = EntrepriseInterfaces::entreprisesService::entreprisesPort->new();
|
||||
my $params = EntrepriseElements::IdentiteRequest->new({
|
||||
siret => '34838984200017',
|
||||
});
|
||||
my $result = $service->getIdentite($params);
|
||||
die $result if not $result;
|
||||
print $result;
|
||||
|
||||
</pre>
|
||||
|
||||
<h2>Python</h2>
|
||||
<pre>
|
||||
|
||||
from SOAPpy import Config, HTTPTransport, SOAPAddress, WSDL
|
||||
|
||||
class myHTTPTransport(HTTPTransport):
|
||||
username = None
|
||||
passwd = None
|
||||
|
||||
@classmethod
|
||||
def setAuthentication(cls,u,p):
|
||||
cls.username = u
|
||||
cls.passwd = p
|
||||
|
||||
def call(self, addr, data, namespace, soapaction=None, encoding=None,
|
||||
http_proxy=None, config=Config):
|
||||
|
||||
if not isinstance(addr, SOAPAddress):
|
||||
addr=SOAPAddress(addr, config)
|
||||
|
||||
if self.username != None:
|
||||
addr.user = self.username+":"+self.passwd
|
||||
|
||||
return HTTPTransport.call(self, addr, data, namespace, soapaction,
|
||||
encoding, http_proxy, config)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
wsdlFile = 'http://localhost/soap/wsdl/'
|
||||
myHTTPTransport.setAuthentication('USERNAME', 'PASSWORD')
|
||||
server = WSDL.Proxy(wsdlFile, transport=myHTTPTransport)
|
||||
print server.ApiVersion()
|
||||
|
||||
|
||||
</pre>
|
||||
<h2><?=$this->langage?></h2>
|
||||
<pre><?=$this->code?></pre>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<h1>WSDL</h1>
|
||||
<p>Télécharger le WSDL</p>
|
||||
<p>Le fichier est accessible sans authentification.</p>
|
||||
<p><a href="http://<?=$_SERVER['SERVER_NAME']?>/service?wsdl">Télécharger le WSDL</a></p>
|
||||
<i>Le fichier est accessible sans authentification.</i>
|
||||
|
||||
<h1>Authentification</h1>
|
||||
<p>
|
||||
@ -10,6 +10,7 @@ Il s'agit donc de transmettre comme paramètres d'authentification
|
||||
<p>http://{login}:{password}@url</p>
|
||||
<p>password est une chaine construite de cette façon md5({login}|{pass})</p>
|
||||
<p>ou le login est l'identifiant fournit et pass le mot de passe fournit.</p>
|
||||
<p>Exemple : <a href="index/code?langage=php&element=authentication">PHP</a></p>
|
||||
|
||||
<h1>Compatibilité</h1>
|
||||
<p>Notre service web a été testé avec ces langages/librairies</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user