How do I select Application / XML or Text / XML as Media Type?

I am learning jax-rs. My problem is I don't know how to select Application / XML or Text / XML, even I read more articles about them on the internet. Can anyone describe this simply as application / XML support instead? why should i use text / XML?

+3


source to share


2 answers


Media Type text/xml

is an alias for the media type application/xml

.

More on RFC 7303 :

9.1. application / xml

Type name: application

Subtype name: xml

[...]



9.2. text / xml Register

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() {
    ...
}

      

0


source


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?

-1


source







All Articles