【问题标题】:Using CXF HttpAsyncClient through setting use.async.http.conduit contextual property通过设置 use.async.http.conduit 上下文属性使用 CXF HttpAsyncClient
【发布时间】:2014-01-22 15:55:31
【问题描述】:

我试图通过使用上下文属性“use.async.http.conduit”根据文档http://cxf.apache.org/docs/asynchronous-client-http-transport.html来强制使用HttpAsyncClient

但是我不知道在哪里/如何在我的应用中设置这些上下文属性。

我正在通过

使用基于代理的客户端
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
factoryBean.setAddress("http://localhost:6061/services");
factoryBean.setServiceClass(MyServiceInterface.class);
documentCapture = (MyServiceInterface) factoryBean.create();

有谁知道如何设置这些上下文属性并强制使用 HttpAsyncClient?

谢谢!

【问题讨论】:

    标签: java cxf jax-rs


    【解决方案1】:

    您可以在 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);
    

    【讨论】:

    • 所以是客户端配置的问题? ...我期待在服务器端定义一些东西。谢谢。
    • 这对我不起作用,因为 ClassCastException。我使用了这个解决方案stackoverflow.com/questions/14810825/…
    猜你喜欢
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 2022-08-15
    • 2018-07-25
    • 2017-02-12
    • 1970-01-01
    • 2023-01-20
    • 1970-01-01
    相关资源
    最近更新 更多