def __decode_soap_request(self, http_env, http_payload): """ Decode http payload using information in the http header """ # 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' http_payload = collapse_swa(content_type, http_payload) # deserialize the body of the message req_payload, req_header = from_soap(http_payload, charset) return req_header, req_payload
def __decode_soap_request(self, http_env, http_payload): """ Decode http payload using information in the http header """ # 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' http_payload = collapse_swa(content_type, http_payload) # deserialize the body of the message req_payload, req_header = from_soap(http_payload, charset) return req_header, req_payload
def parseSoapRequest(request): # Test if this is a SOAP request. SOAP 1.1 specifies special # header, SOAP 1.2 special Content-Type soapAction = request.headers["SOAPAction"]; import cgi contentType = cgi.parse_header(request.headers["Content-Type"]); if (not soapAction and contentType[0] != "application/soap+xml"): return # Get body data of request body = request.body.read() # Use soaplib to separate header and payload charset = contentType[1].get('charset',None) if charset is None: charset = 'utf-8' payload, soapheader = from_soap(body, charset) from cocy.soaplib.soap import collapse_swa payload = collapse_swa(contentType, payload) if payload is not None: soapAction = payload.tag return soapAction, soapheader, payload