1a) Modifying your schema for MTOM - 7.3

Talend ESB Service Developer Guide

Version
7.3
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend ESB
Talend Runtime
Content
Design and Development
Installation and Upgrade
Last publication date
2023-04-17

Lets say we have a Picture schema type like this:

<schema targetNamespace="http://pictures.com"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <element name="Picture">
      <complexType>
         <sequence>
            <element name="Title" type="xsd:string"/>
            <element name="ImageData" type="xsd:base64Binary"/>
         </sequence>
      </complexType>
   </element>
</schema>

In this case the ImageData element is something we would like to have transferred as an attachment. To do this we just need to add an xmime:expectedContentTypes annotation:

<schema targetNamespace="http://pictures.com" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
   <element name="Picture">
      <complexType>
         <sequence>
            <element name="Title" type="xsd:string"/>
            <element name="ImageData" type="xsd:base64Binary"
               xmime:expectedContentTypes="application/octet-stream"/>
         </sequence>
      </complexType>
   </element>
</schema>

This tells JAXB (which WSDL2Java uses to generate POJOs for your service) that this field could be of any content type. Instead of creating a byte[] array for the base64Binary element, it will create a DataHandler instead which can be used to stream the data.