Estou fazer uma aplicação que chama um Webservice Externo, e caso eu não consiga sair por um proxy devo tentar sair pelo outro.
Então eu atribuo o primeiro, consigo autenticar no proxy e conectar o webservice sem problemas. O problema ocorre quando o primeiro proxy está fora, após eu setar o proxy Backup, no momento que eu chamo o webservice apresenta um erro de socket.
São informado os 2 proxys:
Abaixo o codigo(O erro estoura na segunda linha igual a ws.obterIdEmpresa(cnpj);
private static boolean testWebService() {
WSNFEProxy ws = null;
try {
LogUtil.info("\nTenta usar o proxy: "+proxyHost+" ");
System.getProperties().put("http.proxyHost", proxyHost);
System.getProperties().put("http.proxyPort", proxyPort);
System.getProperties().put("http.proxyUser", proxyUser);
System.getProperties().put("http.proxyPassword", proxyPassword);
System.getProperties().put("https.proxyHost", proxyHost);
System.getProperties().put("https.proxyPort", proxyPort);
System.getProperties().put("https.proxyUser", proxyUser);
System.getProperties().put("https.proxyPassword", proxyPassword);
System.getProperties().put("https.proxySet", "true");
System.getProperties().put("http.proxySet", "true");
ws = new WSNFEProxy("http://"+ ipServer +"/WSNFEService/WSNFE?WSDL");
ws.obterIdEmpresa(cnpj);
LogUtil.info("\nOk");
return (true);
}catch(Exception ex) {
LogUtil.info("\nFalhou");
try {
LogUtil.info("\nTenta usar o proxy: "+proxyHostBackup+" ");
System.getProperties().put("http.proxyHost", proxyHostBackup);
System.getProperties().put("http.proxyPort", proxyPortBackup);
System.getProperties().put("http.proxyUser", proxyUserBackup);
System.getProperties().put("http.proxyPassword", proxyPasswordBackup);
System.getProperties().put("https.proxyHost", proxyHostBackup);
System.getProperties().put("https.proxyPort", proxyPortBackup);
System.getProperties().put("https.proxyUser", proxyUserBackup);
System.getProperties().put("https.proxyPassword", proxyPasswordBackup);
System.getProperties().put("https.proxySet", "true");
System.getProperties().put("http.proxySet", "true");
ws = new WSNFEProxy("http://"+ ipServer +"/WSNFEService/WSNFE?WSDL");
ws.obterIdEmpresa(cnpj);
LogUtil.info("\nOk");
return (true);
}catch (Exception e) {
LogUtil.info("\nFalhou");
e.printStackTrace();
return (false);
}
}
}
Apresenta o erro: