JAX-WS RI 2.2.9 Java WebService Timeout时间设置

程序开发 专栏收录该内容
23 篇文章 1 订阅

JDK1.8 +Tomcat环境,采用以下配置实现了超时配置,且验证有效。

bindingProvider.getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", 30000);
bindingProvider.getRequestContext().put("com.sun.xml.internal.ws.request.timeout", 60000);

给人感觉,有多种不同的实现!小红帽RedHat给出的示例是针对JBoss,看起jdk有些不一样。

public void testConfigureTimeout() throws Exception
{
   //Set timeout until a connection is established
   ((BindingProvider)port).getRequestContext().put("javax.xml.ws.client.connectionTimeout", "6000");

   //Set timeout until the response is received
   ((BindingProvider) port).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "1000");

   port.echo("testTimeout");
}

代码看起来跟引入的包名匹配度高,但是实测不生效。

而Github上的资料显示,不同的环境下,采用的配置有些不一样,也没有一个统一的标准。

A little overview of several implementations:
// Weblogic JAX-WS properties
((BindingProvider) port).getRequestContext().put("com.sun.xml.ws.connect.timeout", timeout);
((BindingProvider) port).getRequestContext().put("com.sun.xml.ws.request.timeout", timeout);
// JDK JAX-WS properties
((BindingProvider) port).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", timeout);
((BindingProvider) port).getRequestContext().put("com.sun.xml.internal.ws.request.timeout", timeout);
// JBOSS CXF JAX-WS properties, warning these might change in the future (CXF-5261)
((BindingProvider) port).getRequestContext().put("javax.xml.ws.client.connectionTimeout", timeout);
((BindingProvider) port).getRequestContext().put("javax.xml.ws.client.receiveTimeout", timeout);

小节,对于JAX-WS的超时配置,需要依据自身的环境配置来决定。默认的超时时间是30s连接,响应超时是60s,这个可以参与apache cfx官网。未验证。

 

参考

https://www.igorkromin.net/index.php/2018/12/06/setting-jax-ws-webservice-client-timeout-values-correctly-within-a-weblogic-12c-container/

https://github.com/javaee/metro-jax-ws/issues/1166

https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/6/html/development_guide/develop_a_jax-ws_client_application

http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport(includingSSLsupport)-Example   搜索一下timeout可以查找到配置说明。

AttributeDescription
ConnectionTimeoutSpecifies the amount of time, in milliseconds, that the client will attempt to establish a connection before it times out. The default is 30000 (30 seconds). 
0 specifies that the client will continue to attempt to open a connection indefinitely.
ReceiveTimeoutSpecifies the amount of time, in milliseconds, that the client will wait for a response before it times out. The default is 60000. 
0 specifies that the client will wait indefinitely.

  • 1
    点赞
  • 0
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:精致技术 设计师:CSDN官方博客 返回首页

打赏作者

Lancker

你的打赏很重要

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值