Java SOAP Message createAttachmentPart(String cid, DataHandler dh, SOAPMessage message)

Here you can find the source of createAttachmentPart(String cid, DataHandler dh, SOAPMessage message)

Description

Create an SAAJ AttachmentPart from a JAXWS Attachment

License

Apache License

Parameter

Parameter Description
cid String content id
dh DataHandler
message SOAPMessage

Return

AttachmentPart

Declaration

public static AttachmentPart createAttachmentPart(String cid, DataHandler dh, SOAPMessage message) 

Method Source Code


//package com.java2s;
/*/*w  w w .  j a va2  s  .  co  m*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import javax.activation.DataHandler;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPMessage;

public class Main {
    /**
     * Create an SAAJ AttachmentPart from a JAXWS Attachment
     * @param cid String content id
     * @param dh DataHandler
     * @param message SOAPMessage
     * @return AttachmentPart
     */
    public static AttachmentPart createAttachmentPart(String cid, DataHandler dh, SOAPMessage message) {
        // Create the Attachment Part
        AttachmentPart ap = message.createAttachmentPart(dh);

        // REVIEW
        // Do we need to copy the content type from the datahandler ?

        // Preserve the original content id
        ap.setContentId(cid);
        return ap;
    }
}

Related

  1. constructMessage(String mimeHdrsFile, String msgFile)
  2. convertSoapMessageToString(SOAPMessage message)
  3. copy(MimeHeaders headers)
  4. copyMimeHeaders(MimeHeaders headers)
  5. create()
  6. createDoc(SOAPMessage soapMsg)
  7. createException(String code, String message)
  8. createFault(String message)
  9. createSOAPFault(SOAPFault fault, Throwable cause)