You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Unnam, Kishore (NSN - IN/Bangalore)" <ki...@nsn.com> on 2014/09/02 16:14:18 UTC

attachment is lost .

HI All,

I am facing a  strange problem ,  sample code is given below for the illustration of the issue.
I am attaching some text as attachment in the flow and trying to read the same ,  doesn't work.


---------Code sample -------

String xml = "<test></test>";
InputStream is = new ByteArrayInputStream(xml.getBytes());
ByteArrayDataSource byteArrayDS = new ByteArrayDataSource(is, "text/xml");
DataHandler fbAttachment = new DataHandler(byteArrayDS,"text/xml");
exchange.getMessage("in").addAttachment("testAttachment", fbAttachment);


InputStream inStream = exchange.getMessage("in").getAttachment("testAttachment").getInputStream();
byte[] byteArray= IOUtils.toByteArray(inStream);
LOG.info("Sending test attachment : "+ new String(byteArray));


----------------------------------


Environment details :
Java version                 :           java-1.7.0-openjdk-1.7.0.65.x86_64/
Servicemix Version   :          3.4.0



Any help is appreciated.

Regards,
Kishore.