NFE - Problema nos esquemas XML - WebServices SP ou MS

22 respostas
V

Pessoal estou com problema nos schemas de SP ou MS, ja validei em diversos programas dá tudo ok, gostaria de saber se alguem fez pro SP ou MS para poder me ajudar, veja o problema abaixo:

consReciNFE está dando Rejeição: Falha no schema XML:

Estou enviando (no cabecalho tentei 1.11 ele fala q é invalido ai coloquei 1.10 foi mas dá pau no schema):

nfeCabecMsg:

1.10

nfeDadosMsg

2 350000000491738

22 Respostas

A

Bom dia,

Estou enviando a seguinte requisição SOAP para a receita:

<soapenv:Envelope xmlns:soapenv=“<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>”

xmlns:nfes=“<a href="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico">http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico</a>”

xmlns:nfe=“<a href="http://www.portalfiscal.inf.br/nfe">http://www.portalfiscal.inf.br/nfe</a>”>

<a>soapenv:Header/</a>

<a>soapenv:Body</a>

<a>nfes:nfeStatusServicoNF</a>

<a>nfes:nfeCabecMsg</a>



1.05



</nfes:nfeCabecMsg>

<a>nfes:nfeDadosMsg</a>

STATUS

</nfes:nfeDadosMsg>

</nfes:nfeStatusServicoNF>

</soapenv:Body>

</soapenv:Envelope>

Porém, recebo o erro a seguir como resposta:

<soapenv:Envelope xmlns:soapenv=“<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a> xmlns:xsd=“<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a> xmlns:xsi=“<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>”>

<a>soapenv:Body</a>

<a>soapenv:Fault</a>

soapenv:Server.userException

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.



<ns1:hostname xmlns:ns1=“<a href="http://xml.apache.org/axis/">http://xml.apache.org/axis/</a>”>vermelho.sefaz.mt.gov.br</ns1:hostname>



</soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

Alguém poderia me ajudar? O que estou mandando de errado?

Obrigado!!!

V

Você está mandando com SOAP etc… manda puro manda assim:

1.10 2 50 // 50 = SP STATUS
A

Opa Vinícius!

mas para uma requisição SOAP, preciso das tags de “envelope”, “body”, etc… Como vc fez aí para mandar puro? Usa AXIS?

Abraço!

A

Opa…estava mandando como SOAP 1.1, alterei para SOAP 1.2…Mas agora recebo o seguinte erro na resposta da requisição:

<soapenv:Envelope xmlns:soapenv=“http://www.w3.org/2003/05/soap-envelope” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
soapenv:Body
soapenv:Fault
soapenv:Code
soapenv:Valuesoapenv:Sender</soapenv:Value>
<soapenv:Subcode xmlns:ns1=“http://www.w3.org/2003/05/soap-rpc”>
soapenv:Valuens1:BadArguments</soapenv:Value>
</soapenv:Subcode>
</soapenv:Code>
soapenv:Reason
<soapenv:Text xml:lang=“en”>string</soapenv:Text>
</soapenv:Reason>
soapenv:Detail
<ns2:hostname xmlns:ns2=“http://xml.apache.org/axis/”>vermelho.sefaz.mt.gov.br</ns2:hostname>
</soapenv:Detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

a requisição está assim:

<soap:Envelope xmlns:soap=“<a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/soap-envelope</a>”>

<a>soap:Header/</a>

<a>soap:Body</a>







1.07









2

51

STATUS







</soap:Body>

</soap:Envelope>
M

o problema eh com sp e ms ou tamem eh com mt???

A

Estou testando só com MT.

Abs!!!

A

Alguém pode me ajudar? SOAP + Nfe

V

Você "escapou" o conteúdo dos elementos nfeCabecMsg e nfeDadosMsg como String (ou seja, trocou > para &gt; e < para &lt;)?

&lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"&gt;
&lt;soap:Header/&gt;
&lt;soap:Body&gt;
&lt;nfeStatusServicoNF xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico"&gt;
&lt;nfeCabecMsg&gt;&amp;lt;cabecMsg versao="1.02" xmlns="http://www.portalfiscal.inf.br/nfe"&amp;gt;&amp;lt;versaoDados&amp;gt;1.07&amp;lt;/versaoDados&amp;gt;&amp;lt;/cabecMsg&amp;gt;
&lt;/nfeCabecMsg&gt;
&lt;nfeDadosMsg&gt;&amp;lt;consStatServ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" versao="1.07" xmlns="http://www.portalfiscal.inf.br/nfe"&amp;gt;&amp;lt;tpAmb&amp;gt;2&amp;lt;/tpAmb&amp;gt;&amp;lt;cUF&amp;gt;51&amp;lt;/cUF&amp;gt;&amp;lt;xServ&amp;gt;STATUS&amp;lt;/xServ&amp;gt;&amp;lt;/consStatServ&amp;gt;&lt;/nfeDadosMsg&gt;
&lt;/nfeStatusServicoNF&gt;
&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;

Ah, testa com Goiás, com a Bahia ou com o Rio Grande do Sul que é bem melhor que Mato Grosso.

A

Cara. Muito obrigado pela resposta!!! Mesmo!

Eu preciso “escapar” então? Desculpe minha ignorância…
Olha só…Eu escapei e a requisição ficou assim:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap=“<a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/soap-envelope</a>”>

<a>soap:Header/</a>

<a>soap:Body</a>



<cabecMsg versao=“1.02” xmlns=“<a href="http://www.portalfiscal.inf.br/nfe">http://www.portalfiscal.inf.br/nfe</a>”><versaoDados>1.07</versaoDados></cabecMsg>



<consStatServ xmlns:xsi=“<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a> xmlns:xsd=“<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a> versao=“1.07” xmlns=“<a href="http://www.portalfiscal.inf.br/nfe">http://www.portalfiscal.inf.br/nfe</a>”><tpAmb>2</tpAmb><cUF>51</cUF><xServ>STATUS</xServ></consStatServ>



</soap:Body>

</soap:Envelope>

Mas aí, recebo a resposta:

<soapenv:Envelope xmlns:soapenv=“<a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/soap-envelope</a> xmlns:xsd=“<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a> xmlns:xsi=“<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>”>

<a>soapenv:Body</a>





2
1.10
299
Rejeicao: XML da area de cabecalho com codificacao diferente de UTF-8
51
   ]]>



</soapenv:Body>

</soapenv:Envelope>

O quer quer dizer que a área de cabeçalho está com codificação diferente de UTF-8? No manual de integração, na página 13, diz para colocar <?xml version="1.0" encoding="utf-8"?> na área de cabeçalho e de dados. Mas aí o parser reclama dizendo que a declaração “XML” só pode aparecer 1 vez no documento.

Obrigado pela atenção. Se não nos ajudarmos e dependermos das informações da receita , a coisa não vai! Valeu

V

Eu acho que é UTF-8 (em maiúsculas) e não utf-8.

Mas sei lá, isso é meio que um chute.

A

Aí vai a resposta deles, mais legível agora, depois de enviar tudo ESCAPADO:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <nfeStatusServicoNFResponse xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico">
         <nfeStatusServicoNFResult><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<retConsStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.07">
<tpAmb>2</tpAmb>
<verAplic>1.10</verAplic>
<cStat>299</cStat>
<xMotivo>Rejeicao: XML da area de cabecalho com codificacao diferente de UTF-8</xMotivo>
<cUF>51</cUF>
   </retConsStatServ>]]></nfeStatusServicoNFResult>
      </nfeStatusServicoNFResponse>
   </soapenv:Body>
</soapenv:Envelope>

Outra coisa, não consigo testar com RS pq não tenho certificado credenciado lá.

Abs
vALEU

A

Acho que o que eles querem dizer com “codificação da área de cabeçalho” é a área da tag . No manual, página 13, tem declaração de encoding (UTF) ali…

V

Deve ser isso. O <?xml version="1.0" encoding="utf-8"?> tem que ter tanto no nfeCabcMsg quanto no nfeDadosMsg.

R

Boa tarde a todos,

Já consegui efetuar a conexão com o Web Service da NFe e verificar o status do serviço, agora estou tentando assinar um XML mas não estou conseguindo, alguem já conseguiu assinar o XML da NFe ?, como funciona a parte do certificado ? achei um código no forum http://www.guj.com.br/posts/list/83758.java mas nele tem uma codificação que não estou entendendo, a mesma esta abaixo:

String configName = /token.cfg;

Provider p = new sun.security.pkcs11.SunPKCS11(configName);

Security.addProvider§;

char[] pin = { s, a, f, e, w, e, b };
No meu código de conexão com o web-server não tem nada de PKCS11, segue abaixo o código:

[b]

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, verConf.getPathKeyPFX());

System.setProperty(javax.net.ssl.keyStorePassword, xxxx);
System.setProperty(javax.net.ssl.trustStoreType, JKS);

System.setProperty(javax.net.ssl.trustStore,verConf.getPathKeyJKS());

[/b]

Alguem já conseguiu assinar um XML NFe, poderia me dar uma ajuda ?

G

Ola a todos. Cheguei neste ponto e não consigo avançar. segue meu código, request e response.

String cabecMsg =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<cabecMsg xmlns=\"http://www.portalfiscal.inf.br/nfe\" " +
                      "versao=\"1.02\">" +
                "<versaoDados>1.07</versaoDados>" +
            "</cabecMsg>";

    String consStatServ =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\">" +
                "<tpAmb>2</tpAmb>" +
                "<cUF>13</cUF>" +
                "<xServ>STATUS</xServ>" +
            "</consStatServ>";

    service = new Service();
    call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(
        "https://homologacao.sefaz.mt.gov.br/nfews/NfeStatusServico"));
    call.setOperationName(new QName(
            "http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico", "nfeStatusServicoNF"));
    call.addParameter("nfeCabecMsg", XMLType.XSD_STRING, ParameterMode.IN);
    call.addParameter("nfeDadosMsg", XMLType.XSD_STRING, ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);
    String ret = (String) call.invoke( new Object[] { cabecMsg, consStatServ } );

Segue o resquest e response do servidor:

Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <nfeStatusServicoNF soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <nfeCabecMsg xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
            &lt;?xml version="1.0" encoding="utf-8"?&gt;
            &lt;cabecMsg xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.02"&gt;
               &lt;versaoDados&gt;1.07&lt;/versaoDados&gt;
            &lt;/cabecMsg&gt;
         </nfeCabecMsg>
         <nfeDadosMsg xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
            &lt;?xml version="1.0" encoding="utf-8" ?&gt;
            &lt;consStatServ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                             versao="1.02"
                             xmlns="http://www.portalfiscal.inf.br/nfe"&gt;
               &lt;tpAmb&gt;2&lt;/tpAmb&gt;
               &lt;cUF&gt;13&lt;/cUF&gt;
               &lt;xServ&gt;STATUS&lt;/xServ&gt;
            &lt;/consStatServ&gt;
         </nfeDadosMsg>
      </nfeStatusServicoNF>
   </soapenv:Body>
</soapenv:Envelope>

Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server.userException</faultcode>
         <faultstring>org.apache.velocity.exception.ResourceNotFoundException: O arquivoTemplate (retornoCancelamento.vm) nao existe no diretorio /usr/appl/nfe/template/</faultstring>
         <detail>
            <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">vermelho.sefaz.mt.gov.br</ns1:hostname>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

Só tenho certificado do MT, nao consigo testar em outro estado.
Alguem já teve esse problema no MT?

G

Resolvido…

Notem a linha:

"<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe">" +

está faltando o atributo: versao=“1.07”

forma correta:

“<consStatServ xmlns=“http://www.portalfiscal.inf.br/nfe” versao=“1.07”>” +

Pra quem teve ou tem o mesmo problema, tomem cuidado com a versao dos dados informada no cabeçalho.
Desenvolvam ou utilivem algum aplicativo para validação de seus arquivos xml nos schemas fornecidos pela
secretaria da fazenda, vai facilitar muito.

Um abraço a todos…

A

Cara vc poderia me dar uma ajuda, estou com um problema na hora do envio da nfe, veja o erro: ja tentei de tudo q nao consegui resolve o problema se vc poder me dar uma dica eu agradeço…

AxisFault

faultCode: {<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>}Server.userException

faultSubcode:

faultString: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

faultActor:

faultNode:

faultDetail:

{<a href="http://xml.apache.org/axis/">http://xml.apache.org/axis/</a>}stackTrace:javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1591)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:975)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:123)

at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)

at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1107)

at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

at org.apache.axis.client.Call.invoke(Call.java:2767)

at org.apache.axis.client.Call.invoke(Call.java:2443)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at webservices.NfeRecepcao.NfeRecepcaoSoapStub.nfeRecepcaoLote(NfeRecepcaoSoapStub.java:110)

at ws.WebServices.enviaNotaFiscalEletronica(WebServices.java:29)

at LeArquivoEnvio.LeArquivoEnvio.leArquivoEnvio(LeArquivoEnvio.java:1092)

at nfe.EnviaNFe.leArquivoEnvio(EnviaNFe.java:22)

at nfe.IniciaNFe.main(IniciaNFe.java:18)

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)

at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)

at sun.security.validator.Validator.validate(Validator.java:218)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:954)

… 25 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)

at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)

… 31 more
{http://xml.apache.org/axis/}hostname:saopaulo
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

at org.apache.axis.client.Call.invoke(Call.java:2767)

at org.apache.axis.client.Call.invoke(Call.java:2443)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at webservices.NfeRecepcao.NfeRecepcaoSoapStub.nfeRecepcaoLote(NfeRecepcaoSoapStub.java:110)

at ws.WebServices.enviaNotaFiscalEletronica(WebServices.java:29)

at LeArquivoEnvio.LeArquivoEnvio.leArquivoEnvio(LeArquivoEnvio.java:1092)

at nfe.EnviaNFe.leArquivoEnvio(EnviaNFe.java:22)

at nfe.IniciaNFe.main(IniciaNFe.java:18)

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1591)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)

at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:975)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:123)

at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)

at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1107)

at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

 14 more

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)

at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)

at sun.security.validator.Validator.validate(Validator.java:218)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)

at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:954)

 25 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)

at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)

 31 more
V

Caro amigo esse erro é porque o java nao esta aceitando o certificado do servidor sendo assim a conexao perdida.

Voce tem que colocar o certificado do servidor no cacertes do java ou criar um keystore e chamar na antes da conexão com o servidor.

Sds

T

Bom dia colegas,

Depois de quase 10 dias de luta, finalmente consegui conectar ao Web service no MT, mas agora recebo a seguinte resposta quando solicito o serviço de consulta de Status do serviço:

<?xml version="1.0" encoding="UTF-8"?>
<retConsStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.07">
	<tpAmb>0</tpAmb>
	<verAplic>110</verAplic>
	<cStat>239</cStat>
	<xMotivo>Rejeicao: Cabecalho - Versao do arquivo XML nao suportada</xMotivo>
	<cUF>51</cUF>
</retConsStatServ>

Coloquei o meu XML a prova no validador da SEFAZ-RS(link: http://www.sefaz.rs.gov.br/AAE_ROOT/NFE/SAT-WEB-NFE-VAL_1.asp) e na aplicação ValidaXML (link: http://nf-eletronica.com/blog?dl_id=6), ambos retornam positivamente quanto a formação do XML.

vou postar o código que tenho utilizado aqui para que vocês me ajudem a encontrar uma resposta:

import java.io.*;
import java.rmi.RemoteException;
import java.security.Security;

import javax.xml.rpc.ServiceException;

import br.inf.portalfiscal.www.nfe.wsdl.NfeStatusServico.NfeStatusServico_PortType;
import br.inf.portalfiscal.www.nfe.wsdl.NfeStatusServico.NfeStatusServico_Service;
import br.inf.portalfiscal.www.nfe.wsdl.NfeStatusServico.NfeStatusServico_ServiceLocator;

public class StatusNFE {
	
	public static void main(String[] args) throws Exception {
		
	
	String cabecMsg =			
            "<?xml version=\"1.0\" " +
            "encoding=\"UTF-8\"?>" +
            "<cabecMsg xmlns=\"http://www.portalfiscal.inf.br/nfe\" " +
                      "versao=\"1.02\">" +
              "<versaoDados>1.07</versaoDados>" +
            "</cabecMsg>";
            

    String consStatServ =
    		"<nfeDadosMsg>" +
    		"<?xml version=\"1.0\" " +
           "encoding=\"UTF-8\"?>" +
            "<consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"1.07\">" +
                "<tpAmb>2</tpAmb>" +
                "<cUF>13</cUF>" +
                "<xServ>STATUS</xServ>" +
            "</consStatServ></nfeDadosMsg>";    
    
		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:\\testeCert\\Certificado.pfx"); 
		System.setProperty("javax.net.ssl.keyStorePassword", "******");

		System.setProperty("javax.net.ssl.trustStoreType", "JKS");
		System.setProperty("javax.net.ssl.trustStore", "C:\\testeCert\\cert.jks");

		System.out.println("Verificado status...");

		NfeStatusServico_Service hService = new NfeStatusServico_ServiceLocator();
		System.out.println("Criou hService");
		try {
			NfeStatusServico_PortType port = hService.getNfeStatusServico();
			System.out.println("Criou port");
			try {
				System.out.println(port.nfeStatusServicoNF(cabecMsg, consStatServ));
				System.out.println("verificou status");
			} catch (RemoteException e) {
				System.out.println("-------------------------------------");
				System.out.println(e.getMessage());
				System.out.println("-------------------------------------");
				e.printStackTrace();
			}

		} catch (ServiceException e1) {
			e1.printStackTrace();
		}
	}
}

Desde já agradeço a cooperação de todos os colegas.

T

vm:
Caro amigo esse erro é porque o java nao esta aceitando o certificado do servidor sendo assim a conexao perdida.

Voce tem que colocar o certificado do servidor no cacertes do java ou criar um keystore e chamar na antes da conexão com o servidor.

Sds

PRECISO DA SUA AJUDA ESTOU COM UM PROBLEMA IGUAL. COMO IREI FAZER COM QUE O JAVA ACEITE MEU CERTIFICADO?

AGRADEÇO VC DESDE JÁ,

SEGE MEU E-MAIL: [email removido]

T

Faça como o amigo vm falou "Voce tem que colocar o certificado do servidor no cacertes do java ou criar um keystore e chamar na antes da conexão com o servidor. "

D

Olá…

estou com um problema parecido… talvez sua experiência possa me ajudar:

Utilizo Axis para implementar o meu WS e eu quero retornar o seguinte simples xml: <resposta msg=“Sucesso” />. Daí qd o WS retorna, é pego o seguinte xml:

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;soapenv:Body&gt;
              &lt;testeResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
                     &lt;testeReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"&gt;&lt;resposta msg="Erro meu vei" /&gt;&lt;/testeReturn&gt;
               &lt;/testeResponse&gt;
       &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;

como vc pode ver o problema sao os caracteres < e > que foram substiuídos por < e o > . Como fazer para que isso não ocorra?

Criado 5 de abril de 2008
Ultima resposta 13 de abr. de 2010
Respostas 22
Participantes 12