uCosminexus Application Server, Web Service Development Guide
The javax.xml.bind.annotation.XmlMimeType annotation is a JAXB annotation that is used for associating Java type and MIME type, and this annotation is used for associating the Java type and MIME type when using the javax.xml.ws.soap.MTOM annotation.
You can specify the javax.xml.bind.annotation.XmlMimeType annotation in the service method argument, and the return value possessed by the Web Service Implementation Class containing SEI or implicit SEI, or the getter method of user definition type. The operation is not guaranteed if specified at any other location (fields such as service method argument, a return value, user definition exceptions possessed by the Web Service Implementation Class without implicit SEI).
When the javax.xml.bind.annotation.XmlMimeType annotation is annotated in SEI, the WSDL file issued by the Web Service JAX-WS engine and the WSDL file generated by the cjwsgen tool is assigned by the xmime:expectedContentTypes attribute that possesses a value specified in the value element of the annotation to the schema element that corresponds to the Java type with annotated javax.xml.bind.annotation.XmlMimeType.
The following figure shows an example using the javax.xml.bind.annotation.XmlMimeType annotation.
Figure 16-19 Example using the javax.xml.bind.annotation.XmlMimeType annotation
When Java type and MIME type are not associated, the javax.xml.bind.annotation.XmlMimeType annotation need not be annotated. In this case, the initial value that corresponds to the Java type is used as a value in the Content-Type field in the attachment part of the message that is sent in the attachment of the MTOM/XOP specification format.
The following figure shows an example where the javax.xml.bind.annotation.XmlMimeType annotation is not used.
Figure 16-20 Example where javax.xml.bind.annotation.XmlMimeType annotation is not used
The following table lists the Java type with which the MIME type can be associated and its specification location by annotating the javax.xml.bind.annotation.XmlMimeType annotation. Note that the operation is not guaranteed if the javax.xml.bind.annotation.XmlMimeType annotation is annotated with any other type.
Table 16-17 Java type where MIME type can be associated and its specification location
| No | Java type | Possibility of association | Specification location | |||
|---|---|---|---|---|---|---|
| Method argument | Method return value | User definition type field | User definition exception fields | |||
| 1 | java.awt.Image | Y#1 | Y | Y | A#2 | N#3 |
| 2 | javax.xml.transform.Source | Y | Y | Y | A #2 | N #3 |
| 3 | javax.activation.DataHandler | Y | Y | Y | A #2 | N #3 |
| 4 | java.awt.Image array type | A #4 | Y | Y | A #2 | N #3 |
| 5 | javax.activation.DataHandler array type | A #4 | Y | Y | A #2 | N #3 |
| 6 | java.util.List<Image> | Y | Y | Y | A #2 | N #3 |
| 7 | java.util.List<DataHandler> | Y | Y | Y | A #2 | N #3 |
| 8 | javax.xml.ws.Holder<Image> | Y | Y | N #5 | N #5 | N #5 |
| 9 | javax.xml.ws.Holder<Source> | Y | Y | N #5 | N #5 | N #5 |
| 10 | javax.xml.ws.Holder<DataHandler> | Y | Y | N #5 | N #5 | N #5 |
package com.sample;
import java.awt.Image;
public class UserData {
private Image image;
public void setImage(Image image) {
this.image = image;
}
@javax.xml.bind.annotation.XmlMimeType("image/png")
public Image getImage() {
return image;
}
}
|
The value element specifies the text expression of the MIME type that is associated with the Java type where the javax.xml.bind.annotation.XmlMimeType annotation is annotated.
The MIME type to be specified must be the appropriate MIME type for the Java type where the annotation is annotated. If the MIME type is inappropriate, or multiple MIME types are mentioned by separating them by using a comma, the operation is not guaranteed. Also, in the MIME type to be specified, do not mention the parameters other than the charset parameters of the text/xml and the application/xml. If the parameters other than the charset parameters of the text/xml and the application/xml are mentioned, the operation is not guaranteed.
The following table describes the MIME types that can be specified in the Java type.
Table 16-18 MIME types that can be specified in the Java type
| No | Java type | MIME type that can be specified in the value element |
|---|---|---|
| 1 | java.awt.Image,java.awt.Image array type, java.util.List<Image>, or javax.xml.ws.Holder<Image> | image/png#1 |
| 2 | image/jpeg#1 | |
| 3 | image/*#2 | |
| 4 | javax.xml.transform.Source or javax.xml.ws.Holder<Source> | text/xml#3 |
| 5 | application/xml | |
| 6 | javax.activation.DataHandler, javax.activation.DataHandler array type, java.util.List<DataHandler>, or javax.xml.ws.Holder<DataHandler> | Other than above-mentioned#4 |
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.