Rest easy has JAXB Decorators, so you can add to marshaller properties before marshalling.
1.- Create a DecoratorProcessor
@DecorateTypes({"application/xml"})
public class NameSpaceProcesor implements DecoratorProcessor<Marshaller, CustomMarshaller> {
/* Override method</br>
* @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;
}
}
2.- Create your Decorated Annotation.
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Decorator(processor = NameSpaceProcesor.class, target = Marshaller.class)
public @interface CustomMarshaller {}
3.- Then annotate your method with the decorator.
@GET
@CustomMarshaller
@Path("cfdi")
@Produces({"application/xml", "application/json"})
// /consulta/cfdi?uuid=0a7da89b-a328-4e54-9666-e1a3d7a10b0a
public Comprobante cfdi(...){}
Hope this help some one else.