Example usage for javax.xml.soap SOAPMessage createAttachmentPart

List of usage examples for javax.xml.soap SOAPMessage createAttachmentPart

Introduction

In this page you can find the example usage for javax.xml.soap SOAPMessage createAttachmentPart.

Prototype

public AttachmentPart createAttachmentPart(DataHandler dataHandler) 

Source Link

Document

Creates an AttachmentPart object and populates it using the given DataHandler object.

Usage

From source file:org.cerberus.service.soap.impl.SoapService.java

@Override
public void addAttachmentPart(SOAPMessage input, String path) throws CerberusException {
    URL url;/*from  w w w . jav  a2 s.  c om*/
    try {
        url = new URL(path);
        DataHandler handler = new DataHandler(url);
        //TODO: verify if this code is necessary
        /*String str = "";
         StringBuilder sb = new StringBuilder();
         BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
         while (null != (str = br.readLine())) {
         sb.append(str);
         }*/
        AttachmentPart attachPart = input.createAttachmentPart(handler);
        input.addAttachmentPart(attachPart);
    } catch (MalformedURLException ex) {
        throw new CerberusException(new MessageGeneral(MessageGeneralEnum.SOAPLIB_MALFORMED_URL));
    } catch (IOException ex) {
        throw new CerberusException(new MessageGeneral(MessageGeneralEnum.SOAPLIB_MALFORMED_URL));
    }

}