Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estebanroblesluna/1075558 to your computer and use it in GitHub Desktop.
Save estebanroblesluna/1075558 to your computer and use it in GitHub Desktop.
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