java - 通过设置 use.async.http.conduit 上下文属性来使用 CXF HttpAsyncClient

标签 java cxf jax-rs

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

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

我通过

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

有人知道如何设置此类上下文属性并强制 HttpAsyncClient 吗?

谢谢!

最佳答案

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

关于java - 通过设置 use.async.http.conduit 上下文属性来使用 CXF HttpAsyncClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20497003/

相关文章:

java - 智能 : customize naming of generated test methods

java - Apache Camel 和 CXF : How do i send HTTP status code from bean

tomcat - 资源路径 [cxf-ehcache.xml] 无效

java - 无法加载 Jersey 测试中的注入(inject)值

json - JAX-RS JAXB JSON 响应不起作用(MessageBodyProviderNotFoundException)

java - 如何在循环中向变量添加值

java - C + JNI 无法执行一个非常简单的程序

Java读取文件并发送到服务器

xml - 如何扩展 CXF wsdl2java 生成的类使用的 JAXBContext 以包含额外的 ObjectFactory

jakarta-ee - 无法加载内置提供程序 : org. jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider