user1325397
user1325397

Reputation: 41

Getting CXF JAX-RS Client to use Jackson

I can't figure out how to use Jackson with the CXF client for Jax-RS.

I've seen some references claiming I should be adding the following XML snippet, however, I have no idea where I should be adding this. Is this only relevant when using Services or can I also set this with a client?

<jaxrs:providers>
   <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
</jaxrs:providers>

The way I'm currently creating my clients is:

MyServiceClass client = JAXRSClientFactory.create(serverUrl, MyServiceClass.class);

How do I set this client to use Jackson? I'm sure I'm missing something obvious, but I can't seem to see it. . .

Thanks!

Upvotes: 4

Views: 1825

Answers (1)

toadzky
toadzky

Reputation: 3846

This will probably do it: JAXRSClientFactory#create(String,Class,List)

The list is declared as List<?> because you can pass anything in there and it should be handled correctly - assuming it has the correct annotations.

Upvotes: 1

Related Questions