0

I've used JAXWS-RI 2.1 to create an interface for my web service, based on a WSDL. I can interact with the web service no problems, but haven't been able to specify repetition when SocketTimeoutException:

try {
  final Response response = service.serviceName(params);
} catch (SocketTimeoutException e) {

}

is there a way how to specify it in service or I need to code this ?

for example I would set for 3 repetation and when after 3 exception there will be stil timemout so this exception will be thrown

4

1 回答 1

0

没有本地方法可以做到这一点(我怀疑你来自 Ruby,这是一种语言特性)。您将需要循环,然后在成功时中断,例如

for (int i = 0 ; i < 3 ; i++) {
    try {
        final Response response = service.serviceName(params);
        break;
    } catch (SocketTimeoutException e) {
        Thread.getCurrentThread().sleep(10 * 1000);
    }
}
于 2012-11-06T08:20:25.170 回答