Package javax.xml.soap

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


    }

    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

    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

            if ( soapMessage.countAttachments() > )
            {
                Iterator attachmentIter = soapMessage.getAttachments();
                for (; attachmentIter.hasNext();)
                {
                    AttachmentPart attachment = (AttachmentPart) attachmentIter.next();
                    DataHandler dataHandler = attachment.getDataHandler();
                    String contentId = attachment.getContentId();
                    normalizedMessage.addAttachment( contentId, dataHandler);
                }
            }
        }
    }
View Full Code Here

        // if there are unrefferenced attachments, add that to response
        if (!unaccessedAttachments.isEmpty()) {
            Collection attachments = unaccessedAttachments.values();
            Iterator attachementsIterator = attachments.iterator();
            while (attachementsIterator.hasNext()) {
                AttachmentPart attachment = (AttachmentPart)attachementsIterator.next();
                response.addAttachmentPart(attachment);
            }
        }

        return response;
View Full Code Here

                    // check whether the omtext refers to an attachment

                    final OMText omText = (OMText)omChildNode;
                    if (omText.isOptimized()) { // is this an attachment?
                        final DataHandler datahandler = (DataHandler)omText.getDataHandler();
                        AttachmentPart attachment = saajSOAPMsg.createAttachmentPart(datahandler);
                        final String id = IDGenerator.generateID();
                        attachment.setContentId(id);
                        attachment.setContentType(datahandler.getContentType());
                        saajSOAPMsg.addAttachmentPart(attachment);

                        saajEle.addAttribute(
                                saajSOAPMsg.getSOAPPart().getEnvelope().createName("href"),
                                "cid:" + id);
View Full Code Here


        Map attachmentMap = new HashMap();
        final Iterator attachments = saajSOAPMsg.getAttachments();
        while (attachments.hasNext()) {
            final AttachmentPart attachment = (AttachmentPart)attachments.next();
            if (attachment.getContentId() == null ||
                    attachment.getContentId().trim().length() == 0) {
                attachment.setContentId(IDGenerator.generateID());
            }
            if (attachment.getDataHandler() == null) {
                throw new SOAPException("Attachment with NULL DataHandler");
            }
            attachmentMap.put(attachment.getContentId(), attachment);
        }

        //Get keys of attachments to a hashmap
        //This hashmap will be updated when attachment is accessed atleast once.
        //Doing this here instead of inside insertAttachmentNodes()is much simpler
View Full Code Here

            final OMAttribute hrefAttr = child.getAttribute(new QName("href"));
            String contentID = getContentID(hrefAttr);

            if (contentID != null) {//This is an omEnvelope referencing an attachment
                child.build();
                AttachmentPart ap = ((AttachmentPart)attachments.get(contentID.trim()));
                //update the key status as accessed
                keyAccessStatus.put(contentID.trim(), "accessed");
                OMText text = new OMTextImpl(ap.getDataHandler(), true,
                                             omEnvelope.getOMFactory());
                child.removeAttribute(hrefAttr);
                child.addChild(text);
            } else {
                //possibly there can be references in the children of this omEnvelope
View Full Code Here

            String keyStatus = (String)keyAccessStatus.get(key);
            if ("not-accessed".equals(keyStatus)) {
                //The value for this key has not been accessed in the
                //referencing attachment scenario.Hence it must be an
                //unreferenced one.
                AttachmentPart ap = ((AttachmentPart)attachments.get(key));
                unaccessedAttachments.put(key, ap);
                keyAccessStatus.put(key, "accessed");
            }
        }
        return unaccessedAttachments;
View Full Code Here

            MessageFactory factory = MessageFactory.newInstance();
            SOAPMessage request = factory.createMessage(null,
                    new ByteArrayInputStream(msg.getBytes()));
           
            // Add the Attachment
            AttachmentPart ap = request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
            ap.setContentId(SoapMessageProvider.ID);
            request.addAttachmentPart(ap);

            TestLogger.logger.debug("Request Message:");
            request.writeTo(System.out);
           
            // Dispatch
            TestLogger.logger.debug(">> Invoking SourceMessageProviderDispatch");
            SOAPMessage response = dispatch.invoke(request);

            // Check assertions and get the data element
            SOAPElement dataElement = assertResponseXML(response, SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
            assertTrue(countAttachments(response) == 1);
           
            // Get the Attachment
            AttachmentPart attachmentPart = (AttachmentPart) response.getAttachments().next();
           
            // Check the attachment
            StreamSource contentSS = (StreamSource) attachmentPart.getContent();
            String content = SoapMessageProvider.getAsString(contentSS);
            assertTrue(content != null);
            assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
           
            // Print out the response
View Full Code Here

TOP

Related Classes of javax.xml.soap.AttachmentPart

Copyright © 2018 www.massapicom. 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.