Use MTOM on only certain fields, other fields inline - CXF SOAP

747 views Asked by At

I have a CXF based web service that is using MTOM. It's using MTOM perfectly fine, however there are some byte[] fields that I always want to be inline in the SOAP XML. I do NOT want them to be sent as mime attachments.

Even if I do not use the @XmlMimeType attribute on the byte array responses always use MTOM on the byte fields. Is it possible to have some byte arrays place the payload inline and others use MTOM?

The only way I have seen this possible is based on size by using the threshold, but this is not what I want.

Example:

public class Content {

     //I want this field inline
     private byte[] contentNONMTOM;


     //I want this field to be attached/MTOM
     @XmlMimeType("application/octet-stream")
     private byte[] contentMTOM
     ....
1

There are 1 answers

0
bdoughan On BEST ANSWER

The @XmlInlineBinaryData annotation is used to force JAXB to inline the data in the XML:

@XmlInlineBinaryData
private byte[] contentNONMTOM;

For More Information

I have written more about this use case on my blog: