0

如何在 Java 中为我的 WSDL 执行 Ping?

我已经尝试过了:

InetAddress.getByname(my_wsdl).isReachable(3000);

但没有用。

4

1 回答 1

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();
        }    
}
于 2015-08-20T20:21:04.310 回答