更改Apache CXF中特定请求的客户端超时 [英] changing client timeout for a particular request in Apache CXF

查看:188
本文介绍了更改Apache CXF中特定请求的客户端超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须根据我的请求中的某些条件在Apache cxf请求中设置不同的超时

I have to set a different timeout in Apache cxf request based on some condition in my request

我的当前代码如下所示

 <http-conf:client  ReceiveTimeout="120000" AcceptEncoding="gzip, deflate"/>

现在有办法根据某些条件更改特定请求的接收超时。

Now is there any way to change this receive timeout for a particular request based on some condition.

推荐答案

目前我们在CXF中没有提供这种设置。
如果您仍想这样做,您可以从CXF客户端代理获取HttpConduit并将HTTPClientPolicy直接设置为HttpConduit。

Current we don't provide this kind of setting in CXF. If you still want to do that, you can get the HttpConduit from the CXF client proxy and set the HTTPClientPolicy directly to the HttpConduit.

 // Get the HttpConduit 
 HttpConduit httpConduit = (HttpConduit) ClientProxy.getClient(greeter).getConduit();
 // Set your custom HTTPClientPolicy directly to the httpConduit
 httpConduit.setHTTPClientPolicy(httpClientPolicy);

通过这种方式,您可以在将请求发送到服务器之前更新超时。

In this way, you can update the timeout before sending the request to the server.

这篇关于更改Apache CXF中特定请求的客户端超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆