如何在 Java 中为我的 WSDL 执行 Ping?
我已经尝试过了:
InetAddress.getByname(my_wsdl).isReachable(3000);
但没有用。
尝试这个
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();
}
}