Package org.apache.servicemix.jbi.util

Examples of org.apache.servicemix.jbi.util.ByteArrayDataSource


        InOut me = d.createInOutExchange();
        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FileUtil.copyInputStream(new FileInputStream(f), baos);
        DataSource ds = new ByteArrayDataSource(baos.toByteArray(), "image/jpeg");
        DataHandler dh = new DataHandler(ds);
        me.getInMessage().addAttachment("image", dh);
        client.sendSync(me);
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        assertEquals(1, me.getOutMessage().getAttachmentNames().size());
View Full Code Here


                if (ds instanceof ByteArrayDataSource) {
                    newAttachments.put(name, ds);
                } else {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    FileUtil.copyInputStream(ds.getInputStream(), baos);
                    ByteArrayDataSource bads = new ByteArrayDataSource(baos.toByteArray(), ds.getContentType());
                    bads.setName(ds.getName());
                    newAttachments.put(name, bads);
                }
            }
            attachments = newAttachments;
        }
View Full Code Here

        InOnly exchange = client.createInOnlyExchange(resolver);

        Source source = getSourceFromClassPath("request.xml");
        exchange.getInMessage().setContent(source);
        ByteArrayDataSource ds = new ByteArrayDataSource("hello".getBytes(), "text/plain");
        ds.setName("id");
        exchange.getInMessage().addAttachment("id", new DataHandler(ds));

        client.send(exchange);
        // END SNIPPET: xpath
View Full Code Here

        // Add soap part
        MimeBodyPart soapPart = new MimeBodyPart();
        soapPart.setContentID("<" + SOAP_PART_ID + ">");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        writeSimpleMessage(baos);
        soapPart.setDataHandler(new DataHandler(new ByteArrayDataSource(baos.toByteArray(), "text/xml")));
        soapPart.addHeader("Content-Transfer-Encoding", "8bit");
        parts.addBodyPart(soapPart);
        // Add attachments
        for (Iterator itr = message.getAttachments().entrySet().iterator(); itr.hasNext();) {
            Map.Entry entry = (Map.Entry) itr.next();
View Full Code Here

        return r;
    }
   
    @WebMethod
    public DataSource mtom(int id) {
        return new ByteArrayDataSource("<xsl:stylesheet />".getBytes(), "text/xml");
    }
View Full Code Here

        InOnly exchange = client.createInOnlyExchange(resolver);

        Source source = getSourceFromClassPath("request.xml");
        exchange.getInMessage().setContent(source);
        ByteArrayDataSource ds = new ByteArrayDataSource("hello".getBytes(), "text/plain");
        ds.setName("id");
        exchange.getInMessage().addAttachment("id", new DataHandler(ds));

        client.send(exchange);
        // END SNIPPET: xpath
View Full Code Here

                if (ds instanceof ByteArrayDataSource) {
                    newAttachments.put(name, ds);
                } else {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    FileUtil.copyInputStream(ds.getInputStream(), baos);
                    ByteArrayDataSource bads = new ByteArrayDataSource(baos.toByteArray(), ds.getContentType());
                    bads.setName(ds.getName());
                    newAttachments.put(name, bads);
                }
            }
            attachments = newAttachments;
        }
View Full Code Here

        InOnly exchange = client.createInOnlyExchange(resolver);

        Source source = getSourceFromClassPath("request.xml");
        exchange.getInMessage().setContent(source);
        ByteArrayDataSource ds = new ByteArrayDataSource("hello".getBytes(), "text/plain");
        ds.setName("id");
        exchange.getInMessage().addAttachment("id", new DataHandler(ds));

        client.send(exchange);
        // END SNIPPET: xpath
View Full Code Here

     *
     * @throws Exception
     */
    public void testGetAttachment() throws Exception {
        // testcase for SM-1186
        DataHandler dh = new DataHandler(new ByteArrayDataSource("test".getBytes(), "test"));

        // first test with existing attachments
        MessageExchangeImpl inOnly = new InOnlyImpl("inonly");
        NormalizedMessage msg = inOnly.createMessage();
        msg.addAttachment("att_1", dh);
View Full Code Here

                if (ds instanceof ByteArrayDataSource) {
                    newAttachments.put(name, ds);
                } else {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    FileUtil.copyInputStream(ds.getInputStream(), baos);
                    ByteArrayDataSource bads = new ByteArrayDataSource(baos.toByteArray(), ds.getContentType());
                    bads.setName(ds.getName());
                    newAttachments.put(name, bads);
                }
            }
            attachments = newAttachments;
        }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.util.ByteArrayDataSource

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.