如何在Java中ping WSDL

时间:2012-04-18 00:23:41

标签: java wsdl ping

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

我已经尝试过了:

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

但没有用。

1 个答案:

答案 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();
        }    
}