Browse Source

[FIX] Corrige consulta de distribuíção de NF-e

pull/71/head
Fábio Luna 8 years ago
committed by Danimar Ribeiro
parent
commit
582742ecca
  1. 12
      pytrustnfe/client.py
  2. 2
      pytrustnfe/nfe/comunicacao.py

12
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),

2
pytrustnfe/nfe/comunicacao.py

@ -30,5 +30,5 @@ def executar_consulta(certificado, url, cabecalho, xmlEnviar, send_raw=False):
if send_raw:
xml = '<?xml version="1.0" encoding="utf-8"?>' + 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())
Loading…
Cancel
Save