Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.Attachments


        newMC.setDoingMTOM(ori.isDoingMTOM());
        newMC.setDoingSwA(ori.isDoingSwA());

        // if the original request carries any attachments, copy them to the clone
        // as well, except for the soap part if any
        Attachments attachments = ori.getAttachmentMap();
        if (attachments != null && attachments.getAllContentIDs().length > 0) {
            String[] cIDs = attachments.getAllContentIDs();
            String soapPart = attachments.getSOAPPartContentID();
            for (String cID : cIDs) {
                if (!cID.equals(soapPart)) {
                    newMC.addAttachment(cID, attachments.getDataHandler(cID));
                }
            }
        }

        Iterator itr = ori.getPropertyNames();
View Full Code Here


        newMC.setDoingMTOM(ori.isDoingMTOM());
        newMC.setDoingSwA(ori.isDoingSwA());

        // if the original request carries any attachments, copy them to the clone
        // as well, except for the soap part if any
        Attachments attachments = ori.getAttachmentMap();
        if (attachments != null && attachments.getAllContentIDs().length > 0) {
            String[] cIDs = attachments.getAllContentIDs();
            String soapPart = attachments.getSOAPPartContentID();
            for (String cID : cIDs) {
                if (!cID.equals(soapPart)) {
                    newMC.addAttachment(cID, attachments.getDataHandler(cID));
                }
            }
        }

        Iterator itr = ori.getPropertyNames();
View Full Code Here

        super.setUp();
    }

    private Attachments createAttachmentsForTestMTOMMessage() throws Exception {
        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE_2.getName());
        return new Attachments(inStream, TestConstants.MTOM_MESSAGE_2.getContentType());
    }
View Full Code Here

     * OMText nodes.
     * 
     * @throws Exception
     */
    public void testDeferredLoadingOfAttachments() throws Exception {
        Attachments attachments = createAttachmentsForTestMTOMMessage();
        SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments);
        OMDocument doc = builder.getDocument();
        // Find all the binary nodes
        List/*<OMText>*/ binaryNodes = new ArrayList();
        for (Iterator it = doc.getDescendants(false); it.hasNext(); ) {
            OMNode node = (OMNode)it.next();
            if (node instanceof OMText) {
                OMText text = (OMText)node;
                if (text.isBinary()) {
                    binaryNodes.add(text);
                }
            }
        }
        assertFalse(binaryNodes.isEmpty());
        // At this moment only the SOAP part should have been loaded
        assertEquals(1, attachments.getContentIDList().size());
        for (Iterator it = binaryNodes.iterator(); it.hasNext(); ) {
            // Request the DataHandler and do something with it to make sure
            // the part is loaded
            ((DataHandler)((OMText)it.next()).getDataHandler()).getInputStream().close();
        }
        assertEquals(binaryNodes.size() + 1, attachments.getContentIDList().size());
    }
View Full Code Here

        byte[] bytes3 = xmlPlusMime3.getBytes();
        byte[] full = append(bytes1, bytes2);
        full = append(full, bytes3);
       
        InputStream inStream = new BufferedInputStream(new ByteArrayInputStream(full));
        Attachments attachments = new Attachments(inStream, contentTypeString);
        SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments);
        OMElement root = builder.getDocumentElement();
        root.build();
    }
View Full Code Here

   
    public void test() throws Exception {
        Attachments[] attachments = new Attachments[2];
        XMLStreamReader[] soapPartReader = new XMLStreamReader[2];
        for (int i=0; i<2; i++) {
            attachments[i] = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE.getName()),
                    TestConstants.MTOM_MESSAGE.getContentType());
            soapPartReader[i] = StAXUtils.createXMLStreamReader(attachments[i].getRootPartInputStream());
        }
        XMLStreamReader actual = new XOPEncodingStreamReader(new XOPDecodingStreamReader(soapPartReader[1], new OMAttachmentAccessorMimePartProvider(attachments[1])), contentIDGenerator, OptimizationPolicy.DEFAULT);
        new XMLStreamReaderComparator(soapPartReader[0], actual).compare();
View Full Code Here

import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
import org.apache.axiom.util.base64.Base64Utils;

public class XOPDecodingStreamReaderTest extends AbstractTestCase {
    private XMLStreamReader getXOPDecodingStreamReader() throws Exception {
        Attachments attachments = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE.getName()),
                TestConstants.MTOM_MESSAGE.getContentType());
        return new XOPDecodingStreamReader(
                StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream()),
                new OMAttachmentAccessorMimePartProvider(attachments));
    }
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        orgEnvelope.serialize(out, format);
        assertFalse(element.isExpanded());
       
        // Parse the serialized message
        Attachments att = new Attachments(new ByteArrayInputStream(out.toByteArray()), format.getContentType());
        assertEquals(2, att.getAllContentIDs().length);
        SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(att).getSOAPEnvelope();
        OMElement contentElement = envelope.getBody().getFirstElement().getFirstChildWithName(
                new QName("http://ws.apache.org/axiom/test/jaxb", "content"));
        OMText content = (OMText)contentElement.getFirstOMChild();
        assertTrue(content.isBinary());
View Full Code Here

    public AxiomSoapMessage(SOAPFactory soapFactory, boolean payloadCaching, boolean langAttributeOnSoap11FaultString) {
        SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
        axiomFactory = soapFactory;
      axiomMessage = axiomFactory.createSOAPMessage();
      axiomMessage.setSOAPEnvelope(soapEnvelope);
        attachments = new Attachments();
        this.payloadCaching = payloadCaching;
        this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
        soapAction = EMPTY_SOAP_ACTION;
    }
View Full Code Here

     */
    public AxiomSoapMessage(SOAPMessage soapMessage,
                            String soapAction,
                            boolean payloadCaching,
                            boolean langAttributeOnSoap11FaultString) {
        this(soapMessage, new Attachments(), soapAction, payloadCaching, langAttributeOnSoap11FaultString);
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.Attachments

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.