jax-ws实现的web service客户端,默认请求响应超时时间是1分钟(read time out异常)。对于服务端处理逻辑复杂的服务,这个远远不够的。网上找了很多jax-ws超时设置参数,都无效。后在一国外论坛挖掘到一个有效设置。这里,用Jdk6。
ExternalOrgPostService externalOrgPostService = new ExternalOrgPostService(preUrl);
ExternalOrgPostServicePortType portType = externalOrgPostService.getExternalOrgPostServiceHttpPort();
Map<String, Object> requestContext = ((javax.xml.ws.BindingProvider)portType).getRequestContext();
/*
* 多次测试,有效设置请求超时时间的参数
*/
//Set timeout until a connection is established
requestContext.put(“javax.xml.ws.client.connectionTimeout”, 30*60*1000);
//Set timeout until the response is received
requestContext.put(“javax.xml.ws.client.receiveTimeout”, 30*60*1000);
近期评论