我需要执行ping webservice来检查我是否有连接到端点,并且webservice服务器都很好。
这有点蠢,但我必须为此调用一个Web服务。问题是,当我调用stub.ping(request)并且我没有连接时,它会继续尝试执行此代码一段时间......然后返回false。
如果它不能ping通过1秒后任何方法使这个超时?public boolean ping() {
try {
PingServiceStub stub = new PingServiceStub(soapGWEndpoint);
ReqPing request = new ReqPing();
UserInfo userInfo = new UserInfo();
userInfo.setName(soapGWUser);
userInfo.setPassword(soapGWPassword);
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.setConfigurationName(soapGWAppName);
stub.ping(request);
return true;
} catch (RemoteException | PingFault e) {
return false;
}
}