cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sergey.beryoz...@iona.com>
Subject Re: CXF & JSON Response
Date Fri, 06 Jun 2008 10:29:56 GMT
Hi

Current JSON provider on the trunk works with a JAXBContext in tandem and it can only acquire
a JAXBContext
if XMLRootElement annotation is available. Once the patch I'm slowly working upon is commited,
it will be able to acquire contexts 
if an ObjectFactory is available in a package and thus you'd be able to avoid annotating classes
like AlertMsg.
If you'd like to avoid dealing with JAXB at all then another alternative is to use Aegis and
I'm considering adding a basic Aegis 
provider as well.

Trying to provide your own message provider can be a reasonable solution. Runtime won't always
be able to do the (de)serialzation 
the way you expect (dur to a custom nature of a given type or due to the fact it's not capable
of doing the given moment of time) 
and in such cases being able to provide your own provider is really handly

Cheers, Sergey


>I got my CXF JAX-RS service going but the response is cryptic: No message body writer
found for response class : AlertMsg.
>
> Browsing the archive, I found the solution, but it looks "roundabout".  I don't like
the need to annotate my response bean with 
> JAXB stuff.  An analogy is that Web Services (SOAP) do not require annotations/registration
of writers of the response beans...why 
> CXF/JAX-RS?  Thanks...
>
>    @GET
>    @Path("/getAlertMsg/{aId}")
>    @ProduceMime("application/json")
>    public AlertMsg getAlertMsg(@PathParam("aId") String aId)
>
>
> public class AlertMsg implements java.io.Serializable
> {
>   private String a;
>   private String[] b;
> }
>
>
> 

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Mime
View raw message