uCosminexus Application Server, Web Service Development Guide

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

20.1.31 xsd:schema element

This subsection describes the support range of the xsd:schema element.

Organization of this subsection
(1) xmime:expectedContentTypes attribute (xsd:schema element)

(1) xmime:expectedContentTypes attribute (xsd:schema element)

When xsd:base64Binary is specified in the type attribute of the xsd:element element, which is a WSDL schema declaration, you can explicitly specify the MIME type by using the xmime:expectedContentTypes attribute to associate the Base64 format data with a Java type corresponding to the MIME type. The following table describes whether you can code the xmime:expectedContentTypes attribute for the xsd:element element, which is a WSDL schema declaration.

Table 20-1 Codability of the xmime:expectedContentTypes attribute

No. Parameters of wsdl:message that reference the xsd:element element Codability of the xmime:expectedContentTypes attribute for the xsd:element element
1 wsdl:input Y#1
2 wsdl:output Y#1
3 wsdl:fault N#2

Legend:
Y: Can be coded.
N: Cannot be coded.

#1
When the type of WSDL part is inout, specify the same MIME type as the value of the xmime:expectedContentTypes attribute of the xsd:element element referenced from the wsdl:input element, and as the value of the xmime:expectedContentTypes attribute of the xsd:element element referenced from the wsdl:output element. If a different MIME type is specified, the operations are not guaranteed.

#2
The operations are not guaranteed if you specify the xsd:element element in which the xmime:expectedContentTypes attribute is coded in the fault message.

To map WSDL to the Java type when the xmime:expectedContentTypes attribute is specified in the xsd:element element, map the xsd:base64Binary type with the xmime:expectedContentTypes attribute of the WSDL to the Java type. The following figure shows an example of mapping the WSDL to a Java type.

Figure 20-1 Example of mapping the WSDL to a Java type

[Figure]

Do not code parameters other than the charset parameter of text/xml and application/xml in the MIME type to be specified in the xmime:expectedContentTypes attribute. If a parameter other than the charset parameter of text/xml and application/xml are coded, the operations are not guaranteed.

The Java type to be mapped from WSDL changes depending on the MIME type specified in the xmime:expectedContentTypes attribute. The following table describes the relationship between the MIME types coded in the xmime:expectedContentTypes attribute and the associated Java types.

Table 20-2 Value of the xmime:expectedContentTypes attribute and the associated Java types

No. Value of the xmime:expectedContentTypes attribute (MIME type) Associated Java type
1 application/xml javax.xml.transform.Source
2 image/png#1 java.awt.Image#2
3 image/jpeg#1
4 Code the above MIME types delimited with commas (Example: image/png, image/jpeg)#3
5 image/*#3
6 text/plain java.lang.String
7 text/*#4 javax.activation.DataHandler
8 text/xml#5 javax.xml.transform.Source
9 Other than above mentioned #4, #6 javax.activation.DataHandler

#1
To associate the image type that is not mentioned in the table with a Java type, specify application/octet-stream in the xmime:expectedContentTypes attribute and associate with the javax.activation.DataHandler class.

#2
Complies with the JAXB specifications. The java.awt.Image class is an abstract class that expresses the graphical image in the Java SE specifications and for which the data format is not defined. When the image data is instantiated by using this association, you can only store the decoded information in a concrete class instance. Therefore, when you send an image for which information can be reduced during encoding, such as the JPEG format, as an attachment, the instance at the receiving side might differ from the instance at the sending side and from the original data.
If you want to handle the image as is in the original format, use the MIME type (such as application/octet-stream) that is mapped to javax.activation.DataHandler.

#3
When similar types such as "image/png, image/jpeg" or "image/*" are specified as the MIME type, the Content-Type field value of the MIME header in the attachment part of the SOAP message to be sent is the initial value (image/png) when the java.awt.Image type is used.

#4
When text/* or a MIME type that is not mentioned in the table is specified as the MIME type, the Content-Type field value of the MIME header in the attachment part of the SOAP message to be sent is the initial value (MIME type of the javax.activation.DataHandler object) when the javax.activation.DataHandler type is used.

#5
When text/xml is specified as the MIME type, the Content-Type field value of the MIME header in the attachment part of the SOAP message to be sent is the initial value (application/xml) when the javax.xml.transform.Source type is used.

#6
This includes cases when a MIME type of a different type name is coded using commas as delimiters (example: image/png, text/plain).

The MIME type specified in the xmime:expectedContentTypes attribute is mapped to the value of the javax.xml.bind.annotation.XmlMimeType annotation that is annotated in the JavaBean class corresponding to the element coding the xmime:expectedContentTypes attribute, from among the JavaBean classes that are automatically generated by the cjwsimport command. The following figure shows an example of mapping the automatically generated JavaBean class from the WSDL.

Figure 20-2 Mapping the automatically generated JavaBean class from the WSDL

[Figure]

(a) Importing the Namespace "xmime"

To map the WSDL to a Java type, you use the attribute xmime:expectedContentTypes existing in the Namespace xmime, but the Namespace xmime need not be imported using the xsd:import element with the JAX-WS.

When you use the WSDL created with the cjwsgen command, you must import the Namespace xmime as and when required. The following is an example of importing the Namespace xmime:

<wsdl:definitions targetNamespace="http://localhost"
 xmlns:intf="http://localhost"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xmime="http://www.w3.org/2005/05/xmlmime" ......>
 <wsdl:types>
 <xsd:schema targetNamespace="http://localhost">
  <xsd:import namespace="http://www.w3.org/2005/05/xmlmime"/>
  <xsd:element name="setPhotoData" type="intf:setPhotoData"/>
  <xsd:complexType name="setPhotoData">
  <xsd:sequence>
   <xsd:element name="in0" type="xsd:base64Binary" xmime:expectedContentTypes="image/jpeg"/>
  </xsd:sequence>
  </xsd:complexType>
  ......
 </xsd:schema>
 </wsdl:types>
 ......