Examples of AttachmentPart


Examples of javax.xml.soap.AttachmentPart

                cachedSoapEnvelope = cachedSoapPart.getEnvelope();
            }
            if (sm.countAttachments() > 0) {
                Iterator it = sm.getAttachments();
                while (it != null && it.hasNext()) {
                    AttachmentPart ap = (AttachmentPart) it.next();
                    cachedAttachmentParts.add(ap);
                }
            }
        } catch (Throwable t) {
            if (log.isDebugEnabled()) {
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

                    log.debug("checkSOAPMessageInfo detected " + currentNumAttachmentParts + "AttachmentParts");
                }
                Iterator cachedIT = cachedAttachmentParts.iterator();
                Iterator currentIT = sm.getAttachments();
                while (currentIT.hasNext() && cachedIT.hasNext()) {
                    AttachmentPart currentAP = (AttachmentPart) currentIT.next();
                    AttachmentPart cachedAP  = (AttachmentPart) cachedIT.next();
                    if (currentAP != cachedAP) {
                        if (log.isDebugEnabled()) {
                            log.debug("checkSOAPMessageInfo returns false due to: " +
                                    "current AttachmentParts is " + JavaUtils.getObjectIdentity(currentAP) +
                                    " and cached is " + JavaUtils.getObjectIdentity(cachedAP));
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

        el2.addTextNode("bodyvalue3a");
        el2 = el.addChildElement("bodyfield3b", NS_PREFIX);
        el2.addTextNode("bodyvalue3b");
        el2 = el.addChildElement("datefield", NS_PREFIX);

        AttachmentPart ap = msg.createAttachmentPart();
        ap.setContent("some attachment text...", "text/plain");
        msg.addAttachmentPart(ap);

        String jpgfilename = "docs/axis.jpg";
        File myfile = new File(jpgfilename);
        FileDataSource fds = new FileDataSource(myfile);
        DataHandler dh = new DataHandler(fds);
        AttachmentPart ap2 = msg.createAttachmentPart(dh);
        ap2.setContentType("image/jpg");
        msg.addAttachmentPart(ap2);

        FileOutputStream fout = new FileOutputStream(filename);
        msg.writeTo(fout);
        fout.close();
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

           
            // TODO: setup mime headers
            Collection<Attachment> atts = message.getAttachments();
            if (atts != null) {
                for (Attachment a : atts) {
                    AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
                   
                    soapMessage.addAttachmentPart(ap);
                }
            }
           
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

            Iterator iterator = soapMessage.getAttachments();
            while ( iterator.hasNext() ) {
                /**
                 * Get next attachment.
                 */
                AttachmentPart ap = (AttachmentPart) iterator.next();
                /**
                 * Get content type.
                 */
                String contentType = ap.getContentType();
                System.out.println("content type: " + contentType);
                /**
                 * Get content Id.
                 */
                String contentId = ap.getContentId();
                System.out.println("content Id: " + contentId);

                /**
                 * Check if this is a Text attachment.
                 */
                if ( contentType.indexOf("text") >=0 ) {
                    /**
                     * Get and print the content if it is a text
                     * attachment.
                     */
                   
                    Object content =  ap.getContent();
                   
                    /**
                     * content could be returned as an Input Stream.
                     */
                    if ( content instanceof InputStream ) {
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

        /**
         * Create an atachment with activation API.
         */
        URL url = new URL ("http://java.sun.com/webservices/");
        DataHandler dh = new DataHandler (url);
        AttachmentPart ap = soapMessage.createAttachmentPart(dh);
        /**
         * set content type/ID.
         */
        ap.setContentType("text/html");
        ap.setContentId("cid-001");

        /**
         *  add the attachment to the SOAP message.
         */
        soapMessage.addAttachmentPart(ap);
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

        if (attachmentHandler.hasAttachments()) {
            // add attachments to message
            for (String id : attachmentHandler.getAttachments().keySet()) {
                DataHandler attachment = attachmentHandler.getAttachments().get(id);
                AttachmentPart part = message.createAttachmentPart(attachment);
                part.setContentType(attachment.getContentType());
                String contentId = "<" + id.substring(4) + ">";
                part.setContentId(contentId);
                part.setMimeHeader("Content-Transfer-Encoding", "binary");
                message.addAttachmentPart(part);
            }
        }

        return message;
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

                            ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache();
                        } catch (IOException e) {
                            throw new Fault(e);
                        }
                    }
                    AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
                    ap.setContentId(a.getId());
                    Iterator<String> i = a.getHeaderNames();
                    while (i != null && i.hasNext()) {
                        String h = i.next();
                        String val = a.getHeader(h);
                        ap.addMimeHeader(h, val);
                    }
                    soapMessage.addAttachmentPart(ap);
                }
            }
           
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

    }

    protected void addNmsAttachments(NormalizedMessage normalizedMessage, SOAPMessage soapMessage) throws MessagingException, SOAPException {
        Iterator iter = soapMessage.getAttachments();
        while (iter.hasNext()) {
            AttachmentPart attachment = (AttachmentPart) iter.next();
            normalizedMessage.addAttachment(attachment.getContentId(), asDataHandler(attachment));
        }
    }
View Full Code Here

Examples of javax.xml.soap.AttachmentPart

    protected void addSoapAttachments(SOAPMessage soapMessage, NormalizedMessage normalizedMessage) throws IOException {
        Iterator iterator = normalizedMessage.getAttachmentNames().iterator();
        while (iterator.hasNext()) {
            String name = (String) iterator.next();
            DataHandler attachment = normalizedMessage.getAttachment(name);
            AttachmentPart attachmentPart = soapMessage.createAttachmentPart(attachment.getContent(), attachment.getContentType());
            attachmentPart.setContentId(name);
            soapMessage.addAttachmentPart(attachmentPart);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.