java webservice 超时_java关于设置webservice连接超时和请求超时

以下记录常用的webservice超时配置

1、CXF

Client client = ClientProxy.getClient(port);

HTTPConduit http = (HTTPConduit) client.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

// 设置连接超时

httpClientPolicy.setConnectionTimeout(6*1000);

httpClientPolicy.setAllowChunking(false);

http.setClient(httpClientPolicy);

2、jax-ws

ServiceReceivePidService serviceReceivePidService = new ServiceReceivePidService();

ServiceReceivePid serviceReceivePid = serviceReceivePidService.getServiceReceivePid();

((BindingProvider)serviceReceivePid).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", 6*1000);

((BindingProvider)serviceReceivePid).getRequestContext().put("com.sun.xml.internal.ws.request.timeout", 6*1000);

com.sun.xml.internal.ws.connect.timeout:连接超时

com.sun.xml.internal.ws.request.timeout:请求超时

单位是毫秒。如果没有指定对应的超时时间或者指定的超时时间为0都表示永不超时;

你可能感兴趣的:(java,webservice,超时)