82 lines
2.0 KiB
PHTML
Raw Normal View History

<?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>