Web / Apache Axiom Interview questions
What is the difference between OMText for plain text and OMText for binary/MTOM data?
Both are instances of the same OMText interface, but they carry fundamentally different payloads and behave differently on serialization.
| Plain OMText | Binary/MTOM OMText |
| Backed by a String, from CHARACTERS events | Backed by a DataHandler wrapping raw bytes |
| getText() returns the character data directly | getDataHandler() returns the attachment |
| Always serialized inline as text content | Serialized as an xop:Include reference when optimized |
| No isBinary flag set | isBinary() returns true |
On the wire, a plain OMText node's content simply appears as character data between tags, exactly as you'd expect. A binary OMText, when the serialization's OMOutputFormat has MTOM optimization enabled, instead gets replaced at that position with an <xop:Include href="cid:..."/> element, with the actual bytes shipped as a separate MIME part rather than inline.
If optimization is not enabled for a given serialization, a binary OMText typically falls back to being base64-encoded inline instead - so the same node can produce different wire formats depending purely on the output format configuration used at serialization time, not on anything intrinsic to the node itself.
More Related questions...