In the web service I was working on, I displayed text on the screen using these methods in HTML:
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello()
{
/**Do some stuff
return "<html> " + "<title>" + "Hello" + "</title>"
+ "<body><h1>" + "Hello World" + "</h1></body></html>";
}
which is displayed on the screen pretty well. To match the project description of the project I'm working on, I worked on moving toward XML output by creating a document, converting it to a string and returning a string. Using @Produces (MediaType.TEXT_XML) shows the XML tree as I expected.
Here's my question: I need to pass this XML data using what the project description calls in the application header Content Content-Type of the application / xml; charset = UTF-8. So what do I need to do to post using @Produces (MediaType.APPLICATION_XML) instead of @Produces (MediaType.TEXT_XML)?