更改Apache CXF中特定请求的客户端超时

时间:2014-02-24 05:55:16

标签: java apache http cxf

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

我当前的代码看起来像这样

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

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

1 个答案:

答案 0 :(得分:2)

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

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

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