From: Bill B. <bb...@re...> - 2012-05-01 23:46:49
|
Did this work with a previous version of Resteasy? On 5/1/12 3:24 PM, Zhang, Yi wrote: > Hi, > > I'm trying to turn on schema validation (and secure XML processing) on the Unmarshaller class but have not been able to get it to work. I've tried both Resteasy 2.3.1.GA and 2.3.3.Final on JBoss 5.1.2 with no success. > > I also tried to use the annotation as a parameter annotation as suggested in https://issues.jboss.org/browse/RESTEASY-551 (see code snippets below), but still no luck. Also, this post indicated the same problem: http://stackoverflow.com/questions/7570326/jboss-resteasy-jax-rs-jaxb-schema-validation-with-decorator > > Any suggestions appreciated! > > Here is the code: > // Annotation > @Target( > { > ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD > }) > @Retention(RetentionPolicy.RUNTIME) > @Decorator(processor = SecureXMLProcessor.class, target = Unmarshaller.class) > public @interface SecureXML > { > } > > // The decorator implementation > @DecorateTypes( > { > MediaType.APPLICATION_XML, MediaType.TEXT_XML > }) > public class SecureXMLProcessor implements DecoratorProcessor<Unmarshaller, SecureXML> > { > public Unmarshaller decorate(Unmarshaller target, SecureXML annotation, Class type, Annotation[] annotations, > MediaType mediaType) > { > target.setSchema(mySchema); > return target; > } > } > > // The JAX-RS resource > @POST > @Path("/") > @Consumes( > { > MediaType.APPLICATION_XML > }) > @Produces( > { > MediaType.APPLICATION_XML > }) > public Response registerApplication(@SecureXML Application application) > > Yi -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |