samuel-oliveira / java_nfe Goto Github PK
View Code? Open in Web Editor NEWProjeto Open Source Java - NFe, NFce
License: MIT License
Projeto Open Source Java - NFe, NFce
License: MIT License
Alguns WebService não tem disponibilidade de modo Sincrono para serviços como o NFC-e.
Criar função no sistema para consulta de protocolo no modo Assincrono.
Existem cenários (Sistemas Web) em que o certificado digital não está na maquina local, e sim no cliente.
O objetivo desta função é buscar formas de receber o certificado digital de outras maneiras.
NfeStatusServico_4.00=https://nfce.sefazrs.rs.gov.br/ws/NfeStatusServico/NfeStatusServico4.asmx
NfeAutorizacao_4.00=https://nfce.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx
RecepcaoEvento_4.00=https://nfce.sefazrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx
NfeConsultaProtocolo_4.00=https://nfce.sefazrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx
NfeInutilizacao_4.00=https://nfce.sefazrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx
Homologação
NFeAutorizacao 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/NfeAutorizacao4
NFeRetAutorizacao 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/NfeRetAutorizacao4
NfeInutilizacao 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/NfeInutilizacao4
NfeConsultaProtocolo 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/NfeConsulta4
NfeStatusServico 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/NfeStatusServico4
RecepcaoEvento 4.00 https://homologacao.sefaz.mt.gov.br/nfcews/v2/services/RecepcaoEvento4
Produção
NFeAutorizacao 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/NfeAutorizacao4
NFeRetAutorizacao 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/NfeRetAutorizacao4
NfeInutilizacao 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/NfeInutilizacao4
NfeConsultaProtocolo 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/NfeConsulta4
NfeStatusServico 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/NfeStatusServico4
RecepcaoEvento 4.00 https://nfce.sefaz.mt.gov.br/nfcews/v2/services/RecepcaoEvento4
Samuel!
Nao estou encontrando jeito de usar esse parametro id do exemplo de inutilizacao.
Por exemplo, seu eu quiser inutilizar do numero 3 até o 19 da serie 4 do modelo 65 de uma empresa, como devo especificar o id para submeter?
Tentei de tudo que foi jeito aqui (menos o certo, aparentemente, kkkk)!
Não inicia Configuração ao Enviar evento!
O WebService da Bahia está usando um Stub Diferente de todos os estados.
Deve serve gerando um Stub Diferente para os serviços :
Adicionar funções e validações pra compatibilidade com NFc-e;
Olá, eu estou realizando alguns testes e coloquei a pasta do projeto em um caminho com acento e Ç:
"D:\Downloads\Teste Instalação\glassfish5\"
O projeto funciona normalmente em um caminho sem espaço e sem esses caracteres, como por exemplo:
"D:\Downloads\TesteInstalacao\glassfish5\"
Mas no caminho com estes caracteres especiais ele ocasiona o seguinte erro:
Erro Na Validação do Xml: schema_reference.4: Falha ao ler o documento do esquema '/D:/Downloads/Teste Instalação/glassfish5/glassfish/domains/domain1/applications/meuprojeto/WEB-INF/classes/Schemas/enviNFe_v3.10.xsd' porque 1) não foi possível encontrar o documento; 2) não foi possível ler o documento; 3) o elemento-raiz do documento não é . cvc-elt.1: Não pode localizar a declaração do elemento 'enviNFe'.
Eu depurei o código e acredito que o erro esteja acontecendo ao executar a seguinte linha de código:
ConfiguracoesIniciaisNfe.iniciaConfiguracoes(estado, ambiente,
certificado, getPathSchemas(), ConstantesUtil.VERSAO.V3_10);
Alguém sabe dizer o que estou fazendo de errado?
Se adicionar CONSUMO_INDEVIDO("656") em StatusEnum.java.
Obrigado!
O QrCode NO XML Final vem sem CDATA e sem &.
Adicionar endereços de WebServices exclusivos para NFc-e
Estou tentando gerar o NFC-e mas tenho duvida sobre alguns parâmetros. Estou tentando, mas sigo recebendo a mensagem "Rejeicao: Falha no Schema XML do lote de NFe"
========================================
// Inicia As Configurações
ConfiguracoesIniciaisNfe config = iniciaConfigurações();
TNFe nfe = new TNFe();
InfNFe infNFe = new InfNFe();
// Substitua X Pelo ID
infNFe.setId(xxxxxxxxxxxxx); <<<<====== COMO GERO ISSO?
infNFe.setVersao(config.getVersaoNfe());
Ide ide = new Ide();
ide.setCUF(config.getEstado().getCodigoIbge());
// Substitua X Pelo CNF
ide.setCNF(xxxx); <<<<====== COMO GERO ISSO?
ide.setNatOp("NOTA FISCAL CONSUMIDOR ELETRONICA");
ide.setIndPag("0");
ide.setMod("65");
ide.setSerie("1");
// Substitua X Pelos Valores Desejados
ide.setNNF(xxxxx); <<<<====== COMO GERO ISSO?
ide.setDhEmi(xxxxxxxx);
ide.setTpNF("1");
ide.setIdDest("1");
ide.setCMunFG(xxxxxx);
ide.setTpImp("4");
ide.setTpEmis("1");
ide.setCDV(xxxxx);
ide.setTpAmb(config.getAmbiente());
ide.setFinNFe("1");
ide.setIndFinal("1");
ide.setIndPres("1");
ide.setProcEmi("0");
ide.setVerProc(xxx);
infNFe.setIde(ide);
O erro acontece ao tentar Manifestar a Nfe, sem fazer a validação.
Sugiro adicionar transformar o Objeto em XML(String) do retorno da consulta da situação da NFe
Ex.:
private static final String SITUACAO_NFE_RET = "TRetConsSitNFe";
...
public static String objectToXml(Object obj) throws JAXBException, NfeException {
...
case SITUACAO_NFE_RET:
context = JAXBContext.newInstance(TRetConsSitNFe.class);
element = new br.inf.portalfiscal.nfe.schema_4.retConsSitNFe.ObjectFactory().createRetConsSitNFe((TRetConsSitNFe) obj);
break;
..
Adicionar!
Boa noite,
Algum motivo específico para não incluir os schemas na biblioteca como resource?
Obrigado,
Bruno
Samuel,
atualizei pra versao 4 da tua biblioteca, fiz os acertos e as notas estao funcionando aqui para o DF. Todavia, quando tento utilizar em um cliente do RS, recebo a mensagem
WebService de NfeAutorizacao_4.00 não encontrado para Rio Grande do Sul
Já atualizei a pasta Schemas, mas o erro persiste.
O que pode estar ocorrendo?
URL NFCE NFeAutorizacao4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/NfeAutorizacao4";
URL NFCE NFeRetAutorizacao4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/NfeRetAutorizacao4";
URL NFCE NFeInutilizacao4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/NfeInutilizacao4";
URL NFCE NFeConsultaProtocolo4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/NfeConsulta4";
URL NFCE NFeStatusServico4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/NfeStatusServico4";
URL NFCE NFeRecepcaoEvento4 : "https://homologacao.sefaz.mt.gov.br/nfcews/services/RecepcaoEvento4";
// Envia a Nfe para a Sefaz
TRetEnviNFe retorno = Nfe.enviarNfe(enviNFe, ConstantesUtil.NFE);
//transformar o retorno em xml
// isso aqui não funciona pois o TRetEnviNFe é do pacote:
// br.inf.portalfiscal.nfe.schema_4.enviNFe.TRetEnviNFe;
// sendo que para poder gerar o xml, esse retorno deveria ser do pacote:
// br.inf.portalfiscal.nfe.schema_4.retEnviNFe.TRetEnviNFe;
String xmlRetorno = XmlUtil.ObjectToXml(retorno);
É possível setar um timeout personalizado de espera do retorno da manifestação?
Não baixa pelo repositório do maven:
Missing artifact br.com.samuelweb:java-nfe:jar:3.10.8
A classe CertificadoUtil.java está diferente da classe na Branch_3.10.8
Erro especifico da Sefaz de PE, referente ao cabeçalho SOAP:
Cod: 409
Rejeição: Campo cUF inexistente no elemento nfeCabecMsg do SOAP Header
WebService - https://nfe.sefaz.ba.gov.br/webservices/NfeConsulta/NfeConsulta.asmx
Erro:Transport error: 403 Error: Forbidden
fev 09, 2017 9:27:53 PM org.apache.axis2.transport.http.HTTPSender sendViaPost
INFORMAÇÕES: Unable to sendViaPost to url[https://nfe.sefaz.ba.gov.br/webservices/NfeConsulta/NfeConsulta.asmx]
org.apache.axis2.AxisFault: Transport error: 403 Error: Forbidden
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at br.inf.portalfiscal.www.nfe.wsdl.NfeConsulta2.NfeConsulta2Stub.nfeConsultaNF2(NfeConsulta2Stub.java:197)
at br.com.samuelweb.nfe.ConsultaXml.consultaXml(ConsultaXml.java:83)
at br.com.samuelweb.nfe.Nfe.consultaXml(Nfe.java:58)
at leech.JNFe.myButton3ActionPerformed(JNFe.java:174)
at leech.JNFe.access$200(JNFe.java:31)
at leech.JNFe$3.actionPerformed(JNFe.java:73)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Adicionar endereços para O Modo de Contigencia SCAN.
Adicionar Endereços:
[NFCe_ES_P]
Usar=NFCe_SVRS_P
URL-QRCode=http://app.sefaz.es.gov.br/ConsultaNFCe/QRCode.aspx
URL-ConsultaNFCe=http://app.sefaz.es.gov.br/ConsultaNFCe
[NFCe_ES_H]
Usar=NFCe_SVRS_H
URL-QRCode=http://homologacao.sefaz.es.gov.br/ConsultaNFCe/qrcode.aspx
URL-ConsultaNFCe=http://app.sefaz.es.gov.br/ConsultaNFCe
Resolver problema de compatibilidade de leitura de certificados digitais no sistema operacional Linux.
Motivo : Rejeicao: Cabecalho - Versao do arquivo XML nao suportada
Fazer a atualização dos Cacerts pois o WebService de MS deixou de Comunicar.
Bom dia,
Já está disponível a versão 3.00 da manifestação do destinatário?
Estou conseguindo gerar, assinar e transmitir uma NFE (modelo 55), mas na hora de gerar o qrCode dela, recebo a mensagem "WebService de URL-QRCode não encontrado para Rio Grande do Sul".
`String qrCodeChaveSemNfe = infNFe.getId().substring(3);
String qrCodeVersao = "100";
String qrCodeAmbiente = config.getAmbiente();
String qrCodeCpfCnpj = (dest!=null?Ferramentas.apenasNumeros(dest.getCNPJ() == null ? dest.getCPF() : dest.getCNPJ()):"");
String qrCodeDtEmissao = ide.getDhEmi();
String qrCodeVnf = total.getICMSTot().getVNF();
String qrCodeVicms = total.getICMSTot().getVICMS();
String qrCodeBase64 = Base64.getEncoder().encodeToString(enviNFe.getNFe().get(0).getSignature().getSignedInfo().getReference().getDigestValue());
String qrCode = NFCeUtil.getCodeQRCode(
qrCodeChaveSemNfe,
qrCodeVersao,
qrCodeAmbiente,
qrCodeCpfCnpj,
qrCodeDtEmissao,
qrCodeVnf,
qrCodeVicms,
qrCodeBase64,
idToken,
csc,
getUrl(ConstantesUtil.NFE, ConstantesUtil.SERVICOS.URL_QRCODE)); `
Interessante é que quando, no "getURL", seleciono ConstantesUtil.NFC dá tudo certo e sem erros.
O WebService SVRS (Exclusivamente ele, os outros estão funcionais), não aceita alguns nameSpaces que são adicionados ao converter um Objeto para XML.
Adicionar função que remove Acentos no XML antes de assinar a Nota.
Atualizar Lib para Pegar o Novo WebService de NFeDistribuicaoDFe. E adicionar download de Nfe Por Chave.
Como criar o objeto evento cancelar?
Na versão 4.00.0e tinha o método:
Nfe.criaObjetoCancelarNfe
Já na versão 4.00.2 o método:
Cancelar.criaEventoCancelamento não existe mais.
O mesmo ocorre com o método:
Nfe.criaObjetoCartaCorrecaoNfe.
Era mais pratico quando a classe era a como a anterior:
`package br.com.samuelweb.nfe;
import br.com.samuelweb.nfe.dom.ConfiguracoesIniciaisNfe;
import br.com.samuelweb.nfe.exception.NfeException;
import br.com.samuelweb.nfe.util.CertificadoUtil;
import br.com.samuelweb.nfe.util.ConstantesUtil;
import br.com.samuelweb.nfe.util.XmlUtil;
import br.inf.portalfiscal.nfe.schema.envEventoCancNFe.TEnvEvento;
import br.inf.portalfiscal.nfe.schema.envEventoCancNFe.TEvento;
import br.inf.portalfiscal.nfe.schema.envEventoCancNFe.TRetEnvEvento;
import javax.xml.bind.JAXBException;
/**
@author Samuel Oliveira - [email protected]
Data: 28/09/2017 - 11:11
*/
class Cancelar {
static TEnvEvento criaEventoCancelamento(String chave, String protocolo, String cnpj, String data,String motivo) throws NfeException {
ConfiguracoesIniciaisNfe configuracoesNfe = CertificadoUtil.iniciaConfiguracoes();
String id = "ID"+ ConstantesUtil.EVENTO.CANCELAR + chave + "01";
TEnvEvento enviEvento = new TEnvEvento();
enviEvento.setVersao(ConstantesUtil.VERSAO.EVENTO_CANCELAMENTO);
enviEvento.setIdLote("1");
TEvento eventoCancela = new TEvento();
eventoCancela.setVersao(ConstantesUtil.VERSAO.EVENTO_CANCELAMENTO);
TEvento.InfEvento infoEvento = new TEvento.InfEvento();
infoEvento.setId(id);
infoEvento.setChNFe(chave);
infoEvento.setCOrgao(String.valueOf(configuracoesNfe.getEstado().getCodigoIbge()));
infoEvento.setTpAmb(configuracoesNfe.getAmbiente());
infoEvento.setCNPJ(cnpj);
infoEvento.setDhEvento(data);
infoEvento.setTpEvento(ConstantesUtil.EVENTO.CANCELAR);
infoEvento.setNSeqEvento("1");
infoEvento.setVerEvento(ConstantesUtil.VERSAO.EVENTO_CANCELAMENTO);
TEvento.InfEvento.DetEvento detEvento = new TEvento.InfEvento.DetEvento();
detEvento.setVersao(ConstantesUtil.VERSAO.EVENTO_CANCELAMENTO);
detEvento.setDescEvento("Cancelamento");
detEvento.setNProt(protocolo);
detEvento.setXJust(motivo);
infoEvento.setDetEvento(detEvento);
eventoCancela.setInfEvento(infoEvento);
enviEvento.getEvento().add(eventoCancela);
return enviEvento;
}
static TRetEnvEvento eventoCancelamento(TEnvEvento enviEvento, boolean valida, String tipo) throws NfeException {
try {
String xml = XmlUtil.objectToXml(enviEvento);
xml = xml.replaceAll(" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\"", "");
xml = xml.replaceAll("<evento v", "<evento xmlns=\"http://www.portalfiscal.inf.br/nfe\" v");
xml = Eventos.enviarEvento(xml,ConstantesUtil.EVENTO.CANCELAR,valida, tipo);
return XmlUtil.xmlToObject(xml, TRetEnvEvento.class);
} catch (JAXBException e) {
throw new NfeException(e.getMessage());
}
}
}
`
Sistema gera um null point ao tentar ler informações de certificado digital A3, onde o card ou o token não está inserido.
Modificar logica de Replace dos lixos (ns2,ns3) vindos da Conversão do JAXB.
Manifestação com Codigo de ID Duplicado
Adicionar Proxy as Configurações do Projeto.
Caso não seja tipo OPERACAO_NAO_REALIZADA, desconsiderar parametro Justificativa.
Como faço para transformar o enviNFe em nfeProc para impressão da contingência?
Apos concluído o envio da NFC-e, ao gerar o ProcNfe para armazenar o xml, o conteúdo do campo QrCode volta vazio.
Olá!
Primeiro lugar, parabéns pelo projeto! Queria saber se existe alguma facilidade nesse projeto para, a partir de um XML, gerar o DANFe da nota. Dei uma procurada mas não encontrei.
Olá,
Estão faltando os métodos: listaCertificadosWindows() e certificadoPfx() na classe CertificadoUtil
De modo que não consigo configurar a API como orienta o wiki: https://github.com/Samuel-Oliveira/Java_NFe/wiki/01-:-Configuracoes
Att
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.