I am using the RestEasy library to do JAX-RS web services. I am not instantiating a JAXBCon开发者_StackOverflow社区text in my service methods. Is there a way to make JAX-RS include the "<?xml version...?>" header string in the XML it returns? Here is a sample service method from my code:
@GET
@Path("/patients/{patient_id}/diagnoses/portal_edits")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDiagnosisPortalEdits(@Context final UriInfo info,
@PathParam("practice_id") final int practiceId,
@PathParam("patient_id") final long patientId) {
logger.info(SERVICE_NAME + ".getDiagnosisPortalEdits: " + info.getPath());
final DiagnosisPortalEdits diagnosisPortalEdits = new DiagnosisPortalEdits();
diagnosisPortalEdits.getDiagnosisPortalEdits().addAll(DefaultDiagnosisPortalEditService.doLoadForPatientId(practiceId,
patientId));
return Response.ok(diagnosisPortalEdits).build();
}
Add the following annotation to the class:
@XmlHeader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
精彩评论