The best solution is to create a VIP for the web service and automatically recover from a failure. Thus, your application only cares about one endpoint and does not need details.
Java, , -. Java, :
try {
URL primaryURL = new URL(web_service_endpoint);
HttpURLConnection con = (HttpURLConnection) primaryURL.openConnection();
con.setConnectTimeout(5000);
} catch (java.net.SocketTimeoutException e) {
}