java 如何在 jboss 上以编程方式设置 jax-ws 客户端请求超时?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2592303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 21:57:16  来源:igfitidea点击:

How do I set the jax-ws client request timeout programatically on jboss?

javajbossweb-servicesjax-ws

提问by Jonas Andersson

I am trying to set the request (and connection) timeout for a jax-ws-webservice-client generated with the jaxws-maven-plugin. When running my app under tomcat or jetty the timeout works, but when deployed under jboss it doesn't "take".

我正在尝试为使用 jaxws-maven-plugin 生成的 jax-ws-webservice-client 设置请求(和连接)超时。在 tomcat 或 jetty 下运行我的应用程序时,超时有效,但在 jboss 下部署时,它不会“占用”。

private void setRequestAndConnectionTimeout(Object wsPort) {
  String REQUEST_TIMEOUT = BindingProviderProperties.REQUEST_TIMEOUT; // "com.sun.xml.ws.request.timeout";
  ((BindingProvider) wsPort).getRequestContext().put(REQUEST_TIMEOUT, timeoutInMillisecs);
  ((BindingProvider) wsPort).getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, timeoutInMillisecs);
}

What is the correct way to do this for JBoss?

为 JBoss 执行此操作的正确方法是什么?

回答by systempuntoout

Try with this code in Jboss:

在 Jboss 中尝试使用此代码:

(BindingProvider)wsPort).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, yourTimeoutInMillisec);

Have a look to thisthread.

看看这个线程。