Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class AddAttachmentMessageProcessor implements MessageProcessor
{
@Override
public MuleEvent process(MuleEvent event) throws MuleException
{
Collection<Attachment> attachments = new ArrayList<Attachment>();
AttachmentImpl attachment = new AttachmentImpl("1");
String attachmentXML = "";
try
{
attachmentXML = IOUtils.getResourceAsString("attachment.xml", this.getClass());
}
catch (IOException e)
{
e.printStackTrace();
}
DataSource source = new ByteArrayDataSource(attachmentXML.getBytes(), "text/xml");
attachment.setDataHandler(new ConfigurableDataHandler(source));
attachments.add(attachment);
event.getMessage().setInvocationProperty(CxfConstants.ATTACHMENTS, attachments);
return event;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment