Thanks Guillaume !
Can you explain more on how I can handle the "MIME attachments" ?
I can work on creating a patch as I have an urgent need for this.
I have already set the binary PDF file as an attachement in an InOut Message
:
//client is HTTPClient ,
client.executeMethod(method);
InputStream datainput = method.getResponseBodyAsStream();
byte[] responseBody = ByteUtils.toByteArray(datainput);
ByteArrayDataSource ds = new ByteArrayDataSource(responseBody,
"binary");
ds.setName("HTTPRESPONSE");
DataHandler handler = new DataHandler(ds);
out.addAttachment("HTTPRESPONSE", handler);
First , is this the correct way to do it or is there a better way to create
an Attachement ?
I then want to send this attachement to the Client that used the HTTPInvoker
component . I tried to change the HttpMarshaler class as follows :
( method :toResponse(InOut exchange, NormalizedMessage message,
HttpServletResponse response) )
DataHandler dh = message.getAttachment(oneAttachmentName);
DataSource ds = dh.getDataSource();
InputStream instream = ds.getInputStream();
SourceTransformer st = getTransformer();
st.toResult(new StreamSource(instream), new
StreamResult(response.getOutputStream()));
This did not work and I got an exception :
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in p
rolog.
at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.ja
va:469)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTransformer.java:92)
at
org.apache.servicemix.components.http.HttpMarshaler.toResponse(HttpMarshaler.java:142)
Apparently , its looking for some valid XML to parse and send to the client
and is not able to handle the binary data...
Can you suggest whats the problem above and how can I fix it ?
Also can you point me to some examples where MIME attachement is used to
send data ?
Thanks
Pat
--
View this message in context:
http://www.nabble.com/setContent%28%29-mandatory-for-HTTPComponent---t1828477.html#a5042244
Sent from the ServiceMix - User forum at Nabble.com.