code: public static void writeDataHandler(boolean mtom, SOAPMessage msg, Element el, DataHandler dh){
          LOG.debug("Writing DataHandler, mtom: "+mtom+", contentType: "+dh.getContentType());
          if(mtom){
              Element inc = el.getOwnerDocument().createElementNS("http://www.w3.org/2004/08/xop/include","Include");
              el.appendChild(inc);
              String id = UUID.randomUUID().toString()+"@s1-platform.org";
              AttachmentPart ap = msg.createAttachmentPart();
              ap.setDataHandler(dh);
              ap.setContentId("<"+id+">");
              msg.addAttachmentPart(ap);
              inc.setAttribute("href","cid:"+id);
              //LOG.debug("File contentId: "+id);
          }else{
              try {
                  el.setTextContent(Base64.encode(IOUtils.toBytes(dh.getInputStream())));
              } catch (IOException e) {
                  throw S1SystemError.wrap(e);
              }
          }
      }
docs: Write binary data to message as base64 or xop:Include depending on mtom parameter.
  
  @param mtom
  @param msg
  @param el
  @param dh