What's the difference between MTOM and the attachment features provided by SAAJ?
Asked Answered
V

1

18

SAAJ: SOAP with Attachments API for Java

MTOM: SOAP Message Transmission Optimization Mechanism

My simple understanding: they deal with SOAP attachments, with MTOM being the more optimized version of SAAJ. Is this correct?

Are they simply 2 different ways of doing the same thing? Or am I trying to compare apples and oranges here?

Can I use SAAJ and MTOM together?

Vardhamana answered 18/3, 2013 at 15:31 Comment(0)
A
37

It is a little bit more complicated. SAAJ is an old Java API for used to manipulate SOAP envelopes, so sending binary attachments can be done in a sane way (that is not as a BASE64 encoded string in message body). SAAJ is a sort of low level interface, you need to construct SOAP envelope "by hand" in your code and add attachments to it.

If you don't need to work with legacy code and you want to work directly with SOAP envelopes, then look on JAX-WS Dispatcher and Provider interfaces.

MTOM is a another beast. It is not a full web service API - it is specialized way of sending attachments. It can be used by any "true" web service API like JAX-WS or SAAJ (if you manage to force SAAJ to work that way).

MTOM is (almost) always used with XOP, a more efficient way to send binary data, as compared to BASE64 (which has large overhead). Attachment is sent separately as MIME attachment and the MIME type is handled properly (that used to be an issue for Java-Microsoft technologies interactions).

Nowdays forget about SAAJ, use JAX-WS + MTOM support which is provided by most JAX-WS implementations.

Aviva answered 18/3, 2013 at 22:50 Comment(1)
This explains a lot. is "that used to be an issue for Java-Microsoft technologies interactions)." about XOP or about not using XOP? Or about not using MTOM?Alcantar

© 2022 - 2024 — McMap. All rights reserved.