uCosminexus Application Server, Web Service Development Guide

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

25.15.2 Combination of Java types and MIME media types available for an HTTP response entity

The following table lists the combination of Java types and MIME media types that can be used in the return values.

Table 25-7 Combination of Java types and MIME media types that can be used in the return value of an entity body

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

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 injection to an HTTP response.
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
The JAX-RS engine creates a temp directory on the local computer and saves the temporary file.

#3
You can use the following implementation classes:
- javax.xml.transform.stream.StreamSource
- javax.xml.transform.sax.SAXSource
- javax.xml.transform.dom.DOMSource
Note that when you use javax.xml.transform.stream.StreamSource or javax.xml.transform.sax.SAXSource, receive the HTTP response with the generic type (ClientResponse) and obtain the entity object by using the getEntity() method of the ClientResponse class. At this time, make sure you invoke the bufferEntity() method before invoking the getEntity() method. For details on how to receive an HTTP response by using a generic type (ClientResponse), see 11.4.1 Use case of a Web resource client.

#4
Used as T in No. 14 in the table. Operation is not guaranteed for any other usage.

#5
If the MIME media type is application/fastinfoset or application/json, the operation ends normally without any errors.

#6
Used as T in No.14 in this table. In T, you can specify the types described in No.2 to No.12, and No.15 in the table. Operation is not guaranteed for any other usage.

#7
In T, you can specify the types described from No. 2 to No. 13, and No. 15 in the table.

#8
Enable the JSON POJO mapping. The operation when the 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 the JSON POJO mapping, see 18. Mapping JSON and POJO.

If the specified Java type is an unsupported type, an error occurs (KDJJ10031-E and KDJJ18888-E) and the ClientHandlerException exception is thrown.

If the return value is the following Java type and the MIME media type is a type that cannot be used by the entity body of an HTTP response, an error occurs (KDJJ10031-E or KDJJ18888-E) and the ClientHandlerException exception is thrown.

If the IOException exception is thrown during conversion from the HTTP response entity body, an error occurs (KDJJ18888-E) and the ClientHandlerException exception is thrown.

If an exception other than the IOException exception is thrown during conversion from the HTTP response entity body, the corresponding exception is thrown. To check the log, use the J2EE server log files instead of the JAX-RS functionality log files.

With the entity parameter java.awt.image.RenderedImage, if the Content-Type HTTP header is image/*, an error occurs (KDJJ18888-E) and the ClientHandlerException exception that wraps the java.io.IOException exception is thrown.

With the entity parameter com.cosminexus.jersey.api.client.GenericType<T>, if an HTTP response contains an entity body, and if T is of the type described in No.1 in the table, an error occurs (KDJJ10031-E and KDJJ18888-E) and the ClientHandlerException exception is thrown.

With the entity parameter com.cosminexus.jersey.core.provider.EntityHolder<T>, if an HTTP response contains an entity body, an error (KDJJ10003-E) occurs and the javax.ws.rs.WebApplicationException exception is thrown in one of the following cases:

If the client APIs operate on the J2EE server, the entity body contains maximum 10,000 form parameters by default. If the entity parameter type is javax.ws.rs.core.MultivaluedMap<String, String>, or com.cosminexus.jersey.core.provider.GenericType<EntityHolder<javax.ws.rs.core.MultivaluedMap<String, String>>> and if the number of response parameters exceed the specified value, the RuntimeException exception is thrown. Change the value in the webserver.connector.limit.max_parameter_count property of the user property file for J2EE servers (usrconf.properties) as and when required. To check the log, use the J2EE server log files instead of the JAX-RS functionality log files.

If the Content-Type HTTP header does not exist in the HTTP response, the MIME media type is considered to be the application/octet-stream.