简体   繁体   English

JAVA | CXF JAXRS非Spring客户端

[英]JAVA | CXF JAXRS Non-Spring client

We are trying to come up with a non-spring client for our cxf jaxrs services. 我们正在尝试为我们的cxf jaxrs服务提供一个非spring客户。 (Not a web-client) (不是网络客户端)

We have the following element in our spring-context (for enabling kerberos authentication): 我们在spring上下文中具有以下元素(用于启用kerberos身份验证):

<http:conduit name="*.http-conduit">
        <http:authorization>
            <sec:AuthorizationType>Negotiate</sec:AuthorizationType>
        </http:authorization>
</http:conduit>

Any idea how this can be converted to java code ? 知道如何将其转换为Java代码吗?

Sample client code: 客户端代码示例:

JAXRSClientFactoryBean clientBean = new JAXRSClientFactoryBean();
clientBean.setResourceClass(ServiceClassName.class);
clientBean.setAddress(restful-service-url);

CXF documentation doesn't specify this clearly : http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-CreatingclientsprogrammaticallywithnoSpringdependencies CXF文档没有明确指出: http ://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-以无弹簧依赖的方式以编程方式创建客户端

Thanks, 谢谢,
Gayathri 盖亚特里

dma_k was pointing you to the correct information for SOAP services. dma_k为您指出了有关SOAP服务的正确信息。 If you are looking to the direct answer for REST services, check http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ConfiguringClientsatRuntime 如果您正在寻找REST服务的直接答案,请查看http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ConfiguringClientsatRuntime

YourService proxy = JAXRSClientFactory.create(YourService.class);
ClientConfiguration config = WebClient.getConfig(proxy);
HTTPConduit conduit1 = (HTTPConduit)config.getConduit();
System.out.println(conduit1.getClient().getProxyServer());

This code allows you to access the conduit of your REST service, and then configure it as you want. 此代码使您可以访问REST服务的管道,然后根据需要对其进行配置。 You just have to pass through the WebClient.getConfig() method. 您只需要通过WebClient.getConfig()方法即可。

Regards, Gabriel 问候,加百利

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM