You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Dan King <da...@yahoo.com> on 2011/01/25 00:08:38 UTC
Changing json provider in server and client
Hi,
I'm aware that I can change the default jettison json provider to jackson by
adding the below xml, but what configurations, if any, must I change on the
client side? I'm using cxf-bundle-minimal-2.3.2
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
<property name="mapper">
<bean
class="com.rest.json.ObjectMapperFactoryBean">
</bean>
</property>
</bean>
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
Are there any major pitfalls I should be wary of when deciding to make a change
to either jackson or gson? Thanks.
-Dan
Re: Changing json provider in server and client
Posted by Sergey Beryozkin <sb...@gmail.com>.
By the way, forgot to answer this question:
> Are there any major pitfalls I should be wary of when deciding to make a
>> change
>> to either jackson or gson? Thanks.
>>
>>
I'm presuming you're asking about using Jackson vs the default
Jettison-based provider CXF ships.
Basically, many users are saying Jackson produces better JSON sequences and
is faster. I'm not worried about the speed with which Jettison writes JSON
as IMHO the JSON sequences where the performance difference starts showing
are just too large. Jackson though is moving ahead full speed and is
improving all the time while Jettison is in the maintenance mode.
Jettison is JAXB-driven and this what gives us an opportunity to customize a
lot the incoming and outcoming sequences. Nearly everything one can do for
customizing in/out XML while working with JAXBElementProvider is possible to
do with the Jettison provider. You can have a JSON client deployed and
working long after the original JSON-producing service has been updated to
produce a more involved JSON sequence.
Cheers, Sergey
> -Dan
>>
>>
>>
>>
>>
>
Re: Changing json provider in server and client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
You can register custom providers the same way you did register
ResponseReader.
When injecting clients from Spring you can use either jaxrs:client (proxies)
or use a WebClient constructor injection for creating web clients.
The extension mappings properties are not supported on the client side.
Please see
http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-Injectingproxies
(add jaxrs:providers if needed)
and
http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ConfiguringHTTPclientsinSpring
Cheers, Sergey
On Mon, Jan 24, 2011 at 11:08 PM, Dan King <da...@yahoo.com> wrote:
> Hi,
>
> I'm aware that I can change the default jettison json provider to jackson
> by
> adding the below xml, but what configurations, if any, must I change on the
> client side? I'm using cxf-bundle-minimal-2.3.2
>
> <jaxrs:providers>
> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
> <property name="mapper">
> <bean
> class="com.rest.json.ObjectMapperFactoryBean">
> </bean>
> </property>
> </bean>
> </jaxrs:providers>
> <jaxrs:extensionMappings>
> <entry key="json" value="application/json" />
> <entry key="xml" value="application/xml" />
> </jaxrs:extensionMappings>
>
> Are there any major pitfalls I should be wary of when deciding to make a
> change
> to either jackson or gson? Thanks.
>
> -Dan
>
>
>
>
>