Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Rest easy has JAXB Decorators, so you can add to marshaller properties before marshalling.</p> <p>1.- Create a DecoratorProcessor</p> <pre><code>@DecorateTypes({"application/xml"}) public class NameSpaceProcesor implements DecoratorProcessor&lt;Marshaller, CustomMarshaller&gt; { /* Override method&lt;/br&gt; * @see org.jboss.resteasy.spi.interception.DecoratorProcessor#decorate(java.lang.Object, java.lang.annotation.Annotation, java.lang.Class, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType) */ @Override public Marshaller decorate(Marshaller target, CustomMarshaller arg1, @SuppressWarnings("rawtypes") Class arg2, Annotation[] arg3, MediaType arg4) { try { target.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); target.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,"http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd"); } catch (PropertyException e) { } return target; } } </code></pre> <p>2.- Create your Decorated Annotation.</p> <pre><code>@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Decorator(processor = NameSpaceProcesor.class, target = Marshaller.class) public @interface CustomMarshaller {} </code></pre> <p>3.- Then annotate your method with the decorator.</p> <pre><code> @GET @CustomMarshaller @Path("cfdi") @Produces({"application/xml", "application/json"}) // /consulta/cfdi?uuid=0a7da89b-a328-4e54-9666-e1a3d7a10b0a public Comprobante cfdi(...){} </code></pre> <p>Hope this help some one else.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload