Mapping the request and response entity body with Java types

JAX-RS uses javax.ws.rs.ext.MessageBodyReader for mapping the HTTP request entity body to an appropriate Java type. On the other hand, javax.ws.rs.ext.MessageBodyWriter is used for mapping the Java type returned by a resource class method to the appropriate HTTP response entity body representation, such as JSON, XML, and text. The MessageBodyReader and MessageBodyWriter implementations will raise javax.ws.rs.WebApplicationException if they do not know how to convert the input data.

JAX-RS offers the default content handlers (entity providers) for all common data types. Here is a list of the Java types supported by JAX-RS by default:

  • JAX-RS supports mapping between the following Java data types and request-response entity bodies for all media forms: byte[], java.lang.String, java.io.InputStream, java.io.Reader, java.io.File, javax.activation.DataSource, and javax.xml.transform.Source
  • JAX-RS supports the javax.ws.rs.core.MultivaluedMap<K,V> type for reading or writing the form content, whose media type is application/x-www-form-urlencoded
  • JAX-RS supports the javax.xml.bind.JAXBElement type for reading or writing content represented using the XML media types (text/xml, application/xml, and application/*+xml)
  • JAX-RS supports the java.lang.Boolean, java.lang.Character, and java.lang.Number types for reading and writing the Boolean strings (true or false), characters, and numerical content presented in the text/plain media type
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.157.34