users@jersey.java.net

[Jersey] Re: Schema compliant marshalling

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 12 Sep 2011 15:34:40 +0200

Hi Veit,

You may want to try implement a custom ContextResolver (see [1]) for both
JAXB Marshaller and Unmarshaller and use setSchema method [2] on both
to switch validation on.

HTH,

~Jakub

[1]http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/ext/ContextResolver.html
[2]http://download.oracle.com/javase/6/docs/api/javax/xml/bind/Marshaller.html#setSchema%28javax.xml.validation.Schema%29

On 11.9.2011 11:06, Veit Guna wrote:
> Hi.
>
> I'm using Jersey for implementing a REST service. I've managed to add
> schema validation for incoming requests
> using the MessageBodyReader. That works so far. Now I've encountered,
> that responses generated by Jersey aren't
> schema compliant. Is there a way to tell Jersey to use a specific xml
> schema when marshalling the response?
>
> Thanks
> Veit
>
>