From: <bov...@us...> - 2007-01-11 21:53:53
|
Revision: 1317 http://svn.sourceforge.net/pywebsvcs/?rev=1317&view=rev Author: boverhof Date: 2007-01-11 13:53:49 -0800 (Thu, 11 Jan 2007) Log Message: ----------- A test/wsdl2py/test_GoogleAdWords.py -- added unittest for google adwords, good soap:header access example M test/wsdl2py/config.txt M test/wsdl2py/test_DateService.py A test/wsdl2py/test_GoogleAdWords.py M test/wsdl2py/test_ThreatService.py M test/wsdl2py/test_XMethodsQuery.py M test/wsdl2py/test_MapPoint.py M test/wsdl2py/test_AWSECommerceService.py M test/wsdl2py/test_FinancialService.py M test/wsdl2py/test_SquareService.py M test/wsdl2py/test_WhiteMesa.py -- modified tests to work with changes M ZSI/generate/wsdl2python.py M ZSI/generate/commands.py M ZSI/generate/containers.py -- changed locator access method from "portType.name" to "port.name", because this is correct. This could be problematic for services that declare multiple port's of the same portType. -- changed name of "SOAP" classes. Name after "binding.name", which is correct, not "port.name". Now if multiple ports w/same binding create 1 class and all of the "getPort" accessors use the 1 class. M ZSI/TC.py -- fixed _AnyLax and _AnyStrict constructors.. M CHANGES Modified Paths: -------------- trunk/zsi/CHANGES trunk/zsi/ZSI/TC.py trunk/zsi/ZSI/generate/commands.py trunk/zsi/ZSI/generate/containers.py trunk/zsi/ZSI/generate/wsdl2python.py trunk/zsi/test/wsdl2py/config.txt trunk/zsi/test/wsdl2py/test_AWSECommerceService.py trunk/zsi/test/wsdl2py/test_DateService.py trunk/zsi/test/wsdl2py/test_FinancialService.py trunk/zsi/test/wsdl2py/test_MapPoint.py trunk/zsi/test/wsdl2py/test_SquareService.py trunk/zsi/test/wsdl2py/test_ThreatService.py trunk/zsi/test/wsdl2py/test_WhiteMesa.py trunk/zsi/test/wsdl2py/test_XMethodsQuery.py Added Paths: ----------- trunk/zsi/test/wsdl2py/test_GoogleAdWords.py Modified: trunk/zsi/CHANGES =================================================================== --- trunk/zsi/CHANGES 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/CHANGES 2007-01-11 21:53:49 UTC (rev 1317) @@ -10,6 +10,10 @@ - no more wsdl2dispatch, wsdl2py does it all - simplified and consolidated various wsdl2py script options - wsdl2py added some soapheader support to client code. + - wsdl2py changed Locator accessors names to match the "port.name" + rather than the "portType.name" + - wsdl2py changed generated Binding class names to match the "binding.name" + rather than the "portType.name" Change for 2.0.0rc3 released xxx: - Updated ZSI developers guide Modified: trunk/zsi/ZSI/TC.py =================================================================== --- trunk/zsi/ZSI/TC.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/ZSI/TC.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -1666,8 +1666,7 @@ logger = _GetLogger('ZSI.TC._AnyStrict') def __init__(self, pname=None, aslist=False, **kw): - TypeCode.__init__(self, pname=pname, **kw) - self.aslist = aslist + Any.__init__(self, pname=pname, aslist=aslist, **kw) self.unique = True def serialize(self, elt, sw, pyobj, name=None, **kw): @@ -1687,8 +1686,7 @@ logger = _GetLogger('ZSI.TC._AnyLax') def __init__(self, pname=None, aslist=False, **kw): - TypeCode.__init__(self, pname=pname, **kw) - self.aslist = aslist + Any.__init__(self, pname=pname, aslist=aslist, **kw) self.unique = True def parse_into_dict_or_list(self, elt, ps): Modified: trunk/zsi/ZSI/generate/commands.py =================================================================== --- trunk/zsi/ZSI/generate/commands.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/ZSI/generate/commands.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -67,17 +67,13 @@ return f def wsdl2py(args=None): + """Utility for automatically generating client/service interface code from a wsdl +definition, and a set of classes representing element declarations and +type definitions. By default invoking this script produces three files, each +named after the wsdl definition name, in the current working directory. +These files will end with '_client.py', '_types.py', '_server.py' +respectively. """ - A utility for automatically generating client interface code from a wsdl - definition, and a set of classes representing element declarations and - type definitions. This will produce two files in the current working - directory named after the wsdl definition name. - - eg. <definition name='SampleService'> - SampleService_client.py - SampleService_types.py - SampleService_server.py - """ op = optparse.OptionParser(usage="USAGE: %wsdl2py [options] WSDL", description=wsdl2py.__doc__) @@ -120,7 +116,7 @@ action="callback", callback=SetUpTwistedClient, callback_kwargs={'module':'ZSI.generate.pyclass', 'metaclass':'pyclass_type'}, - help="generate a twisted.web client, dependencies python>=2.4, Twisted>=2.0.0, TwistedWeb>=0.5.0") + help="generate a twisted.web client/server, dependencies python>=2.4, Twisted>=2.0.0, TwistedWeb>=0.5.0") # Extended generation options #op.add_option("-e", "--extended", @@ -134,7 +130,7 @@ # help="file to load types from") op.add_option("-o", "--output-dir", action="store", dest="output_dir", default=".", type="string", - help="Directory to place generated files in (default current directory)") + help="save files in directory") op.add_option("-s", "--simple-naming", action="store_true", dest="simple_naming", default=False, help="map element names directly to python attributes") @@ -190,7 +186,7 @@ # Use a different client suffix # WriteServiceModule.client_module_suffix = "_client" # Write messages definitions to a separate file. - wsdl2pyServiceDescription.separate_messages = True + #wsdl2pyServiceDescription.separate_messages = True # Use more simple type and element class names containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) ) containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) ) Modified: trunk/zsi/ZSI/generate/containers.py =================================================================== --- trunk/zsi/ZSI/generate/containers.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/ZSI/generate/containers.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -371,8 +371,11 @@ self.logger.warning('Skip port(%s), not a SOAP-1.1 address binding' %p.name) continue - info = (p.getBinding().getPortType().name, p.getBinding().name, ab.location) - self.portInfo.append(info) + #info = (p.getBinding().getPortType().name, p.getBinding().name, ab.location) + self.portInfo.append( (NC_to_CN(p.name), + NC_to_CN(p.getBinding().name), + ab.location) + ) def getLocatorName(self): '''return class name of generated locator. @@ -392,23 +395,22 @@ self.locatorName = '%sLocator' %self.serviceName locator = ['# Locator', 'class %s:' %self.locatorName, ] self.portMethods = [] - for p in self.portInfo: - ptName = NC_to_CN(p[0]) - bName = NC_to_CN(p[1]) - sAdd = p[2] - method = 'get%s' %ptName - - pI = [ - '%s%s_address = "%s"' % (ID1, ptName, sAdd), - '%sdef get%sAddress(self):' % (ID1, ptName), - '%sreturn %sLocator.%s_address' % (ID2, - self.serviceName,ptName), - '%sdef %s(self, url=None, **kw):' %(ID1, method), - '%sreturn %s%s(url or %sLocator.%s_address, **kw)' \ - % (ID2, bName, self.clientClassSuffix, self.serviceName, ptName), + kwargs = KW.copy() + for port,bind,addr in self.portInfo: + # access method each port + method = 'get%s' %port + kwargs.update(dict(port=port, bind=bind, addr=addr, + service=self.serviceName, suffix=self.clientClassSuffix, method=method)) + + locator += [ + '%(ID1)s%(port)s_address = "%(addr)s"' %kwargs, + '%(ID1)sdef get%(port)sAddress(self):' %kwargs, + '%(ID2)sreturn %(service)sLocator.%(port)s_address' %kwargs, + '%(ID1)sdef %(method)s(self, url=None, **kw):' %kwargs, + '%(ID2)sreturn %(bind)s%(suffix)s(url or %(service)sLocator.%(port)s_address, **kw)' %kwargs, ] + self.portMethods.append(method) - locator += pI self.writeArray(locator) @@ -509,6 +511,7 @@ self.inputSimpleType = \ FromMessageGetSimpleElementDeclaration(op.getInputMessage()) self.inputAction = op.getInputAction() + self.soap_input_headers = bop.input.findBindings(WSDLTools.SoapHeaderBinding) if bop.output is not None: sbody = bop.output.findBinding(WSDLTools.SoapBodyBinding) @@ -519,10 +522,7 @@ self.outputSimpleType = \ FromMessageGetSimpleElementDeclaration(op.getOutputMessage()) self.outputAction = op.getOutputAction() - - - self.soap_input_headers = bop.input.findBindings(WSDLTools.SoapHeaderBinding) - self.soap_output_headers = bop.output.findBindings(WSDLTools.SoapHeaderBinding) + self.soap_output_headers = bop.output.findBindings(WSDLTools.SoapHeaderBinding) def _setContent(self): '''create string representation of operation. @@ -687,8 +687,9 @@ self.writeArray(method) -class ServiceOperationsClassContainer(ServiceContainerBase): - ''' +class BindingDescription(ServiceContainerBase): + '''writes out SOAP Binding class + class variables: readerclass -- writerclass -- @@ -697,7 +698,7 @@ readerclass = None writerclass = None operationclass = ServiceOperationContainer - logger = _GetLogger("ServiceOperationsClassContainer") + logger = _GetLogger("BindingDescription") def __init__(self, useWSA=False, do_extended=False, wsdl=None): '''Parameters: @@ -709,7 +710,7 @@ ServiceContainerBase.__init__(self) self.useWSA = useWSA self.rProp = None - self.bName = None + #self.bName = None self.operations = None self.do_extended = do_extended self._wsdl = wsdl # None unless do_extended == True @@ -734,43 +735,44 @@ cls.operationclass = className setOperationClass = classmethod(setOperationClass) - def setUp(self, port): + def setUp(self, item): '''This method finds all SOAP Binding Operations, it will skip all bindings that are not SOAP. - port -- WSDL.Port instance + item -- WSDL.Binding instance ''' - assert isinstance(port, WSDLTools.Port), \ - 'expecting WSDLTools Port instance' + assert isinstance(item, WSDLTools.Binding), \ + 'expecting WSDLTools Binding instance' + portType = item.getPortType() + self._kwargs = KW.copy() + self._kwargs['bind'] = NC_to_CN(item.name) self.operations = [] - self.bName = port.getBinding().name - self.rProp = port.getBinding().getPortType().getResourceProperties() - soap_binding = port.getBinding().findBinding(WSDLTools.SoapBinding) + self.rProp = portType.getResourceProperties() + soap_binding = item.findBinding(WSDLTools.SoapBinding) if soap_binding is None: raise Wsdl2PythonError,\ - 'port(%s) missing WSDLTools.SoapBinding' %port.name + 'Binding(%s) missing WSDLTools.SoapBinding' %item.name - for bop in port.getBinding().operations: + for bop in item.operations: soap_bop = bop.findBinding(WSDLTools.SoapOperationBinding) if soap_bop is None: self.logger.warning(\ - 'Skip port(%s) operation(%s) no SOAP Binding Operation'\ - %(port.name, bop.name), + 'Skip Binding(%s) operation(%s) no SOAP Binding Operation'\ + %(item.name, bop.name), ) continue - #soapAction = soap_bop.soapAction if bop.input is not None: soapBodyBind = bop.input.findBinding(WSDLTools.SoapBodyBinding) if soapBodyBind is None: self.logger.warning(\ - 'Skip port(%s) operation(%s) Bindings(%s) not supported'\ - %(port.name, bop.name, bop.extensions) + 'Skip Binding(%s) operation(%s) Bindings(%s) not supported'\ + %(item.name, bop.name, bop.extensions) ) continue - op = port.getBinding().getPortType().operations.get(bop.name) + op = portType.operations.get(bop.name) if op is None: raise Wsdl2PythonError,\ 'no matching portType/Binding operation(%s)' % bop.name @@ -782,27 +784,32 @@ def _setContent(self): if self.useWSA is True: - ctorArgs = 'endPointReference=None, **kw' - epr = 'self.endPointReference = endPointReference' + args = 'endPointReference=None, **kw' + epr = 'self.endPointReference = endPointReference' else: - ctorArgs = '**kw' + args = '**kw' epr = '# no ws-addressing' if self.rProp: - rprop = 'kw.setdefault("ResourceProperties", ("%s","%s"))'\ + rp = 'kw.setdefault("ResourceProperties", ("%s","%s"))'\ %(self.rProp[0], self.rProp[1]) else: - rprop = '# no resource properties' + rp = '# no resource properties' + kwargs = self._kwargs + kwargs.update(dict(suffix=self.clientClassSuffix, + args=args, epr=epr, rp=rp, readerclass=self.readerclass, + writerclass=self.writerclass,)) + methods = [ '# Methods', - 'class %s%s:' % (NC_to_CN(self.bName), self.clientClassSuffix), - '%sdef __init__(self, url, %s):' % (ID1, ctorArgs), - '%skw.setdefault("readerclass", %s)' % (ID2, self.readerclass), - '%skw.setdefault("writerclass", %s)' % (ID2, self.writerclass), - '%s%s' % (ID2, rprop), - '%sself.binding = client.Binding(url=url, **kw)' %ID2, - '%s%s' % (ID2,epr), + 'class %(bind)s%(suffix)s:' %kwargs, + '%(ID1)sdef __init__(self, url, %(args)s):' %kwargs, + '%(ID2)skw.setdefault("readerclass", %(readerclass)s)' %kwargs, + '%(ID2)skw.setdefault("writerclass", %(writerclass)s)' %kwargs, + '%(ID2)s%(rp)s' % kwargs, + '%(ID2)sself.binding = client.Binding(url=url, **kw)' %kwargs, + '%(ID2)s%(epr)s' % kwargs, ] for op in self.operations: @@ -810,6 +817,7 @@ self.writeArray(methods) +ServiceOperationsClassContainer = BindingDescription class MessageContainerInterface: Modified: trunk/zsi/ZSI/generate/wsdl2python.py =================================================================== --- trunk/zsi/ZSI/generate/wsdl2python.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/ZSI/generate/wsdl2python.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -7,7 +7,7 @@ # $Id$ -import os +import os, warnings from ZSI import _get_idstr from ZSI.wstools.logging import getLogger as _GetLogger from ZSI.wstools import WSDLTools @@ -239,7 +239,7 @@ self.imports = ServiceHeaderContainer() self.messagesImports = ServiceHeaderContainer() self.locator = ServiceLocatorContainer() - self.methods = [] + self.bindings = [] self.messages = [] self.do_extended=do_extended self._wsdl = wsdl # None unless do_extended == True @@ -272,30 +272,42 @@ self.locator.setUp(service) + try: + bindings = map(lambda p: p.binding, service.ports) + except: + warnings.warn('not all ports have binding declared,') + bindings = () + for port in service.ports: - sop_container = ServiceOperationsClassContainer(useWSA=self.wsAddressing, do_extended=self.do_extended, wsdl=self._wsdl) + if port.binding not in bindings: + continue + while port.binding in bindings: + bindings.remove(port.binding) + + desc = BindingDescription(useWSA=self.wsAddressing, do_extended=self.do_extended, wsdl=self._wsdl) try: - sop_container.setUp(port) + desc.setUp(port.getBinding()) except Wsdl2PythonError, ex: self.logger.warning('Skipping port(%s)' %port.name) if len(ex.args): self.logger.warning(ex.args[0]) - else: - sop_container.setReaderClass(kw.get('readerclass')) - sop_container.setWriterClass(kw.get('writerclass')) - for soc in sop_container.operations: - if soc.hasInput() is True: + continue + + desc.setReaderClass(kw.get('readerclass')) + desc.setWriterClass(kw.get('writerclass')) + for soc in desc.operations: + if soc.hasInput() is True: + mw = MessageWriter(do_extended=self.do_extended) + mw.setUp(soc, port, input=True) + self.messages.append(mw) + + if soc.hasOutput() is True: mw = MessageWriter(do_extended=self.do_extended) - mw.setUp(soc, port, input=True) + mw.setUp(soc, port, input=False) self.messages.append(mw) - if soc.hasOutput() is True: - mw = MessageWriter(do_extended=self.do_extended) - mw.setUp(soc, port, input=False) - self.messages.append(mw) + self.bindings.append(desc) - self.methods.append(sop_container) - def write(self, fd, msg_fd=None): """write out module to file descriptor. @@ -309,7 +321,7 @@ print >>fd, self.imports print >>fd, self.locator - for m in self.methods: + for m in self.bindings: print >>fd, m if msg_fd != None: Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/config.txt 2007-01-11 21:53:49 UTC (rev 1317) @@ -164,4 +164,10 @@ test_InfoBil = http://javatest2.infodata.se/webservices/services/Infobil?wsdl # Google AdWords -test_GoogleAdWords_TES = https://sandbox.google.com/api/adwords/v8/TrafficEstimatorService?wsdl +test_GoogleAdWords = https://sandbox.google.com/api/adwords/v8/TrafficEstimatorService?wsdl + +# TODO: These aren't finished +test_GoogleAdWords_CS = https://sandbox.google.com/api/adwords/v8/CampaignService?wsdl +test_Manufacturer = /Users/boverhof/Desktop/Workspace/Python/zsi/test/wsdl2py/wsdl/ManufacturerImpl.wsdl + + Modified: trunk/zsi/test/wsdl2py/test_AWSECommerceService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_AWSECommerceService.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -96,7 +96,7 @@ def test_net_ItemSearch(self): loc = self.client_module.AWSECommerceServiceLocator() - port = loc.getAWSECommerceServicePortType(**self.getPortKWArgs()) + port = loc.getAWSECommerceServicePort(**self.getPortKWArgs()) msg = self.client_module.ItemSearchRequestMsg() msg.SubscriptionId = '0HP1WHME000749APYWR2' Modified: trunk/zsi/test/wsdl2py/test_DateService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_DateService.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_DateService.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -60,7 +60,7 @@ def test_dispatch_getCurrentDate_getDate(self): offset = 9 loc = self.client_module.simple_Date_ServiceLocator() - port = loc.getDateService_PortType(**self.getPortKWArgs()) + port = loc.getDateService_Port(**self.getPortKWArgs()) print "START" msg = self.client_module.getCurrentDateRequest() msg.Input = "Test" Modified: trunk/zsi/test/wsdl2py/test_FinancialService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_FinancialService.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_FinancialService.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -58,7 +58,7 @@ def test_dispatch_getPV(self): loc = self.client_module.FinancialServiceLocator() - port = loc.getFinancialService_PortType(**self.getPortKWArgs()) + port = loc.getFinancialService_Port(**self.getPortKWArgs()) msg = self.client_module.getPVRequest() msg.Irate = 4 Added: trunk/zsi/test/wsdl2py/test_GoogleAdWords.py =================================================================== --- trunk/zsi/test/wsdl2py/test_GoogleAdWords.py (rev 0) +++ trunk/zsi/test/wsdl2py/test_GoogleAdWords.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -0,0 +1,97 @@ +#!/usr/bin/env python +############################################################################ +# Joshua R. Boverhof, LBNL +# See LBNLCopyright for copyright notice! +########################################################################### +import os, sys, unittest +from ServiceTest import main, ServiceTestCase, ServiceTestSuite +from ZSI import FaultException +""" +Unittest for contacting google adwords + +WSDL: +""" + +# General targets +def dispatch(): + """Run all dispatch tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(ServiceTest, 'test_dispatch')) + return suite + +def local(): + """Run all local tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(ServiceTest, 'test_local')) + return suite + +def net(): + """Run all network tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(ServiceTest, 'test_net')) + return suite + +def all(): + """Run all tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(ServiceTest, 'test_')) + return suite + + +class TrafficEstimatorServiceTest(ServiceTestCase): + """Test case for Google AdWords, sandbox v8 + Reads header information from a file "adwords.properties", need to format this for ConfigParser + +[test_GoogleAdWords_TES] +email = +password = +useragent = +applicationtoken = + + """ + name = "test_GoogleAdWords_TES" + client_file_name = "TrafficEstimatorService_client.py" + types_file_name = "TrafficEstimatorService_types.py" + server_file_name = "TrafficEstimatorService_server.py" + + header_info = os.path.join(os.getenv('HOME'), 'adwords.properties') + + def __init__(self, methodName): + ServiceTestCase.__init__(self, methodName) + self.wsdl2py_args.append('-b') + + def _get_soap_headers(self): + from ConfigParser import ConfigParser + cp = ConfigParser(); cp.read(self.header_info) + p,e,a,u = map(lambda var: cp.get(self.__class__.name, var), 'password email applicationtoken useragent'.split()) + tns,GED = "https://adwords.google.com/api/adwords/v8", self.client_module.GED + + password = GED(tns, "password").pyclass(p) + email = GED(tns, "email").pyclass(e) + atoken = GED(tns, "applicationToken").pyclass(a) + useragent = GED(tns, "useragent").pyclass(u) + + # google sandbox uses these conventions... + dtoken = GED(tns, "developerToken").pyclass('%s++USD' %e) + cemail = GED(tns, "clientEmail").pyclass('client_1+'+e) + + return (email, password, useragent, dtoken, atoken, cemail) + + def test_net_KeywordEstimate(self): + loc = self.client_module.TrafficEstimatorServiceLocator() + port = loc.getTrafficEstimatorService(**self.getPortKWArgs()) + msg = self.client_module.estimateKeywordListRequest() + + kwd = msg.new_keywordRequests() + kwd.Text = "flowers" + kwd.MaxCpc = 50000L + kwd.Type = "Broad" + msg.KeywordRequests = [ kwd ] + + rsp = port.estimateKeywordList(msg, soapheaders=self._get_soap_headers()) + +ServiceTest = TrafficEstimatorServiceTest + +if __name__ == "__main__" : + main() + Modified: trunk/zsi/test/wsdl2py/test_MapPoint.py =================================================================== --- trunk/zsi/test/wsdl2py/test_MapPoint.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_MapPoint.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -5,6 +5,7 @@ ########################################################################### import sys, unittest from ServiceTest import main, ServiceTestCase, ServiceTestSuite +from ZSI.auth import AUTH """ Unittest for contacting the Map Point Service. @@ -46,11 +47,17 @@ types_file_name = "CommonService_types.py" server_file_name = "CommonService_server.py" + def __init__(self, methodName): + ServiceTestCase.__init__(self, methodName) + self.wsdl2py_args.append('-b') + def test_net_GetVersionInfo(self): """expect this to fail cause i'm not doing http authentication. """ loc = self.client_module.CommonServiceLocator() - port = loc.getCommonServiceSoap(**self.getPortKWArgs()) + kw = self.getPortKWArgs() + #port = loc.getCommonServiceSoap(auth=(AUTH.httpdigest, "USERNAME", "PASSWORD"), **kw) + port = loc.getCommonServiceSoap(**kw) msg = self.client_module.GetVersionInfoSoapIn() try: @@ -58,6 +65,13 @@ except RuntimeError: # RuntimeError: HTTP Digest Authorization Failed pass + + port.binding.SetAuth(AUTH.httpdigest, user="USERNAME", password="PASSWORD") + print ">> DIGEST AUTH" + try: + rsp = port.GetVersionInfo(msg) + except RuntimeError: + pass if __name__ == "__main__" : Modified: trunk/zsi/test/wsdl2py/test_SquareService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_SquareService.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_SquareService.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -61,7 +61,7 @@ def test_dispatch_getSquare(self): loc = self.client_module.SquareServiceLocator() - port = loc.getSquarePortType(**self.getPortKWArgs()) + port = loc.getSquarePort(**self.getPortKWArgs()) msg = self.client_module.getSquareRequest() msg.X = 4.0 Modified: trunk/zsi/test/wsdl2py/test_ThreatService.py =================================================================== --- trunk/zsi/test/wsdl2py/test_ThreatService.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_ThreatService.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -54,7 +54,7 @@ def test_net_threatLevel(self): loc = self.client_module.Current_Homeland_Security_Threat_LevelLocator() - port = loc.getthreat(**self.getPortKWArgs()) + port = loc.getthreat_cfc(**self.getPortKWArgs()) msg = self.client_module.threatLevelRequest() rsp = port.threatLevel(msg) Modified: trunk/zsi/test/wsdl2py/test_WhiteMesa.py =================================================================== --- trunk/zsi/test/wsdl2py/test_WhiteMesa.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_WhiteMesa.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -63,7 +63,7 @@ msg._inputBoolean = True loc = self.client_module.WhiteMesaSoapRpcLitTestSvcLocator() - port = loc.getSoapTestPortTypeRpc(**self.getPortKWArgs()) + port = loc.getSoap11TestRpcLitPort(**self.getPortKWArgs()) rsp = port.echoBoolean(msg) self.failUnless(msg._inputBoolean == rsp._return, Modified: trunk/zsi/test/wsdl2py/test_XMethodsQuery.py =================================================================== --- trunk/zsi/test/wsdl2py/test_XMethodsQuery.py 2007-01-11 17:27:28 UTC (rev 1316) +++ trunk/zsi/test/wsdl2py/test_XMethodsQuery.py 2007-01-11 21:53:49 UTC (rev 1317) @@ -53,7 +53,7 @@ def test_net_getAllServiceNames(self): loc = self.client_module.XMethodsQueryLocator() - port = loc.getXMethodsQuerySoapPortType(**self.getPortKWArgs()) + port = loc.getXMethodsQuerySoap(**self.getPortKWArgs()) msg = self.client_module.getAllServiceNames2SoapIn() rsp = port.getAllServiceNames(msg) @@ -61,7 +61,7 @@ def test_net_getAllServiceSummaries(self): loc = self.client_module.XMethodsQueryLocator() - port = loc.getXMethodsQuerySoapPortType(**self.getPortKWArgs()) + port = loc.getXMethodsQuerySoap(**self.getPortKWArgs()) msg = self.client_module.getAllServiceSummaries1SoapIn() rsp = port.getAllServiceSummaries(msg) @@ -69,7 +69,7 @@ def test_net_getServiceDetail(self): loc = self.client_module.XMethodsQueryLocator() - port = loc.getXMethodsQuerySoapPortType(**self.getPortKWArgs()) + port = loc.getXMethodsQuerySoap(**self.getPortKWArgs()) msg = self.client_module.getServiceDetail4SoapIn() msg._id = 'uuid:A29C0D6C-5529-0D27-A91A-8E02D343532B' @@ -78,7 +78,7 @@ def test_net_getServiceNamesByPublisher(self): loc = self.client_module.XMethodsQueryLocator() - port = loc.getXMethodsQuerySoapPortType(**self.getPortKWArgs()) + port = loc.getXMethodsQuerySoap(**self.getPortKWArgs()) msg = self.client_module.getServiceNamesByPublisher3SoapIn() msg._publisherID = 'xmethods.net' @@ -87,7 +87,7 @@ def test_net_getServiceSummariesByPublisher(self): loc = self.client_module.XMethodsQueryLocator() - port = loc.getXMethodsQuerySoapPortType(**self.getPortKWArgs()) + port = loc.getXMethodsQuerySoap(**self.getPortKWArgs()) msg = self.client_module.getServiceSummariesByPublisher0SoapIn() msg._publisherID = 'xmethods.net' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |