Estou tentando acessar um Web Service, só que minha rede tem proxy e está ocorrendo o seguinte erro:
[color=red] com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
java.io.IOException: Unable to tunnel through proxy. Proxy returns “HTTP/1.0 407 Proxy Authentication Required”
java.io.IOException: Unable to tunnel through proxy. Proxy returns “HTTP/1.0 407 Proxy Authentication Required”
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:146)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:122)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:226)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:189)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:159)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:81)
at javax.xml.ws.Service.<init>(Service.java:56)
at br.inf.portalfiscal.nfe.wsdl.nfestatusservico.NfeStatusServico.<init>(NfeStatusServico.java:44)
at Main.main(Main.java:35)
[/color]
Código da classe:
import br.inf.portalfiscal.nfe.wsdl.nfestatusservico.NfeStatusServico;
import br.inf.portalfiscal.nfe.wsdl.nfestatusservico.NfeStatusServicoNF;
import br.inf.portalfiscal.nfe.wsdl.nfestatusservico.NfeStatusServicoSoap;
import br.inf.portalfiscal.nfe.wsdl.nfestatusservico.ObjectFactory;
import java.net.URL;
import java.security.Security;
import javax.xml.namespace.QName;
public class Main {
public static void main(String... args) {
try {
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.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", "c:\\homologa_SP"); // Arquivo gerado com o InstallCert
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("javax.net.ssl.keyStore", "c:\\NFe emissao.pfx"); // o arquivo com o certificado do emitente
System.setProperty("javax.net.ssl.keyStorePassword", "senhaCertificado"); // a senha do arquivo
System.setProperty("https.proxyHost", "192.168.1.254");
System.setProperty("https.proxyPort", "5981");
System.setProperty("https.proxyUser", "usuarioProxy");
System.setProperty("https.proxyPassword", "senhaProxy");
NfeStatusServicoNF status = new ObjectFactory().createNfeStatusServicoNF();
status.setNfeCabecMsg("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><cabecMsg xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"1.02\"><versaoDados>1.07</versaoDados></cabecMsg>");
status.setNfeDadosMsg("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><consStatServ xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"1.07\"><tpAmb>2</tpAmb><cUF>35</cUF><xServ>STATUS</xServ></consStatServ>");
NfeStatusServico service = new NfeStatusServico(new URL("https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/nfestatusservico.asmx "), new QName("http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico", "NfeStatusServico"));
NfeStatusServicoSoap soap = service.getNfeStatusServicoSoap();
String result = soap.nfeStatusServicoNF(status.getNfeCabecMsg(), status.getNfeDadosMsg());
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Quando a conexão é direta (sem proxy) funciona perfeitamente.
Agradeço quem puder ajudar!
Obrigado!