服务器连接测试——工具类

package com.rthd.utils;


import java.net.HttpURLConnection;
import java.net.URL;


public class WsdlUtils {
public static int testWsdlConnection(String address) throws Exception {
//测试地址   http://localhost:8080/webservice_four/services/UniSalesCode?wsdl
  int status = 404;
  URL urlObj = new URL(address);
  HttpURLConnection oc = (HttpURLConnection) urlObj.openConnection();
  oc.setUseCaches(false);
  oc.setConnectTimeout(3000); // 设置超时时间
  status = oc.getResponseCode();// 请求状态
  if (200 == status) {
   // 200是请求地址顺利连通。。
   return status;
  }else{
return status;
  }
}
}

你可能感兴趣的:(服务器连接测试——工具类)