Skip to content

Instantly share code, notes, and snippets.

@thiamteck
Last active December 24, 2015 17:39
Show Gist options
  • Save thiamteck/6837132 to your computer and use it in GitHub Desktop.
Save thiamteck/6837132 to your computer and use it in GitHub Desktop.
Set content type, encoding of attachment when using Axis2 to send SOAP request
//
// import these:
//
// import org.apache.axiom.attachments.Attachments;
// import org.apache.axiom.attachments.ConfigurableDataHandler;
// import javax.activation.FileDataSource
Attachments attachments = new Attachments();
ConfigurableDataHandler dh = new ConfigurableDataHandler(new FileDataSource("testing.gif")); // file path
dh.setContentType("image/gif");
dh.setTransferEncoding("base64");
attachments.addDataHandler("testing.gif", dh); // just file name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment