TadaSoftware / PyNFe

Projeto de biblioteca para fazer interface com o webservice de Nota Fiscal eletrônica para Python, disponível sob LGPL.
http://groups.google.com/group/pynfe
Other
415 stars 173 forks source link

GINFES HTTP Error 405: Method Not Allowed #225

Closed AlexandreBellas closed 1 year ago

AlexandreBellas commented 1 year ago

Boa tarde, pessoal. Obtive o erro 405 Method Not Allowed ao testar consulta de lotes para o provedor ginfes. Poderiam me ajudar a entender o problema?

Usei o seguinte código:

import sys
from lxml import etree
from pynfe.processamento.comunicacao import ComunicacaoNfse
from pynfe.processamento.serializacao import SerializacaoNfse
from pynfe.processamento.assinatura import AssinaturaA1
from pynfe.entidades.emitente import Emitente
from pynfe.processamento.validacao import Validacao

# Argumentos do script
autorizador = str(sys.argv[1])
certificado = str(sys.argv[2])
senha = str(sys.argv[3])
homologacao = sys.argv[4] == "True"

# Emitente
emitente = Emitente(
    cnpj='cnpj_de_teste', # usei um CNPJ real aqui
    inscricao_municipal='1234'
)

# Configs da biblioteca
serializador = SerializacaoNfse(autorizador)
nfse = serializador.consultar_lote(emitente, '5')

validador = Validacao()

nfse_etree = etree.fromstring(nfse)

# Configuração do comunicador
con = ComunicacaoNfse(certificado, senha, autorizador, homologacao)
resposta = con.consultar(nfse)

print (resposta)

Executando, obtive o erro:

Traceback (most recent call last):
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/transport/http.py", line 82, in send
    fp = self.u2open(u2request)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/transport/http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 563, in error
    result = self._call_chain(*args)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 755, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 405: Method Not Allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/transport/http.py", line 94, in send
    raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError: Method Not Allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "baixa-nfse/teste.py", line 42, in <module>
    resposta = con.consultar(nfse)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/pynfe/processamento/comunicacao.py", line 569, in consultar
    return self._post_https(url, xml, 'consulta')
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/pynfe/processamento/comunicacao.py", line 742, in _post_https
    raise e
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/pynfe/processamento/comunicacao.py", line 724, in _post_https
    return cliente.service.ConsultarNfseV3(cabecalho, xml)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/client.py", line 581, in invoke
    result = self.send(soapenv)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "/home/forfs/.conda/envs/baixanfse/lib/python3.7/site-packages/suds/client.py", line 677, in process_reply
    raise Exception((status, description))
Exception: (405, 'Method Not Allowed')

Utilizo o python 3.7. Output das bibliotecas que possuo:

python -c 'import OpenSSL; print(OpenSSL.__version__)'          
22.0.0

python -c 'import cryptography; print(cryptography.__version__)'
38.0.1

python -c 'import requests; print(requests.__version__)'
2.28.1

Originally posted by @AlexandreBellas in https://github.com/TadaSoftware/PyNFe/issues/177#issuecomment-1270600694

juniortada commented 1 year ago

@AlexandreBellas a emissão de NFS-e está bem desatualizada. Provavelmente está com bibliotecas, links ou lista de cidades desatualizadas.

Uriel-Alves commented 1 year ago

A leitura NFS-e também apresenta o mesmo erro http 405.

Detalhe que, ao tentar instalar suds-jurko, que é necessário para uso da NFS-e, o pip retorna erro no processo:

error in suds-jurko setup command: use_2to3 is invalid.
ERROR: Could not find a version that satisfies the requirement suds-jurko (from versions: 0.4.1.jurko.1, 0.4.1.jurko.2, 0.4.1.jurko.3, 0.4.1.jurko.4, 0.4.1.jurko.5, 0.5, 0.6)
ERROR: No matching distribution found for suds-jurko

O repositório do mesmo não existe. Alguma ajuda de como podemos tentar resolver?

juniortada commented 1 year ago

A emissão de NFS-e continua desatualizada.