uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

25.15.1 Combination of Java types and MIME media types available for an HTTP request entity

The following table lists the combination of Java types and MIME media types available for the entity body of an HTTP request. Note that the operation of the JAX-RS engine is not guaranteed for other combinations.

Table 25-6 Combination of Java types and MIME media types available for the entity body

No. Java Type charset#1 Content-Type HTTP header Content-Type HTTP header#2
(JAX-RS engine)
1 byte[] N Any (*/*) application/octet-stream
2 java.lang.String Y Any (*/*) text/plain
3 java.io.InputStream N Any (*/*) application/octet-stream
4 java.io.Reader Y Any (*/*) text/plain
5 java.io.File N Any (*/*) application/octet-stream
6 javax.activation.DataSource N Any (*/*) application/octet-stream
7 javax.xml.transform.Source#3 N Any (*/*) application/xml
8 javax.xml.bind.JAXBElement<String>#4 Y ext/xml,
application/xml,
application/*+xml
application/xml
9 JAXB class#4 annotated with the XmlRootElement annotation Y text/xml,
application/xml,
application/*+xml
application/xml
10 javax.ws.rs.core.MultivaluedMap<String,String> Y application/x-www-form-urlencoded application/x-www-form-urlencoded
11 javax.ws.rs.core.StreamingOutput N Any (*/*) application/octet-stream
12 org.w3c.dom.Document N Any (*/*) application/xml
13 java.awt.image.RenderedImage N image/jpeg application/octet-stream
14 javax.ws.rs.core.GenericEntity<T>#5 D MIME media type similar to the Type specified in T. MIME media type similar to the Type specified in T.
15 POJO#6 N#7 application/json application/octet-stream

Legend:
Any (*/*): Indicates that all the MIME media types are supported.

#1
Indicates whether the charset parameter information, if included in the Content-Type HTTP header, is considered during conversion to an HTTP request.
Y: Considered. When the Content-Type HTTP header does not include the charset parameter, UTF-8 is assumed.
D: Depends on the type specified in T.
N: Not considered.

#2
If the Content-Type HTTP header is not specified in the ClientRequest object or the WebResource object and when the entity is non-null, specify the Content-Type HTTP header of an HTTP request by considering the Content-Type specified in this column.
The operation when the entity is null is the same as the operation when the Content-Type HTTP header is not set in the HttpURLConnection object before making an HTTP request.

#3
You can use the following implementation classes:
- javax.xml.transform.stream.StreamSource
- javax.xml.transform.sax.SAXSource
- javax.xml.transform.dom.DOMSource

#4
When the MIME Media type is application/fastinfoset or application/json, the operation ends normally without any error.

#5
In T, you can specify the types described in No.1 to No.13, and No. 15 in the table.

#6
Enable JSON POJO mapping. The operation when JSON POJO mapping is disabled is the same as the operation when an unsupported Java type is specified in the entity parameter. For details on how to enable JSON POJO mapping, see 18. Mapping JSON and POJO.

#7
Do not add the charset parameter in the Content-Type HTTP header.

If the specified Java type is an unsupported type and if the value is not null, an error occurs (KDJJ10032-E and KDJJ18888-E) and the ClientHandlerException exception is thrown. However, if the specified Java type is javax.mail.internet.MimeMultipart and the MIME media type is multipart/*, the operation ends normally without any error.

With the following Java types, if there is a MIME media type that an HTTP request entity body cannot use, an error occurs (KDJJ10032-E and KDJJ18888-E) and the ClientHandlerException exception is thrown:

  1. javax.xml.bind.JAXBElement <String>
  2. JAXB class annotated with the XmlRootElement annotation
  3. javax.ws.rs.core.MultivaluedMap<String, String>
  4. java.awt.image.RenderedImage
  5. POJO

However, if the MIME media type of an HTTP request entity body in 1 or 2 is application/fastinfoset or application/json, the operation ends normally without any errors.

If an exception is thrown during the processing of an HTTP request and HTTP response, an error (KDJJ18888-E) occurs and the ClientHandlerException exception that wraps this exception is thrown.

Notes for the types of HTTP methods are as follows: