diff --git a/src/erpbrasil/edoc/resposta.py b/src/erpbrasil/edoc/resposta.py index 8acca86..abac408 100644 --- a/src/erpbrasil/edoc/resposta.py +++ b/src/erpbrasil/edoc/resposta.py @@ -6,6 +6,9 @@ from lxml import etree +combined_pattern = re.compile( + r"(.*?)|<[a-zA-Z0-9:]*Body[^>]*>(.*?)" +) class RetornoSoap: def __init__(self, webservice, raiz, xml, retorno, resposta): @@ -15,13 +18,11 @@ def __init__(self, webservice, raiz, xml, retorno, resposta): self.resposta = resposta self.retorno = retorno - def analisar_retorno_raw(operacao, raiz, xml, retorno, classe): retorno.raise_for_status() - pattern = r"<[a-zA-Z0-9:]Body.?>(.*?)" - match = re.search(pattern, retorno.text.replace("\n", "")) + match = re.search(combined_pattern, retorno.text.replace("\n", "")) if match: - xml_resposta = match.group(1) + xml_resposta = match.group(1) or match.group(2) xml_etree = etree.fromstring(xml_resposta) resultado = xml_etree[0]