2013-12-10 28 views
1

我試圖通過使用上下文財產「use.async.http.conduit」的強制使用HttpAsyncClient根據文檔http://cxf.apache.org/docs/asynchronous-client-http-transport.html利用CXF HttpAsyncClient通過設置use.async.http.conduit上下文財產

然而我不知道在哪裏/如何在我的應用中設置這些上下文屬性。

我使用的是基於代理的客戶端通過

JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean(); 
factoryBean.setAddress("http://localhost:6061/services"); 
factoryBean.setServiceClass(MyServiceInterface.class); 
documentCapture = (MyServiceInterface) factoryBean.create(); 

有誰知道如何設置這些種情境性的,並迫使HttpAsyncClient?

謝謝!

回答

2

您可以在org.apache.cxf.endpoint.Client上設置這些屬性。只需通過調用靜態方法來獲取它:ClientProxy.getClient(proxy)。

你的情況:

JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean(); 
factoryBean.setAddress("http://localhost:6061/services"); 
MyServiceInterface documentCapture = factoryBean.create(MyServiceInterface.class); 

Client client = ClientProxy.getClient(documentCapture); 
client.getRequestContext().put("use.async.http.conduit", Boolean.TRUE); 
+0

所以這是客戶端配置的問題? ...我期待在服務器端定義一些東西。謝謝。 – Rafael

+0

由於ClassCastException,這對我不起作用。我用這個解決方案http://stackoverflow.com/questions/14810825/prevent-jaxrsclientfactory-to-reuse-connections –