def getOperationName(self, ps, action): '''Returns operation name. action -- soapAction value ''' method = self.root.get(_get_element_nsuri_name(ps.body_root)) or \ self.soapAction.get(action) if method is None: raise UnknownRequestException( 'failed to map request to a method: action(%s), root%s' % (action, _get_element_nsuri_name(ps.body_root))) return method
def getOperationName(self, ps, action): '''Returns operation name. action -- soapAction value ''' method = self.root.get(_get_element_nsuri_name(ps.body_root)) or \ self.soapAction.get(action) if method is None: raise UnknownRequestException( 'failed to map request to a method: action(%s), root%s' %(action,_get_element_nsuri_name(ps.body_root))) return method
def processRequest(cls, ps, **kw): """invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request """ resource = kw['resource'] request = kw['request'] method = getattr(resource, 'wsa_%s' % _get_element_nsuri_name(ps.body_root)[-1]) # TODO: grab ps.address, clean this up. try: req_pyobj, rsp_pyobj = method(ps, ps.address, request=request) except TypeError as ex: log.err( 'ERROR: service %s is broken, method MUST return request, response'\ %self.__class__.__name__ ) raise except Exception as ex: log.err('failure when calling bound method') raise return rsp_pyobj
def processRequest(self, ps, **kw): # TODO: Clean this up resource = kw['resource'] d = getattr(resource, 'root', None) key = _get_element_nsuri_name(ps.body_root) if d is None or (key in d) is False: raise RuntimeError( 'Error looking for key(%s) in root dictionary(%s)' % (key, str(d))) self.op_name = d[key] self.address = address = Address() address.parse(ps) action = address.getAction() if not action: raise WSActionException('No WS-Action specified in Request') request = kw['request'] http_headers = request.getAllHeaders() soap_action = http_headers.get('soapaction') if soap_action and soap_action.strip('\'"') != action: raise WSActionException(\ 'SOAP Action("%s") must match WS-Action("%s") if specified.'\ %(soap_action,action) ) # Save WS-Address in ParsedSoap instance. ps.address = address return ps
def processRequest(cls, ps, **kw): """invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request """ resource = kw['resource'] request = kw['request'] root = _get_element_nsuri_name(ps.body_root) for key, method in inspect.getmembers(resource, inspect.ismethod): if (getattr(method, 'soapmethod', False) and method.root == root): break else: raise RuntimeError('Missing soap callback method for root "%s"' % root) try: req = ps.Parse(method.requesttypecode) except Exception as ex: raise try: rsp = method.responsetypecode.pyclass() except Exception as ex: raise try: req, rsp = method(req, rsp) except Exception as ex: raise return rsp
def processRequest(cls, ps, **kw): """invokes callback that should return a (request,response) tuple. representing the SOAP request and response respectively. ps -- ParsedSoap instance representing HTTP Body. request -- twisted.web.server.Request """ resource = kw['resource'] request = kw['request'] method = getattr(resource, 'soap_%s' % _get_element_nsuri_name(ps.body_root)[-1]) try: req, rsp = method(ps, request=request) except Exception as ex: raise return rsp
def getSubstitutionElement(self, elt, ps): """if elt matches a member of the head substitutionGroup, return the GED typecode representation of the member. head -- ElementDeclaration typecode, elt -- the DOM element being parsed ps -- ParsedSoap instance """ nsuri,ncname = _get_element_nsuri_name(elt) typecode = GED(nsuri,ncname) if typecode is None: return try: nsuri,ncname = typecode.substitutionGroup except (AttributeError, TypeError): return if (ncname == self.pname) and (nsuri == self.nspname or (not nsuri and not self.nspname)): return typecode return