title: How return MTOM in Spring BOOT WS
body: <p>I have a problem with my Spring Boot Soap Server, im using Spring WS, i have to return my files in attachments,  i return a Datahandler to the listtype created by Jaxb, but i see in the response in soap ui, attachments 0, and return me the files in base64.
  I dont know how to do this.
  Can you help me.
  Thanks so much.</p>
  
  <p>My Configuration Bean is:</p>
  
  <pre><code>@Bean
      public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
          MessageDispatcherServlet servlet = new MessageDispatcherServlet();
          servlet.setApplicationContext(applicationContext);
          servlet.setTransformWsdlLocations(true);
          return new ServletRegistrationBean(servlet, "/ws/services/*");
      }
  
      @Bean(name = "students")
      public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
          DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
          wsdl11Definition.setPortTypeName("StudentPort");
          wsdl11Definition.setLocationUri("/ws/services/test");
          wsdl11Definition.setTargetNamespace("http://www.example.org/demo/");
          wsdl11Definition.setSchema(countriesSchema);
          Properties props = new Properties();
          props.put("getDemo", "http://www.example.org/demo/getDemoRequest");
          wsdl11Definition.setSoapActions(props);
  
          return wsdl11Definition;
      }
  
      @Bean
      public XsdSchema countriesSchema() {
          return new SimpleXsdSchema(new ClassPathResource("/it/xsd/demo.xsd"));
      }
  </code></pre>
  
  <p>My endpoint have only these annotations:</p>
  
  <pre><code>@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getDemoRequest")
      @ResponsePayload
  </code></pre>
  
  <p>In my demo.xsd, i setted the fileType in </p>
  
  <pre><code>&lt;element name="fileType" type="base64Binary" maxOccurs="unbounded" xmime:expectedContentTypes="application/octet-stream"&gt;
  </code></pre>
  
  <p>I havent xml configuration for now, i would like dont use any xml if it is not necessary in perfect style of Spring Boot.</p>
  
  <p>Thanks so much.</p>
  
  <p><strong>UP</strong>:
  My code to try enable MTOM.</p>
  
  <pre><code>  import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.oxm.jaxb.Jaxb2Marshaller;
      import org.springframework.ws.config.annotation.WsConfigurerAdapter;
      import org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor;
      import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver;
  
      import java.util.List;
  
      @Configuration
  public class MTOMEnable extends WsConfigurerAdapter {
      @Override
      public void addArgumentResolvers(List&lt;MethodArgumentResolver&gt; argumentResolvers) {
          argumentResolvers.add(methodProcessor());
      }
  
      @Bean
      public Jaxb2Marshaller marshaller() {
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
          marshaller.setClassesToBeBound(GetStudentsResponse.class);
          marshaller.setMtomEnabled(true);
          return marshaller;
      }
  
      @Bean
      public MarshallingPayloadMethodProcessor methodProcessor() {
          return new MarshallingPayloadMethodProcessor(marshaller());
      }
  }
  </code></pre>
  
  <p><strong>POM</strong></p>
  
  <pre><code>&lt;dependencies&gt;
          &lt;!-- SOAP DEPENDENCIES--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-rt&lt;/artifactId&gt;
              &lt;version&gt;2.3.2&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-ri&lt;/artifactId&gt;
              &lt;version&gt;2.3.2&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.org.apache.xml.internal&lt;/groupId&gt;
              &lt;artifactId&gt;resolver&lt;/artifactId&gt;
              &lt;version&gt;20050927&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web-services&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
              &lt;version&gt;2.2.2.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;wsdl4j&lt;/groupId&gt;
              &lt;artifactId&gt;wsdl4j&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
              &lt;version&gt;3.9&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-codec&lt;/groupId&gt;
              &lt;artifactId&gt;commons-codec&lt;/artifactId&gt;
              &lt;version&gt;1.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!--&lt;dependency&gt;
              &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
              &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
              &lt;version&gt;6.2.0.jre8&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sourceforge.jtds&lt;/groupId&gt;
              &lt;artifactId&gt;jtds&lt;/artifactId&gt;
              &lt;version&gt;1.3.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.4.0-b180830.0359&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/javax.activation/activation --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.activation&lt;/groupId&gt;
              &lt;artifactId&gt;activation&lt;/artifactId&gt;
              &lt;version&gt;1.1.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jaxb&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-runtime&lt;/artifactId&gt;
              &lt;version&gt;2.4.0-b180830.0438&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
              &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt; &lt;!-- makesure you put a correct version here --&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>