Senhores,
Estou trabalhando na NFe e estou tendo alguns problemas pra configurar o webservice:
String nfeCabecMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<cabecMsg xmlns=\"http://www.portalfiscal.inf.br/nfe\" "
+ "versao=\"1.02\">" + "<versaoDados>1.07</versaoDados>"
+ "</cabecMsg>";
String nfeDadosMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<consStatServ " + " versao=\"1.07\""
+ " xmlns=\"http://www.portalfiscal.inf.br/nfe\">"
+ "<tpAmb>2</tpAmb>" + "<cUF>35</cUF>"
+ "<xServ>STATUS</xServ>" + "</consStatServ>";
//acceptSSL();
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", "\\Users\\Administrador\\Desktop\\webservice\\vanmax.pfx");//Aqui vem o arquivo do certificado do seu cliente
System.setProperty("javax.net.ssl.keyStorePassword", "");//Aqui a senha deste certificado
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", "\\Users\\Administrador\\Desktop\\webservice\\nfe.keystore");//Aqui vem o arquivo criado através do comando keytool no passo 3
System.setProperty("javax.net.ssl.trustStorePassword", "vanmax");//Aqui a senha deste certificado
// As classes abaixo são as classes geradas atavés do arquivo WSDL no passo 1
try {
NfeStatusServicoNF xml = new NfeStatusServicoNF();
xml.setNfeCabecMsg(nfeCabecMsg);
xml.setNfeDadosMsg(nfeDadosMsg);
NfeStatusServico_Service status = new NfeStatusServico_Service(new URL("https://homnfe.sefaz.am.gov.br/ws/services/NfeConsulta"));
NfeStatusServico service = status.getNfeStatusServico();
System.out.println(service.nfeStatusServicoNF(xml.getNfeCabecMsg(), xml.getNfeDadosMsg()));// O retorno deve ser um XML com o status do serviço
} catch (Throwable e1) {
e1.printStackTrace();
}
Erro gerado:
com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:161)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:57)
at br.inf.portalfiscal.nfe.wsdl.nfestatusservico.NfeStatusServico_Service.<init>(NfeStatusServico_Service.java:50)
at pnfe1.Main.main(Main.java:55)
CONSTRUÍDO COM SUCESSO (tempo total: 1 segundo)
Alguém pode me dizer o que está acontecendo?
Estou usando:
NetBeans 6.8
Win 7
Desde já agradeço,
Ellcyo Castro