def get(self): """ Method get() returned the WSDL. If wsdl_path is null, the WSDL is generated dinamically. """ if hasattr(options, 'wsdl_hostname') and type(options.wsdl_hostname) is str: address = options.wsdl_hostname else: address = getattr( self, 'targetns_address', tornado.httpserver.socket.gethostbyname( tornado.httpserver.socket.gethostname())) port = 80 # if you are using the port 80 if len(self.request.headers['Host'].split(':')) >= 2: port = self.request.headers['Host'].split(':')[1] wsdl_nameservice = self.request.uri.replace('/', '').replace( '?wsdl', '').replace('?WSDL', '') wsdl_input = None wsdl_output = None wsdl_operation = None wsdl_args = None wsdl_methods = [] for operations in dir(self): operation = getattr(self, operations) if callable(operation) and hasattr(operation,'_input') and hasattr(operation,'_output') and hasattr(operation,'_operation') \ and hasattr(operation,'_args') and hasattr(operation,'_is_operation'): wsdl_input = getattr(operation, '_input') wsdl_output = getattr(operation, '_output') wsdl_operation = getattr(operation, '_operation') wsdl_args = getattr(operation, '_args') wsdl_data = { 'args': wsdl_args, 'input': ('params', wsdl_input), 'output': ('returns', wsdl_output), 'operation': wsdl_operation } wsdl_methods.append(wsdl_data) wsdl_targetns = 'http://%s:%s/%s' % (address, port, wsdl_nameservice) wsdl_location = 'http://%s:%s/%s' % (address, port, wsdl_nameservice) query = self.request.query self.set_header('Content-Type', 'application/xml; charset=UTF-8') if query.upper() == 'WSDL': if wsdl_path == None: wsdlfile = wsdl.Wsdl(nameservice=wsdl_nameservice, targetNamespace=wsdl_targetns, methods=wsdl_methods, location=wsdl_location) self.finish(wsdlfile.createWsdl().toxml()) else: fd = open(str(wsdl_path), 'r') xmlWSDL = '' for line in fd: xmlWSDL += line fd.close() self.finish(xmlWSDL)
def get(self): """ Method get() returned the WSDL. If wsdl_path is null, the WSDL is generated dinamically. """ address = getattr( self, 'targetns_address', tornado.httpserver.socket.gethostbyname( tornado.httpserver.socket.gethostname())) port = self.request.headers['Host'].split(':')[1] wsdl_nameservice = self.request.uri.replace('/', '').replace( '?wsdl', '').replace('?WSDL', '') wsdl_input = None wsdl_output = None wsdl_operation = None wsdl_args = None for operations in dir(self): operation = getattr(self, operations) if callable(operation) and hasattr(operation,'_input') and hasattr(operation,'_output') and hasattr(operation,'_operation') \ and hasattr(operation,'_args'): wsdl_input = getattr(operation, '_input') wsdl_output = getattr(operation, '_output') wsdl_operation = getattr(operation, '_operation') wsdl_args = getattr(operation, '_args') wsdl_targetns = 'http://%s:%s/%s/%s' % ( address, port, wsdl_nameservice, wsdl_operation) wsdl_location = 'http://%s:%s/%s' % (address, port, wsdl_nameservice) query = self.request.query self.set_header('Content-Type', 'application/xml; charset=UTF-8') if string.upper(query) == 'WSDL': if wsdl_path == None: wsdlfile = wsdl.Wsdl(nameservice=wsdl_nameservice, targetNamespace=wsdl_targetns, arguments=wsdl_args, elementInput=('params', wsdl_input), elementOutput=('returns', wsdl_output), operation=wsdl_operation, location=wsdl_location) self.finish(wsdlfile.createWsdl().toxml()) else: fd = open(str(wsdl_path), 'r') xmlWSDL = '' for line in fd: xmlWSDL += line fd.close() self.finish(xmlWSDL)
def get(self): """ GET method is executed when the WSDL link is called. """ # Defines the HOST i.e. address = 'localhost' if hasattr(options, 'wsdl_hostname') and type(options.wsdl_hostname) is str: address = options.wsdl_hostname else: address = getattr( self, 'targetns_address', tornado.httpserver.socket.gethostbyname( tornado.httpserver.socket.gethostname())) # Defines the PORT i.e. port = '8887' port = 80 if len(self.request.headers['Host'].split(':')) >= 2: port = self.request.headers['Host'].split(':')[1] # Defines the NAMESERVICE i.e. wsdl_nameservice = 'tim/v1/recharge' wsdl_nameservice = self.request.uri[1:].replace('?wsdl', '').replace( '?WSDL', '') wsdl_input = None wsdl_output = None wsdl_operation = None wsdl_args = None wsdl_methods = [] # Iterates over all methods of the current Handler for operations in dir(self): operation = getattr(self, operations) if callable(operation) and hasattr(operation, '_input') and hasattr(operation, '_output') and hasattr( operation, '_operation') \ and hasattr(operation, '_args') and hasattr(operation, '_is_operation'): wsdl_input = getattr(operation, '_input') wsdl_output = getattr(operation, '_output') wsdl_operation = getattr(operation, '_operation') wsdl_args = getattr(operation, '_args') wsdl_data = { 'args': wsdl_args, 'input': ('params', wsdl_input), 'output': ('returns', wsdl_output), 'operation': wsdl_operation } wsdl_methods.append(wsdl_data) # Target Namespace wsdl_targetns = 'http://%s:%s/%s' % (address, port, wsdl_nameservice) wsdl_location = 'http://%s:%s/%s' % (address, port, wsdl_nameservice) # Content-Type self.set_header('Content-Type', 'application/xml; charset=UTF-8') # QueryString (?wsdl) query = self.request.query if query.upper() == 'WSDL': # Normally goes here if wsdl_path == None: # Makes the WSDL XML wsdlfile = tornadowsdl.Wsdl(nameservice=wsdl_nameservice, targetNamespace=wsdl_targetns, methods=wsdl_methods, location=wsdl_location) self.finish(wsdlfile.createWsdl().toxml()) else: fd = open(str(wsdl_path), 'r') xmlWSDL = '' for line in fd: xmlWSDL += line fd.close() self.finish(xmlWSDL)