From: <bov...@us...> - 2007-01-30 17:32:29
|
Revision: 1346 http://svn.sourceforge.net/pywebsvcs/?rev=1346&view=rev Author: boverhof Date: 2007-01-30 09:32:19 -0800 (Tue, 30 Jan 2007) Log Message: ----------- A test/wsdl2py/test_EchoWSAddr200403.py M test/wsdl2py/config.txt AM test/wsdl2py/servers/EchoWSAddr200403Server.py M ZSI/generate/wsdl2dispatch.py M ZSI/ServiceContainer.py M ZSI/address.py Merged ZSI_v2_0_0 fix for ws-addressing via ServiceContainer [ 1615228 ] "Unexpected keyword" error when using wsdl2dispatch with -a Modified Paths: -------------- trunk/zsi/ZSI/ServiceContainer.py trunk/zsi/ZSI/address.py trunk/zsi/ZSI/generate/wsdl2dispatch.py trunk/zsi/test/wsdl2py/config.txt Added Paths: ----------- trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py trunk/zsi/test/wsdl2py/test_EchoWSAddr200403.py Modified: trunk/zsi/ZSI/ServiceContainer.py =================================================================== --- trunk/zsi/ZSI/ServiceContainer.py 2007-01-27 01:03:50 UTC (rev 1345) +++ trunk/zsi/ZSI/ServiceContainer.py 2007-01-30 17:32:19 UTC (rev 1346) @@ -26,6 +26,7 @@ PostNotSpecified SOAPActionNotSpecified ServiceSOAPBinding + WSAResource SimpleWSResource SOAPRequestHandler ServiceContainer @@ -69,7 +70,7 @@ address = action service = server.getNode(post) isWSResource = False - if isinstance(service, SimpleWSResource): + if isinstance(service, WSAResource): isWSResource = True service.setServiceURL(localURL) address = Address() @@ -122,7 +123,7 @@ return SendFault(FaultFromException(e, 0, sys.exc_info()[2]), **kw) if isWSResource is True: - action = service.getResponseAction(action) + action = service.getResponseAction(ps, action) addressRsp = Address(action=action) try: addressRsp.setResponseFromWSAddress(address, localURL) @@ -220,7 +221,7 @@ return self.getOperation(ps, action)(ps) -class SimpleWSResource(ServiceSOAPBinding): +class WSAResource(ServiceSOAPBinding): '''Simple WSRF service, performs method resolutions based on WS-Action values rather than SOAP Action. @@ -452,7 +453,8 @@ address -- Address instance representing WS-Address ''' method = self.getCallBack(ps, post, action) - if isinstance(method.im_self, SimpleWSResource): + if (isinstance(method.im_self, WSAResource) or + isinstance(method.im_self, SimpleWSResource)): return method(ps, address) return method(ps) Modified: trunk/zsi/ZSI/address.py =================================================================== --- trunk/zsi/ZSI/address.py 2007-01-27 01:03:50 UTC (rev 1345) +++ trunk/zsi/ZSI/address.py 2007-01-30 17:32:19 UTC (rev 1346) @@ -52,7 +52,7 @@ value -- Action value server returned. ''' if action is None: - raise WSActionException, 'User did not specify WSAddress Action value to expect' + raise WSActionException, 'Response missing WSAddress Action' if not value: raise WSActionException, 'missing WSAddress Action, expecting %s' %action if value != action: @@ -72,8 +72,8 @@ if scheme==schemeF and path==pathF and query==queryF and fragment==fragmentF: netloc = netloc.split(':') + ['80'] netlocF = netlocF.split(':') + ['80'] - if netloc[1]==netlocF[1] and \ - socket.gethostbyname(netloc[0])==socket.gethostbyname(netlocF[0]): + if netloc[1]==netlocF[1] and (socket.gethostbyname(netlocF[0]) in + ('127.0.0.1', socket.gethostbyname(netloc[0]))): return raise WSActionException, 'wrong WS-Address From(%s), expecting %s'%(value,self._addressTo) Modified: trunk/zsi/ZSI/generate/wsdl2dispatch.py =================================================================== --- trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-01-27 01:03:50 UTC (rev 1345) +++ trunk/zsi/ZSI/generate/wsdl2dispatch.py 2007-01-30 17:32:19 UTC (rev 1346) @@ -3,7 +3,7 @@ import ZSI, string, sys, getopt, urlparse, types, warnings from ZSI.wstools import WSDLTools from ZSI.generate.wsdl2python import WriteServiceModule, MessageTypecodeContainer -from ZSI.ServiceContainer import ServiceSOAPBinding, SimpleWSResource +from ZSI.ServiceContainer import ServiceSOAPBinding, SimpleWSResource, WSAResource from ZSI.generate.utility import TextProtect, GetModuleBaseNameFromWSDL, NCName_to_ClassName, GetPartsSubNames, TextProtectAttributeName from ZSI.generate import WsdlGeneratorError, Wsdl2PythonError from ZSI.generate.wsdl2python import SchemaDescription @@ -364,7 +364,7 @@ class WSAServiceModuleWriter(ServiceModuleWriter): '''Creates a skeleton for a WS-Address service instance. ''' - def __init__(self, base=SimpleWSResource, prefix='wsa', service_class=SOAPService, strict=True): + def __init__(self, base=WSAResource, prefix='wsa', service_class=SOAPService, strict=True): ''' Parameters: strict -- check that soapAction and input ws-action do not collide. @@ -430,6 +430,7 @@ for ext in bop.extensions: if isinstance(ext, WSDLTools.SoapOperationBinding) is False: continue soap_action = ext.soapAction + if not soap_action: break if wsaction_in is None: break if wsaction_in == soap_action: break if self.strict is False: Modified: trunk/zsi/test/wsdl2py/config.txt =================================================================== --- trunk/zsi/test/wsdl2py/config.txt 2007-01-27 01:03:50 UTC (rev 1345) +++ trunk/zsi/test/wsdl2py/config.txt 2007-01-30 17:32:19 UTC (rev 1346) @@ -19,7 +19,7 @@ # ########################################################################## [configuration] -tracefile = 1 +tracefile = False debug = False skip = False twisted = False @@ -37,6 +37,7 @@ test_SquareService = servers/SquareService.py test_DateService = servers/DateService.py test_FinancialService = servers/FinancialService.py +test_EchoWSAddr200403 = servers/EchoWSAddr200403Server.py ########################################################################## @@ -118,7 +119,7 @@ document = True literal = True broke = False -tests = test_MapPoint test_Echo test_AWSECommerceService test_FinancialService test_BasicComm test_Manufacturer test_Racing test_Attributes test_Choice test_DerivedTypes +tests = test_MapPoint test_Echo test_AWSECommerceService test_FinancialService test_BasicComm test_Manufacturer test_Racing test_Attributes test_Choice test_DerivedTypes test_EchoWSAddr200403 [doc_literal_broke] document = True @@ -165,6 +166,8 @@ test_TerraService = http://terraservice.net/TerraService.asmx?WSDL test_InfoBil = http://javatest2.infodata.se/webservices/services/Infobil?wsdl +test_EchoWSAddr200403 = EchoWSAddr200403.wsdl + # Google AdWords test_GoogleAdWords = https://sandbox.google.com/api/adwords/v8/TrafficEstimatorService?wsdl @@ -172,4 +175,3 @@ test_GoogleAdWords_CS = https://sandbox.google.com/api/adwords/v8/CampaignService?wsdl test_Manufacturer = ManufacturerImpl.wsdl test_Racing = Racing.wsdl - Added: trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py =================================================================== --- trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py (rev 0) +++ trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py 2007-01-30 17:32:19 UTC (rev 1346) @@ -0,0 +1,26 @@ +#!/usr/bin/env python +############################################################################ +# Joshua R. Boverhof, LBNL +# See LBNLCopyright for copyright notice! +########################################################################### +import sys +from ZSI.ServiceContainer import AsServer +from EchoWSAddr200403Server_server import EchoWSAddr200403Server as EchoServer + +""" +EchoServer example service + +WSDL: ../../samples/Echo/Echo.wsdl + +""" + +class WSAService(EchoServer): + def wsa_Echo(self, ps, addr): + response = EchoServer.wsa_Echo(self, ps, addr) + response.EchoResult = self.request.EchoIn + return response + + +if __name__ == "__main__" : + port = int(sys.argv[1]) + AsServer(port, (WSAService('test'),)) Property changes on: trunk/zsi/test/wsdl2py/servers/EchoWSAddr200403Server.py ___________________________________________________________________ Name: svn:executable + * Added: trunk/zsi/test/wsdl2py/test_EchoWSAddr200403.py =================================================================== --- trunk/zsi/test/wsdl2py/test_EchoWSAddr200403.py (rev 0) +++ trunk/zsi/test/wsdl2py/test_EchoWSAddr200403.py 2007-01-30 17:32:19 UTC (rev 1346) @@ -0,0 +1,74 @@ +#!/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 + +WSDL: ../../samples/Echo/Echo.wsdl +""" + +# General targets +def dispatch(): + """Run all dispatch tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(EchoTestCase, 'test_dispatch')) + return suite + +def local(): + """Run all local tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(EchoTestCase, 'test_local')) + return suite + +def net(): + """Run all network tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(EchoTestCase, 'test_net')) + return suite + +def all(): + """Run all tests""" + suite = ServiceTestSuite() + suite.addTest(unittest.makeSuite(EchoTestCase, 'test_')) + return suite + + +class EchoTestCase(ServiceTestCase): + name = "test_EchoWSAddr200403" + client_file_name = "EchoWSAddr200403Server_client.py" + types_file_name = "EchoWSAddr200403Server_types.py" + server_file_name = "EchoWSAddr200403Server_server.py" + + def __init__(self, methodName): + ServiceTestCase.__init__(self, methodName) + self.wsdl2py_args.append('-a') + self.wsdl2py_args.append('-b') + self.wsdl2dispatch_args.append('-a') + + def getPortKWArgs(self): + kw = ServiceTestCase.getPortKWArgs(self) + kw['wsAddressURI'] = 'http://schemas.xmlsoap.org/ws/2004/03/addressing' + return kw + + def test_local_Echo(self): + msg = self.client_module.EchoRequest() + rsp = self.client_module.EchoResponse() + + def test_dispatch_Echo(self): + loc = self.client_module.EchoWSAddr200403ServerLocator() + port = loc.getport(**self.getPortKWArgs()) + + msg = self.client_module.EchoRequest() + msg.EchoIn = 'bla bla bla' + rsp = port.Echo(msg) + self.failUnless(rsp.EchoResult == msg.EchoIn, "Bad Echo") + + +if __name__ == "__main__" : + main() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |