uCosminexus Application Server, Web Service Development Guide

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

28.4.1 Mapping an attachment to a SOAP Message (wsi:swaRef format)

This subsection describes the settings when you map an attachment to a SOAP message. For details about the mapping rules, check this subsection together with 28.4.2 Precautions on mapping an attachment to a SOAP message (wsi:swaRef format).

Organization of this subsection
(1) HTTP header
(2) HTTP body
(3) Boundary string of the HTTP header and HTTP body

(1) HTTP header

The following table describes the values set for the fields and parameters of the HTTP header when attachments are used:

Table 28-5 Values set in the fields and parameters of HTTP header

No. Fields name Parameter name Settings
1 Content-Type -- multipart/related is set.
2 type

SOAP 1.1 specifications
text/xml is set.

SOAP 1.2 specifications
application/soap+xml is specified.
3 boundary The boundary string of the MIME part is set.

Legend:
--: Indicates that the name is directly set in Content-Type.

When 1 or more non-root MIME parts are enumerated (when SOAP Messages with attachments are sent and received), multipart/related is set in the Content-Type. If there is no MIME part, text/xml is set for the SOAP 1.1 specifications and application/soap+xml is set for the SOAP 1.2 specifications.

(2) HTTP body

The HTTP body consists of the root part, attachment part, and boundary string of each part. The following points describe the contents generated in each part and boundary string and the settings when you use attachments:

(a) MIME header of the root part

The following table lists the values set up in the Content-Type field of the root part when you use attachments:

Table 28-6 Values set up in the root part field

No. Field name Settings
1 Content-Type

SOAP 1.1 specifications
text/xml is set up.

SOAP 1.2 specifications
application/soap+xml is set up.
2 Content-Id Globally unique value"+"@"+"jaxws.cosminexus.com is set up.
(b) MIME body of the root part

When you use attachments, SOAP Envelope is saved in the MIME body of the root part as it is. The CID URL scheme is used as the method for referencing the attachments from the SOAP Body in the SOAP Envelope.

The following is the CID URL scheme type:

"cid:"  +  Content-Id-of-the-attachment-part
(c) Boundary string of the MIME header and MIME body of the root part

"CRLF" is set as the boundary string between the MIME header and MIME body of the root part.

(d) MIME header of the attachment part

The following table describes the values set in the MIME header of the attachment part when attachments are used:

Table 28-7 Values set in the MIME header of the attachment part

No. Fields name Parameter name Settings
1 Content-Type -- MIME type#1 is set according to the attachment type.
2 charset The character code#2 is specified when the DataHandler object that is generated, is set.
3 Content-Transfer-Encoding None "binary" is set.
4 Content-Id None "Globally unique value" + "@" + "jaxws.cosminexus.com" is set.

Legend:
--: Indicates that the name is directly set in Content-Type.

#1
The settings for the Content-Type field differ as follows depending on the method of generating the DataHandler object:
  • When the object is generated using DataHandler(DataSource) constructor
    For FileDataSource, the MIME type determined by JAF from the extension of the input attachment is set as the value of Content-Type field. For details about the mapping between the attachment extension and the MIME types, see 28.4.2(3) Mapping between the attachment extension and MIME types.
  • When the object is generated using DataHandler(Object, String) constructor
    When the DataHandler object is generated, the contents specified in the second argument of the constructor (MIME type) are set as the value of the Content-Type field as it is.

#2
For example, when the following DataHandler object is generated, the charset parameter value 'UTF-8' specified in the second argument is set in charset of Content-Type:
DataHandler dhandler = new DataHandler ("abcde", "text/plain; charset=Shift_JIS");
The javax.activation.DataHandler type that is a Java type of attachment is a type of JavaBeans Activation Framework (JAF); therefore, you can specify any MIME type attachment. For details about the correspondence between the attachment extension and the MIME types set by default when FileDataSource is used to generate the DataHandler object, see 28.4.2(3) Mapping between the attachment extension and MIME types.
(e) MIME body of the attachment part

The binary data indicating the attachment contents is stored in the MIME body of attachment part.

(f) Boundary string of the MIME header and MIME body of the attachment part

"CRLF" is set as the boundary string of the MIME header and MIME body of the attachment part, as for the root part.

(g) Boundary string between MIME parts

The following string is set as the boundary string between the root part and attachment part and between the attachment parts:

"CRLF" + "--" + "Boundary-parameter-value-of-HTTP-header"
(h) End string of the MIME part

The following string is set as the end string at the end of MIME part:

"CRLF" + "--" + "<Boundary-parameter-value-of-HTTP-header>" + "--"

(3) Boundary string of the HTTP header and HTTP body

"CRLF" is set as the boundary string between the HTTP header and HTTP body.