uCosminexus Application Server, Web Service Development Guide

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

32.2.4 Operating streamed attachments

When using Streaming, if you receive a SOAP message of MIME Multipart/Related structure containing an attachment, the received attachment is mapped to the com.sun.xml.ws.developer.StreamingDataHandler class instead of the javax.activation.DataHandler class in JAX-WS, and can be handled as a streamed attachment.

For the com.sun.xml.ws.developer.StreamingDataHandler class, see 19.2.4 (2) com.sun.xml.ws.developer.StreamingDataHandler class.

The following is an example of operating a streamed attachment. In this example, the streamed attachment is output with a different name as "C:/portrait.png":

package com.sample;
 
......
 
@MTOM
@StreamingAttachment(dir="C:/TMP", parseEagerly=true, memoryThreshold=50000L)
@BindingType(...)
public class UserInfoImpl implements UserInfo {
 
    public DataHandler getUserInfo(DataHandler dataHandler)
        throws UserDefinedException {
        if (dataHandler instanceof StreamingDataHandler) {
            File file = new File("C:/portrait.png");
            StreamingDataHandler sdh = null;
            try {
                sdh = (StreamingDataHandler)dataHandler;
                sdh.moveTo(file);
                ......
            } finally {
                try {
                    if (sdh != null) {
                        sdh.close();
                    }
                } catch(Exception ex) {
                    ......
                }
            }
        }
    }
}
Organization of this subsection
(1) Points to be noted when operating the streamed attachments

(1) Points to be noted when operating the streamed attachments

The following are the points to be noted when operating the streamed attachments: