uCosminexus Application Server, Web Service Development Guide
This subsection describes about how to obtain the attachment data. The "dhandler" indicated in each example shows the received javax.activation.DataHandler object.
To obtain the received attachment as the java.io.InputStream object, obtain the java.io.InputStream object using the getInputStream method from the received javax.activation.DataHandler object.
java.io.InputStream stream = dhandler.getInputStream(); |
To obtain the received attachment as the javax.activation.DataSource object, obtain the javax.activation.DataSource object linked using the getDataSource method from the received javax.activation.DataHandler object.
javax.activation.DataSource datasource = dhandler.getDataSource(); |
The procedure for obtaining the received attachment as a Java object is as follows. An example of obtaining the java.awt.Image object is described here.
java.lang.Object content = dhandler.getContent(); |
java.lang.String mimetype = dhandler.getContentType(); Obtained-mimetype-contents image/jpeg |
java.awt.Image attachment = (java.awt.Image) content; |
To obtain the received attachment as a Java object:
java.lang.Object content = dhandler.getContent(); |
java.lang.String mimetype = dhandler.getContentType(); Obtained-mimetype-contents text/plain; charset=UTF-8 |
java.lang.String attachment = (java.lang.String) content; |
Receiving a SOAP message of the MIME Multipart or related structure that contains an attachment of the wsi:swaRef format enables you to handle the SOAP messages as an attachment of the streamed wsi:swaRef format. Because the receiving process requires all the data to be imported from the input stream of the javax.activation.DataHandler object to completely receive the attachment of the wsi: swaRef format, the sender is in stand-by status until all the data is imported from the input stream.To resolve this condition, you must either import all the data from the java.io.InputStream object of the javax.activation.DataHandler object or write the data from the input stream to the output stream by using the writeTo(java.io.OutputStream) method of the javax.activation.DataHandler class.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.