cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Oster" <>
Subject Re: Re: @XmlRootElement with jax-rs/jax-ws
Date Wed, 05 Aug 2009 15:32:19 GMT

>>AFAIK, in case of JAXWS, additional JAXB elements/classes are generated.
Correct, though in the "wrapped" mapping, I don't believe these classes are
used.  In any event, I want the REST interface to return the XML of the
"Book" not the "getBookResponse".


From: Sergey Beryozkin <>
Date: Wed, 5 Aug 2009 01:39:59 -0700 (PDT)
To: <>
Subject: Re: @XmlRootElement with jax-rs/jax-ws


AFAIK, in case of JAXWS, additional JAXB elements/classes are generated. For
ex, if it's a method called 'getBook' returning Book then it will be a
getBookResponse class that will be generated.

I was also assuming that if ObjectFactory had methods returning JAXBElements
then there'd be no need in updating the generated classes with
@XmlRootElement which apparently is not the case.

I don't think that in case of JAX-RS we can generate wrappers too.
Dan - is there anything that can be done at a pure JAXB level for users to
avoid explicitly adding XMLRootElement ? It appears there's no solution

thanks, Sergey

Scott Oster-2 wrote:
> I am trying to add jax-rs annotations to an existing service
> implementation
> generated by wsdltojava (wrapped style).  The POJO returned by my
> operation
> is defined in a standalone XSD, and understandably doesn¹t have the
> @XmlRootElement annotation (for the reasons described here
> My web service works fine, but my REST call dies with the error:
> unable to marshal type "..." as an element because it is missing an
> @XmlRootElement annotation
> If I add the @XmlRootElement annotation to the POJO, it works fine, but
> from
> the documentation it seems I shouldn¹t have to do this (and I don¹t want
> to,
> as it is generated code).
> In reading this bug:
> It appears this was an issue and should be ³fixed² in the version I am
> using
> (2.2 and trunk) but it¹s not clear if I am expected to configure
> something.
> The documentation here:
> states:
> ³Alternatively to using @XmlRootElement and Collection wrappers, one can
> provide an Object factory which will tell JAXB how to
> marshal a given type (in case of Collections - its template type).²
> I have an ObjectFactory, generated by wsdl2java (and it looks correct),
> but
> I¹m not sure how I am supposed to ³provide² it other than have it on the
> classpath (as I do).  Could you expand upon what exactly one needs to do
> to
> get this to work?
> Thanks,
> Scott

View raw message