How do I select Application / XML or Text / XML as Media Type?
Media Type text/xml
is an alias for the media type application/xml
.
More on RFC 7303 :
Type name: application
Subtype name: xml
[...]
Registration information for
text/xml
in all respects is the same as above for application / xml ( section 9.1 ), except that "Type name" is "text".
In JAX-RS, you can use the following to support both:
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public Response foo() {
...
}
source to share
I think they answer your question here What is the difference between text / xml vs application / xml for webservice response
In practice, it all depends on the value of the Accept header in the HTTP request, we used it to return pretty well-formed XML when the Accept request header includes text / xml and minified single line XML, when the Accept Accept header includes application / xml when in doubt. ask yourself who will read the answer, the app or the person?
source to share