简体   繁体   中英

JAVA | CXF JAXRS Non-Spring client

We are trying to come up with a non-spring client for our cxf jaxrs services. (Not a web-client)

We have the following element in our spring-context (for enabling kerberos authentication):

<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 ?

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

Thanks,
Gayathri

dma_k was pointing you to the correct information for SOAP services. 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

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. You just have to pass through the WebClient.getConfig() method.

Regards, Gabriel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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