如何在Java中为我的WSDL执行Ping?
我已经尝试过了:
InetAddress.getByname(my_wsdl).isReachable(3000);
但没有用。
答案 0 :(得分:0)
试试这个
private boolean isWSDLAvailable(String wsdlAddr) {
HttpURLConnection c = null;
try {
URL u = new URL(wsdlAddr);
c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("HEAD");
c.getInputStream();
return c.getResponseCode() == 200;
} catch (Exception e) {
return false;
} finally {
if (c != null) c.disconnect();
}
}