Nfe - Nota Fiscal Eletronica

O Visualizado so abre o arquivo de distribuição da NFe (procNFe se não me engano), se tentar abrir o arquivo de envio (enviNFe) ele dá este erro.

Estou tentando fazer a consulta do status versao 2.0 porem não estou obtendo sucesso …

[code] String XML = “<?xml version=\"1.0\" encoding=\"utf-8\"?>”
+ “<soap12:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance””
+ "xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">"
+ “soap12:Header
+ "<sceCabecMsg xmlns="http://www.portalfiscal.inf.br/sce/wsdl/SCERecepcaoRFB">"
+ “2.00”
+ “53”
+ “”
+ “</soap12:Header>”
+ “soap12:Body
+ "<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2">"
+ “<consStatServ xmlns=“http://www.portalfiscal.inf.br/nfe” versao=“2.00”>”
+ “2”
+ “53”
+ “STATUS”
+ “”
+ “”
+ “</soap12:Body>”
+ “</soap12:Envelope>”;

    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
    System.setProperty("javax.net.ssl.keyStore", "C:\\keystore\\nfe.p12");
    System.setProperty("javax.net.ssl.keyStorePassword", "123");

    System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    System.setProperty("javax.net.ssl.trustStore", "C:\\keystore\\rs.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "123456");
     
   NfeStatusServico2 service = new NfeStatusServico2();
   NfeDadosMsg nfeDadosMsg = new NfeDadosMsg();
   nfeDadosMsg.getContent().add(XML);

    try {
NfeStatusServico2Soap12 nfeStatus = service.getNfeStatusServico2Soap12();              
            System.out.println(nfeStatus.nfeStatusServicoNF2(nfeDadosMsg));
    } catch (Throwable e1) {
            e1.printStackTrace();
    }[/code]

da a seguinte exceção:
javax.xml.ws.soap.SOAPFaultException: Server was unable to read request. —> There is an error in XML document (1, 1063). —> The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.
at com.sun.xml.internal.ws.fault.SOAP12Fault.getProtocolException(SOAP12Fault.java:175)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy30.nfeStatusServicoNF2(Unknown Source)

    estou meio perdido alguém poderia me dizer o que estou fazendo de errado e se possivel postar um exemplo?

galera utilizando o axis2 as classes geradas a partir dos wsdl sao essas, mas vendo aki no forum as q vii sao outras, minha duvia eh: tenho q utilizar o axis1 em vez de axis2??

NfeStatusServicoNF2Result.java
NfeStatusServico2Skeleton.java
NfeStatusServico2MessageReceiverInOut.java
NfeDadosMsg.java
NfeCabecMsg0.java
NfeCabecMsg.java
ExtensionMapper.java

[quote=fafb]galera utilizando o axis2 as classes geradas a partir dos wsdl sao essas, mas vendo aki no forum as q vii sao outras, minha duvia eh: tenho q utilizar o axis1 em vez de axis2??

NfeStatusServicoNF2Result.java
NfeStatusServico2Skeleton.java
NfeStatusServico2MessageReceiverInOut.java
NfeDadosMsg.java
NfeCabecMsg0.java
NfeCabecMsg.java
ExtensionMapper.java
[/quote]

Eu utilizo o Axis2 para gerar as classes, funciona normal, mas o nome da segunda e da terceira estão estranhos

Alguém ja fez a integração com o sistema de NFS-e da prefeitura de SP?

Estou enfrentando um problema que é justamente na parte da assinatura do XML, pois os xml’s de consulta não tem ID para usar para assinar o XML, alguém sabe como proceder?

Tenho o seguinte XML:

<?xml version="1.0" encoding="UTF-8"?>

<p1:PedidoConsultaNFePeriodo xmlns:p1=“http://www.prefeitura.sp.gov.br/nfe” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>


04642554000143


04642554000143

31000000
2007-01-01
2007-01-31
1

</p1:PedidoConsultaNFePeriodo>

E o mesmo deve ficar assim:

<?xml version="1.0" encoding="UTF-8"?>

<p1:PedidoConsultaNFePeriodo xmlns:p1=“http://www.prefeitura.sp.gov.br/nfe” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>


04642554000143


04642554000143

31000000
2007-01-01
2007-01-31
1











MLNPmnDg+TdeC9jdIp0ldJOVQGI=


VWCYdIxH+IXmlCuNcYy/Z8CN/fDWs/koDaezE2T942WY1YWJMG7p4OvUDR2uwZlUIwZxqKvtY9CRaa15kMlbyPiQ5gd95qUHObHp8gLEYQhOq7PFq9hL6dehVyxibbWlPMTpGp2EtHob8Xo7X81XwEVu1zJIMwaFc6N5F6A8xQQ=


MIIFUzCCBDugAwIBAgIQSUJS8pELZyjasDkgGzKm0TANBgkqhkiG9w0BAQUFADBuMQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDEsMCoGA1UECxMjU2VjcmV0YXJpYSBkYSBSZWNlaXRhIEZlZGVyYWwgLSBTUkYxHDAaBgNVBAMTE0FDIENlcnRpU2lnbiBTUkYgVjMwHhcNMDYwNzE5MDAwMDAwWhcNMDkwNzE4MjM1OTU5WjCB1DELMAkGA1UEBhMCQlIxEzARBgNVBAoUCklDUC1CcmFzaWwxKjAoBgNVBAsTIVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsLVNSRjETMBEGA1UECxQKU1JGIGUtQ05QSjELMAkGA1UECBMCUkoxFzAVBgNVBAcUDlJJTyBERSBKQU5FSVJPMUkwRwYDVQQDE0BUSVBMQU4gQ09OU1VMVE9SSUEgRSBTRVJWSUNPUyBFTSBJTkZPUk1BVElDQSBMVERBOjA0NjQyNTU0MDAwMTQzMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx86LAoJRVmtQMzmtdWpyNgKy200+bwjtz/TuywNcTjvfw7qHFGIgTjipmuZ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BwxxgGNuIyqirgGXW0by4Io1GnSXtixxfvEOnqOicxBY6AcVS9HHuhmOBYiK9skAUp0Sm2v41hpsC8uIkfUeRxsJIp2CNZ4DjoyfmKwNLMCRZQAKpwMXyyHZlX1a4o/9iGTszNeeShw61g=



</p1:PedidoConsultaNFePeriodo>

Se alguém souber, na documentação só diz para se basear pelo xmldsig-core-schema_v01.xsd que não trás detalhes algum de como fazer.

[ ]'s
Giuseppe Lopes

Se o manual não indica nenhuma Id em específico, ou vc cria uma ID e indica ele no método de assinatura, ou fornece uma string vazia ("").

Nos 3 padrões que desenvolvemos (Nota Control, DSF e Abrasf) não haviam Id, mas era necessário seguir o procedimento que mencionei acima, de outra forma a assinatura não era validada.

zoren, qual a versao do seu Axis2?? a minha eh a axis2 - 1.5.1!

Usa -Dsun.security.ssl.allowUnsafeRenegotiation=true para iniciar

Achei ai:

salve galera

alguem ja consegue importar uma NFe - versão 2.0 no programa Emissor de Nfe do governo , para mim esta dando erro de versão invalida 2.0

Tem como setar em variavel de ambiente o parametro
-Dsun.security.ssl.allowUnsafeRenegotiation=true ?

Alencar

Alguem pode me dar um help…

Qual os campos obrigatórios ao preenchimento de uma NFe?
Obrigado

Voce deve olhar no manual, la onde define as tags, tem uma coluna “Ocorrência”.
Se o valor estiver 1-1 ou 1-N, é obrigatória.
Se estiver 0-1, não é obrigatória.

Alencar

[quote=philler]Voce deve olhar no manual, la onde define as tags, tem uma coluna “Ocorrência”.
Se o valor estiver 1-1 ou 1-N, é obrigatória.
Se estiver 0-1, não é obrigatória.

Alencar[/quote]

Saberia me dizer em qual página encontro isso?
Sinceramente, entender e ler aquele manual é uma complicação ( u.Û )

Obrigado…
Att. Jonas

Outra coisa, como eu sei qual o layout que devo me basear?

Tem uns 2 manual de integração lá… com schemas diferentes…
O schema é o Schema XML: nfe_v99.99.xsd
para layout da NFe ?

Ou eu devo usar nfe_v1.10.xsd ??

Você deve ver nas primeiras páginas, os layouts e suas datas.
Por exemplo: o layout 1.10 é válido até 30/09/2010.

Mas sugiro já partir pro desenvolvimento do novo layout 2.00

Alencar

Pergunta sobre utilização do AXIS SSL para se comunicar com o SEFAZ…

eu preciso utilizar o System.setProperty para configurar os certificados para o axis assim:

 System.setProperty("javax.net.ssl.keyStoreType",pkcs);  
             System.setProperty("javax.net.ssl.keyStorePassword", certificadoSenha);  
             System.setProperty("javax.net.ssl.trustStoreType","JKS");  
             System.setProperty("javax.net.ssl.trustStore","C:/TSCerts");  
             System.setProperty("javax.net.ssl.trustStorePassword", "123456");

O meu sistema roda em um escritorio de contabilidade é multi-thread enviando notas de diversas empresas ao mesmo tempo, como eu faço???

Alguem sabe se tem como configurar essas properties para o SSL sem ser via System.property?

Valeu

[quote=guilherme_ha]Estranho, fiz pelo wizard e tbm deu certo…
olha so como fiz:

        String[] aUrl = {"homologacao.sefaz.mt.gov.br","/nfews/NfeStatusServico2"};
        String sUf = "51"; // MT ok

       /* conecao segura */
            
            NfeStatusServico2Stub nfe = new NfeStatusServico2Stub("https://" + aUrl[0] + aUrl[1]);
            
            NfeCabecMsgE nfeCabecMsg1 = new NfeCabecMsgE();
            NfeCabecMsg param = new NfeCabecMsg();
            
            param.setCUF(sUf);
            param.setVersaoDados("2.00");
            nfeCabecMsg1.setNfeCabecMsg(param);
             
            OMElement ome = AXIOMUtil.stringToOM(
            		"&lt;consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"2.00\"&gt;" + 
                    "   &lt;tpAmb&gt;2&lt;/tpAmb&gt;" +
                    "   &lt;cUF&gt;" + sUf + "&lt;/cUF&gt;" +
                    "   &lt;xServ&gt;STATUS&lt;/xServ&gt;" +
                    "&lt;/consStatServ&gt;");  
           
            NfeDadosMsg nf2 = new NfeDadosMsg();
            nf2.setExtraElement(ome);
            
            NfeStatusServicoNF2Result resp = nfe.nfeStatusServicoNF2(nf2, nfeCabecMsg1);
            System.out.println("Resposta : \n" + resp.getExtraElement().toString()); 

Tente isso… abraco[/quote]

show de bola mano! já tinha um esquema para a NFe antiga atraves do AXIS … tava pelejando pra fazer igual na 2.0 mas nao funfava nem a pau … olhando teu exemplo… putz funfou na hora … vlw d + !

Saudações galera!

é o seguinte, ja li essa thead inteira e não resolvi meu problema
quando tento conecta ao serviços da receita, minha conexão é recusada
erro 403

utilizando o SmartCard eu não conseguia acessar diretamente a pagina do WSDL
por exemplo https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx?WSDL
após instalar no browser os certificados ACCAIXA.cer, ACCAIXAPJ.cer, ACCAIXAPF.cer e acraiz.cer
que estão disponiveis em https://icp.caixa.gov.br/asp/certificados.asp
o IE passou a se conectar normalmente à pagina do wsdl, o que demonstra que o SmartCard esta OK (lista os aliases e solicita o PIN)
e em seguida conecta

para o meu código, gerei o JKS com os certificados que mencionei acima
mais os obtidos no site homologacao.nfe.sefazvirtual.rs.gov.br, utilizando o programa InstallCert.java da Sun

mesmo com todos esses procedimentos gera a seguinte exeption

Mensagem de Erro:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx?WSDL
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(HttpsURLConnectionOldImpl.java:204)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)

segue o meu codigo

        String tokenConfigFile = "/Users/Robson/Documents/Trabalho/Lethus/nfe/certificado/token.cfg";
        String certsConfigFile = "/Users/Robson/Documents/Trabalho/Lethus/nfe/certificado/caixa/jssecacerts";
        String password = "password";

        System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        System.setProperty("javax.net.debug", "all");
        System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");

        KeyStore pks;
        Provider p = new SunPKCS11(tokenConfigFile);
        Security.addProvider(p);
        char[] pin = password.toCharArray();
        Security.addProvider(new sun.security.pkcs11.SunPKCS11(tokenConfigFile));
        System.setProperty("javax.net.ssl.keyStore", "NONE");
        System.setProperty("javax.net.ssl.keyStoreProvider", "SunPKCS11-smartCard");
        System.setProperty("javax.net.ssl.keyStoreType", "pkcs11");
        pks = KeyStore.getInstance("pkcs11");
        pks.load(null, pin);

        System.setProperty("javax.net.ssl.keyStorePassword", password);
        System.setProperty("javax.net.ssl.trustStoreType", "JKS");
        System.setProperty("javax.net.ssl.trustStore", certsConfigFile);

        String nfestatusservico = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx?WSDL";
        String pack = "nfestatusservico";

        WSDL2Java.main(new String[]{nfestatusservico, "-o", "src", "-p",
                    "org.duo.nfe.service." + pack});
        System.out.println("*** Geração concluída ***");

        /*Mensagem de Erro:
        java.io.IOException: Server returned HTTP response code: 403 for URL: https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx?WSDL
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(HttpsURLConnectionOldImpl.java:204)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
        at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
        at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
        at java.lang.Thread.run(Thread.java:619)
        
         */

Já não sei mais o que fazer, se alguém puder ajudar
agradeço!

abraços!

Importe os certificados ACCAIXA.cer, ACCAIXAPJ.cer e acraiz.cer dentro do cartão eCNPJ através do software
de administração do token.
O ACCAIXAPF.cer não se faz necessário.

Aproveitando a mensagem, observou que o certificado emitodo pela CEF, mesmo A3, tem validade até 30/10/2011?
Isso se deve a cadeia certificadora da CEF está sob o certificado ACRaiz.cer e não sob o ACRaizv1.cer

Alencar

Blz Philler, importei os certificados para o cartão e funcionou perfeitamente

muito obrigado!