diff --git a/pytrustnfe/client.py b/pytrustnfe/client.py index 30047d1..03adbd2 100644 --- a/pytrustnfe/client.py +++ b/pytrustnfe/client.py @@ -42,14 +42,20 @@ class HttpClient(object): self.cert_path = cert_path self.key_path = key_path - def _headers(self, action): + def _headers(self, action, send_raw): + if send_raw: + return { + 'Content-type': 'text/xml; charset=utf-8; action="http://www.portalfiscal.inf.br/nfe/wsdl/%s"' % action, + 'Accept': 'application/soap+xml; charset=utf-8', + } + return { 'Content-type': 'application/soap+xml; charset=utf-8; action="http://www.portalfiscal.inf.br/nfe/wsdl/%s"' % action, 'Accept': 'application/soap+xml; charset=utf-8', } - def post_soap(self, xml_soap, cabecalho): - header = self._headers(cabecalho.soap_action) + def post_soap(self, xml_soap, cabecalho, send_raw): + header = self._headers(cabecalho.soap_action, send_raw) urllib3.disable_warnings(category=InsecureRequestWarning) res = requests.post(self.url, data=xml_soap, cert=(self.cert_path, self.key_path), diff --git a/pytrustnfe/nfe/comunicacao.py b/pytrustnfe/nfe/comunicacao.py index 08a7a6a..df6ba53 100644 --- a/pytrustnfe/nfe/comunicacao.py +++ b/pytrustnfe/nfe/comunicacao.py @@ -30,5 +30,5 @@ def executar_consulta(certificado, url, cabecalho, xmlEnviar, send_raw=False): if send_raw: xml = '' + xmlEnviar.rstrip('\n') xml_enviar = xml - xml_retorno = client.post_soap(xml_enviar, cabecalho) + xml_retorno = client.post_soap(xml_enviar, cabecalho, send_raw) return sanitize_response(xml_retorno.encode())