且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-09-19 15:19:16

目前我们在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.