cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: Long vs long...
Date Fri, 09 Dec 2011 16:15:35 GMT
On 09/12/11 11:10, Jeff Wang wrote:
> I have a class with the ID as Long (I like to use null to indicate not
> yet stored, as opposed to a magic-number that is defined as the
> not-yet-stored number.  However, when JAXB is done serialzing it, the
> type comes out as "@xsi.type":"xs:long", which, when ClientProxyImpl
> tries to deserialize, comes up with the error
> java.lang.IllegalArgumentException: prefix xs is not bound to a
> namespace.

Is it a JSON sequence ? The error is side-effect of this xsi type which 
is probably not needed for this particular case; you'd need to set up a 
namespace map for JSONProvider if you prefer to keep 'xsi' & 'xs'

> There are also problems passing in JSON strings as {"user" : {'id' :
> 5}} results in
> cannot be cast to java.lang.Long.  However, PathParams and QueryParams
> assign properly to types of Long.

How does the method signature look like and where is this exception 
originating from ?

> What are the best ways to address the serialization and
> deserialization problem?  I read about setting read and write xsi
> boolean values in JSONProvider, How do I do that? (and if I set them
> to false, what other affects could it have?

set either 'writeXsiType' to false or 'readXsiType' to false on 
org.apache.cxf.jaxrs.provider.JSONProvider and register it in 
jaxrs:providers (on either side, assuming Spring is used) or say 
WebClient.create("someaddress", Collections.singletonList(provider));

Side-effect is that the consumer won;t be able to populate beans 
properly if you get subtypes of a given type serialized, but it is not 
the main JSON area I guess...

Using Jackson is also an option

Cheers, Sergey

> thanks
> Jeff

Sergey Beryozkin

Talend Community Coders


View raw message