uCosminexus Application Server, Web Service Development Guide

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

32.2.2 Web Service client side

To use Streaming in the Web Service client, set the com.sun.xml.ws.developer.StreamingAttachmentFeature class while acquiring SEI.

For the com.sun.xml.ws.developer.StreamingAttachmentFeature class, see 19.2.4 (1) com.sun.xml.ws.developer.StreamingAttachmentFeature class.

The following is an example of a Web Service client that uses Streaming. In this example "C:/TMP" directory is specified as the output destination of the temporary file created by Streaming. Perform detailed parsing of SOAP messages containing attachments and output the MIME bodies of 50,000 bytes or more as temporary files.

package com.sample;
 
......
 
public class TestClient {
 
    public static void main(String[] args) {
        try {
            File portrait = new File("portrait.png");
            FileDataSource fileDataSource = new FileDataSource(portrait);
            DataHandler dataHandler = new DataHandler(fileDataSource);
 
            MTOMFeature mtomFeature = new MTOMFeature();
            StreamingAttachmentFeature streamingAttachmentFeature = new StreamingAttachmentFeature("C:/TMP", true, 50000L);
 
            UserInfoService service = new UserInfoService();
            UserInfoImpl port = service.getUserInfoImplPort(mtomFeature, streamingAttachmentFeature);
            DataHandler userData = port.getUserInfo(dataHandler);
            if (userData instanceof StreamingDataHandler) {
                StreamingDataHandler sdh = null;
                try {
                    sdh = (StreamingDataHandler)userData;
                    sdh.moveTo(file);
                    ......
                } finally {
                    try {
                        if (sdh != null) {
                            sdh.close();
                        }
                    } catch(Exception ex) {
                        ......
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}