users@jersey.java.net

Re: [Jersey] XmlRootElement not added to generated java sources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 26 Aug 2009 10:03:52 +0200

On Aug 25, 2009, at 10:49 PM, vaidya nathan wrote:
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> The second part is as follows.(II)
>
> When I try to use the jersey client wrapper and have the
> request to be one without the XmlRootElement (I way)
> clientResponse =
> createWebResource().accept(contentType).post(ClientResponse.class,
> request);
>
>
> What is the type of "request" ?
> The request is an object of generated elemname (generated from xjc).
> I will mail to that group.

OK, this looks like a bug in 1.0.3. It all depends if the type of
"request" is annotated with @XmlRootElement or not.

As a work around try setting the content type:

   clientResponse = createWebResource().
       accept(contentType).
       type("application/xml").
       post(ClientResponse.class, request);

and see what happens.

Omitting the content-type should result in the setting of
"application/xml" by default for supported JAXB beans.

But i can also reproduce this, in the trunk, for types that are not
supported (e.g. a JAXB bean annotated with @XmlType). I have a fix in
place that is currently being tested.

Paul.