Search in sources :

Example 11 with AttachmentPart

use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.

the class SAAJFactoryTest method addAttachmentPart.

private AttachmentPart addAttachmentPart(SOAPMessage msg, String value) {
    AttachmentPart att = msg.createAttachmentPart(value, "text/html");
    att.addMimeHeader(CUSTOM_MIME_HEADER_NAME, CUSTOM_MIME_HEADER_VALUE);
    att.addMimeHeader(CUSTOM_MIME_HEADER_NAME2, CUSTOM_MIME_HEADER_VALUE2);
    msg.addAttachmentPart(att);
    return att;
}
Also used : AttachmentPart(jakarta.xml.soap.AttachmentPart)

Example 12 with AttachmentPart

use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.

the class AttachmentHelper method getAttachment.

public AttachmentPart getAttachment(java.net.URI ref, Iterator iter) {
    if (iter == null || ref == null) {
        System.err.println("getAttachment: null Iterator for AttachmentPart");
        return null;
    }
    while (iter.hasNext()) {
        AttachmentPart tempAttachment = (AttachmentPart) iter.next();
        if (ref.isOpaque() && ref.getScheme().equals("cid")) {
            String refId = ref.getSchemeSpecificPart();
            String cId = tempAttachment.getContentId();
            if (cId.equals("<" + refId + ">") || cId.equals(refId)) {
                return tempAttachment;
            }
        }
    }
    return null;
}
Also used : AttachmentPart(jakarta.xml.soap.AttachmentPart)

Example 13 with AttachmentPart

use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.

the class JAXBAttachment method writeTo.

@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
    AttachmentPart part = saaj.createAttachmentPart();
    part.setDataHandler(asDataHandler());
    part.setContentId(contentId);
    saaj.addAttachmentPart(part);
}
Also used : AttachmentPart(jakarta.xml.soap.AttachmentPart)

Example 14 with AttachmentPart

use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.

the class HelloLiteralTest method getSOAPMessage.

private SOAPMessage getSOAPMessage() throws Exception {
    byte[] bytes = helloSM.getBytes();
    ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    message.getSOAPPart().setContent(new StreamSource(bis));
    AttachmentPart ap = message.createAttachmentPart(getImage("java.jpg"), "image/jpeg");
    message.addAttachmentPart(ap);
    message.saveChanges();
    return message;
}
Also used : MessageFactory(jakarta.xml.soap.MessageFactory) StreamSource(javax.xml.transform.stream.StreamSource) AttachmentPart(jakarta.xml.soap.AttachmentPart) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 15 with AttachmentPart

use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.

the class MyHandler method handleMessage.

public boolean handleMessage(SOAPMessageContext smc) {
    if (!(Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))
        return true;
    try {
        SOAPMessage msg = smc.getMessage();
        AttachmentPart part = msg.createAttachmentPart(getDataHandler());
        part.setContentId("SOAPTestHandler@example.jaxws.sun.com");
        msg.addAttachmentPart(part);
        msg.saveChanges();
        smc.setMessage(msg);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
    return true;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) AttachmentPart(jakarta.xml.soap.AttachmentPart) SOAPMessage(jakarta.xml.soap.SOAPMessage) WebServiceException(jakarta.xml.ws.WebServiceException)

Aggregations

AttachmentPart (jakarta.xml.soap.AttachmentPart)24 SOAPMessage (jakarta.xml.soap.SOAPMessage)16 MessageFactory (jakarta.xml.soap.MessageFactory)9 ByteArrayInputStream (java.io.ByteArrayInputStream)7 InputStream (java.io.InputStream)7 Message (com.sun.xml.ws.api.message.Message)5 Packet (com.sun.xml.ws.api.message.Packet)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 MessageContextFactory (com.oracle.webservices.api.message.MessageContextFactory)4 DataHandler (jakarta.activation.DataHandler)4 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)4 Test (org.junit.Test)4 MessageContext (com.oracle.webservices.api.message.MessageContext)3 MimeHeaders (jakarta.xml.soap.MimeHeaders)3 SOAPElement (jakarta.xml.soap.SOAPElement)3 SOAPPart (jakarta.xml.soap.SOAPPart)3 Iterator (java.util.Iterator)3 Attachment (com.sun.xml.ws.api.message.Attachment)2 JAXBException (jakarta.xml.bind.JAXBException)2 SOAPBody (jakarta.xml.soap.SOAPBody)2