2010-09-21 15:21:02 +00:00
|
|
|
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()
|
2010-09-30 07:15:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from SOAPpy import WSDL
|
|
|
|
wsdlFile = 'http://hostname/service?wsdl'
|
|
|
|
server = WSDL.Proxy(wsdlFile)
|
|
|
|
server.methods.keys()
|
|
|
|
[u'status', u'getIdentite', u'rechercheEntreprise']
|
|
|
|
|
|
|
|
callInfo = server.methods['getTemp']
|
|
|
|
callInfo.inparams
|
|
|
|
[<SOAPpy.wstools.WSDLTools.ParameterInfo instance at 0xf9b950>]
|
|
|
|
callInfo.inparams[0].name
|
|
|
|
u'parameters'
|
|
|
|
callInfo.inparams[0].type
|
|
|
|
(u'http://wse.scores-decisions.com:8081/service', u'status')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.soapproxy.config.dumpSOAPOut = 1
|
|
|
|
server.soapproxy.config.dumpSOAPIn = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|