MTOM is a way to handle large amounts of binary data in your services. Unlike attachments, the XML infoset stays the same. MTOM just "optimizes" any base64Binary data you have in your messages. When MTOM is turned on, this base64 data gets sent as a binary attachment saving time and space.
Turning on MTOM is easy. You can do it via the API:
Or via services.xml:
You also need to set the mtom-enabled property on your client:
MTOM and the Aegis Binding
The Aegis (aka POJO) binding has support for optimization of the following classes:
- DataSource
- DataHandler
- byte[]
You could also write your own by extending the AbstractXOPType.
MTOM and JAXB 2.0
Any base64Binary type in a schema is a candidate for optimization with JAXB. You can also specify the expected mime content type:
JAXB is then smart enough to use an Image instead of a byte array.
Cleaning up attachments (IMPORTANT!)
In XFire 1.2.3+
In XFire 1.2.3 we automatically delete attachments for you. If you wish to not have the attachment deleted, and the attachment was saved to disk, you'll want to do something like this:
In XFire 1.2.2 and before
After you're done with your attachment, you'll probably want to delete it if it was saved to disk. The default threshold for saving an attachment to disk is about 100K. You only need to do this if it is a DataHandler or DataSource.
Configuring attachments
There are two parameters you can tweak to configure how attachments work:
#. The attachment directory
#. The size threshold for creating a File for the attachment
These can be set on both the service and the client:
