From: ksadil <ks...@pr...> - 2008-10-09 02:27:54
|
I have been using "Interoperable Python ZSI WSDL/SOAP Web Services tutorial" by Holger Joukl with great success. I do have one question that I have not been able to resolve about dispatching. I am trying to extend on the examples in the tutorial and where the example code looks like: AsServer(port=options.port, services=[MySquareService(),]) I am trying to use code like: AsServer(port=options.port, services=[MyfirstService(),MysecondService(),]) It fails with: ServiceAlreadyPresent: Service() already in ServiceContainer My code looks a lot like the following (with extra messy code removed): #!/apps/pydev/bin/python2.4 # *** ZSI 2.0 *** from optparse import OptionParser from ZSI.wstools import logging from ZSI.ServiceContainer import AsServer # Import the generated Server Object from Service1_services_server import firstService # Create a Server implementation by inheritance class MyfirstService(firstService): # Make WSDL available for HTTP GET _wsdl = "".join(open("Service1.wsdl").readlines()) def soap_firstService(self, ps, **kw): # Call the generated base class method to get appropriate # input/output data structures response = firstService.soap_firstService(self, ps, **kw) request = self.request return response def firstService(self,serviceData): print "responding now" # Import the generated Server Object from Serice1_services_server import secondService # Create a Server implementation by inheritance class MysecondService(secndService): # Make WSDL available for HTTP GET _wsdl = "".join(open("Service1.wsdl").readlines()) def soap_secondService(self, ps, **kw): # Call the generated base class method to get appropriate # input/output data structures response = secondService.soap_secondService(self, ps, **kw) request = self.request return response def secondService(self,serviceData1): print "responding now" op = OptionParser(usage="%prog [options]") op.add_option("-l", "--loglevel", help="loglevel (DEBUG, WARN)", metavar="LOGLEVEL") op.add_option("-p", "--port", help="HTTP port",metavar="PORT", default=8082, type="int") options, args = op.parse_args() # set the loglevel according to cmd line arg if options.loglevel: loglevel = eval(options.loglevel, logging.__dict__) logger = logging.getLogger("") logger.setLevel(loglevel) # Run the server with a given list services AsServer(port=options.port, services=[MyfirstService(),MySecondService(),]) any assistance would be appreciated. Regards, Kim |