def parse_soap_request(self): soap = self.request.other.get('SOAPXML') or self.request['BODY'] #these are lxml etree elements payload, header = self.from_soap() ctx = soaplib.core.MethodContext() content_type = cgi.parse_header(self.request.get("CONTENT_TYPE")) charset = content_type[1].get('charset', None) if charset is None: charset = 'ascii' in_string = collapse_swa(content_type, soap) in_object = self.get_in_object(ctx, in_string, charset) return_code = HTTP_200 if ctx.in_error: out_object = ctx.in_error return_code = HTTP_500 else: assert ctx.service != None out_object = self.get_out_object(ctx, in_object) if ctx.out_error: out_object = ctx.out_error return_code = HTTP_500 out_string = self.get_out_string(ctx, out_object) http_resp_headers = { 'Content-Type': 'text/xml', 'Content-Length': '0', } if ctx.descriptor and ctx.descriptor.mtom: # when there are more than one return type, the result is # encapsulated inside a list. when there's just one, the result # is returned unencapsulated. the apply_mtom always expects the # objects to be inside an iterable, hence the following test. out_type_info = ctx.descriptor.out_message._type_info if len(out_type_info) == 1: out_object = [out_object] http_resp_headers, out_string = apply_mtom( http_resp_headers, out_string, ctx.descriptor.out_message._type_info.values(), out_object) # initiate the response http_resp_headers['Content-Length'] = str(len(out_string)) rc = RespComp(out_string, http_resp_headers, return_code) return rc
def parse_soap_request(self): soap = self.request.other.get('SOAPXML') or self.request['BODY'] #these are lxml etree elements payload, header = self.from_soap() ctx = soaplib.core.MethodContext() content_type = cgi.parse_header(self.request.get("CONTENT_TYPE")) charset = content_type[1].get('charset', None) if charset is None: charset = 'ascii' in_string = collapse_swa(content_type, soap) in_object = self.get_in_object(ctx, in_string, charset) return_code = HTTP_200 if ctx.in_error: out_object = ctx.in_error return_code = HTTP_500 else: assert ctx.service != None out_object = self.get_out_object(ctx, in_object) if ctx.out_error: out_object = ctx.out_error return_code = HTTP_500 out_string = self.get_out_string(ctx, out_object) http_resp_headers = { 'Content-Type': 'text/xml', 'Content-Length': '0', } if ctx.descriptor and ctx.descriptor.mtom: # when there are more than one return type, the result is # encapsulated inside a list. when there's just one, the result # is returned unencapsulated. the apply_mtom always expects the # objects to be inside an iterable, hence the following test. out_type_info = ctx.descriptor.out_message._type_info if len(out_type_info) == 1: out_object = [out_object] http_resp_headers, out_string = apply_mtom(http_resp_headers, out_string, ctx.descriptor.out_message._type_info.values(), out_object) # initiate the response http_resp_headers['Content-Length'] = str(len(out_string)) rc = RespComp(out_string, http_resp_headers, return_code) return rc
def _reconstruct_soap_request(http_env): """Reconstruct http payload using information in the http header """ input = http_env.get('wsgi.input') length = http_env.get("CONTENT_LENGTH") http_payload = input.read(int(length)) # fyi, here's what the parse_header function returns: # >>> import cgi; cgi.parse_header("text/xml; charset=utf-8") # ('text/xml', {'charset': 'utf-8'}) content_type = cgi.parse_header(http_env.get("CONTENT_TYPE")) charset = content_type[1].get('charset',None) if charset is None: charset = 'ascii' return collapse_swa(content_type, http_payload), charset
def _reconstruct_soap_request(http_env): """Reconstruct http payload using information in the http header """ input = http_env.get('wsgi.input') length = http_env.get("CONTENT_LENGTH") http_payload = input.read(int(length)) # fyi, here's what the parse_header function returns: # >>> import cgi; cgi.parse_header("text/xml; charset=utf-8") # ('text/xml', {'charset': 'utf-8'}) content_type = cgi.parse_header(http_env.get("CONTENT_TYPE")) charset = content_type[1].get('charset', None) if charset is None: charset = 'ascii' return collapse_swa(content_type, http_payload), charset
def index_html(self, REQUEST, RESPONSE): """Handle an incoming SOAP request or a non-SOAP WSDL query.""" if REQUEST.get('SOAPXML', None) == None: # Not a SOAP Request, return WSDL return self.service_description(REQUEST, RESPONSE) try: # Deserialize the Body of the SOAP Request from soaplib.core._base import _from_soap header, payload = _from_soap(REQUEST.SOAPXML) # TODO: At this point I need dispatch method calls to the soaplib.Application # somehow....... :) ctx = MethodContext() content_type = cgi.parse_header(REQUEST.get("Content-Type")) charset = content_type[1].get('charset', None) length = REQUEST.get("Content-Length") http_payload = REQUEST.read(int(length)) if not charset: charset = "ascii" in_string = collapse_swa(content_type, http_payload) in_obj = self.soap_handler.get_in_object(ctx, in_string, charset) out_obj = self.soap_handler.get_out_object(ctx, in_obj) out_string = self.soap_handler.get_out_string(ctx, out_obj) return out_string except Exception, e: fault = Fault(faultstring=str(e)) resp = etree.tostring(fault, encoding=string_encoding) RESPONSE.setStatus('InternalServerError', reason=faultstring) RESPONSE.setHeader('Content-Type', 'text/xml') return resp
def index_html(self, REQUEST, RESPONSE): """Handle an incoming SOAP request or a non-SOAP WSDL query.""" if REQUEST.get('SOAPXML', None) == None: # Not a SOAP Request, return WSDL return self.service_description(REQUEST, RESPONSE) try: # Deserialize the Body of the SOAP Request from soaplib.core._base import _from_soap header, payload = _from_soap(REQUEST.SOAPXML) # TODO: At this point I need dispatch method calls to the soaplib.Application # somehow....... :) ctx = MethodContext() content_type = cgi.parse_header(REQUEST.get("Content-Type")) charset = content_type[1].get('charset',None) length = REQUEST.get("Content-Length") http_payload = REQUEST.read(int(length)) if not charset: charset = "ascii" in_string = collapse_swa(content_type, http_payload) in_obj = self.soap_handler.get_in_object(ctx, in_string, charset) out_obj = self.soap_handler.get_out_object(ctx, in_obj) out_string = self.soap_handler.get_out_string(ctx, out_obj) return out_string except Exception, e: fault = Fault(faultstring=str(e)) resp = etree.tostring(fault, encoding=string_encoding) RESPONSE.setStatus('InternalServerError', reason=faultstring) RESPONSE.setHeader('Content-Type', 'text/xml') return resp
uuid = uuid_.split("\r\nContent-Type")[0] except Exception, e: pass # &ek- # fyi, here's what the parse_header function returns: # >>> import cgi; cgi.parse_header("text/xml; charset=utf-8") # ('text/xml', {'charset': 'utf-8'}) content_type = cgi.parse_header(http_env.get("CONTENT_TYPE")) charset = content_type[1].get('charset',None) if charset is None: charset = 'ascii' # uuid eklendi &ek return collapse_swa(content_type, http_payload, uuid), charset class Application(Base): transport = 'http://schemas.xmlsoap.org/soap/http' def __call__(self, req_env, start_response, wsgi_url=None): '''This method conforms to the WSGI spec for callable wsgi applications (PEP 333). It looks in environ['wsgi.input'] for a fully formed soap request envelope, will deserialize the request parameters and call the method on the object returned by the get_handler() method. @param the http environment @param a callable that begins the response message @param the optional url @returns the string representation of the soap call '''