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

Jon*_*son 8 java jboss web-services jax-ws

我正在尝试为使用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);
}
Run Code Online (Sandbox Code Playgroud)

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

sys*_*out 9

在Jboss中尝试使用此代码:

(BindingProvider)wsPort).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, yourTimeoutInMillisec);
Run Code Online (Sandbox Code Playgroud)

看看这个帖子.

  • 这解决了!StubExt位于:import org.jboss.ws.core.StubExt; 必须添加一些maven依赖项:<dependency> <groupId> jboss-eap </ groupId> <artifactId> jbossws-spi </ artifactId> <version> 4.3.0.GA_CP02 </ version> <scope>提供</ scope> </ dependency> <dependency> <groupId> jboss-eap </ groupId> <artifactId> jbossws-core </ artifactId> <version> 4.3.0.GA_CP02 </ version> <scope>提供</ scope> </ dependency >非常感谢! (2认同)