CXF File Upload With SOAP MTOM

CXF File Upload With SOAP MTOM shows Implementing a SOAP service for uploading/sending large attachment using MTOM (SOAP Message Transmission Optimization Mechanism)

MTOM is used for encoding binary data in base64Binary and send as binary attachement than keeping it with actual SOAP message. MTOM is approved by WC3 and is a standard. MTOM very useful for transfering binary data such as MS documents, PDF, images etc. MTOM uses XML-binary Optimized Packaging (XOP) packages for transmitting binary data

MTOM is used for sending large attachments using WSDL based services (SOAP).

You can go through following tutorial, in order to use MTOM inside CXF

Required Libraries

You need to download

  1. JDK 6
  2. Eclipse 3.7
  3. CXF-2.7.3
  4. Tomcat 7

Following jar must be in ClassPath

  1. commons-logging-1.1.1.jar
  2. cxf-2.7.3.jar
  3. geronimo-javamail_1.4_spec-1.7.1.jar
  4. httpasyncclient-4.0-beta3.jar
  5. httpclient-4.2.1.jar
  6. httpcore-4.2.2.jar
  7. httpcore-nio-4.2.2.jar
  8. jaxb-api-2.2.6.jar
  9. jaxb-impl-2.2.6.jar
  10. neethi-3.0.2.jar
  11. spring-aop-3.0.7.RELEASE.jar
  12. spring-asm-3.0.7.RELEASE.jar
  13. spring-beans-3.0.7.RELEASE.jar
  14. spring-context-3.0.7.RELEASE.jar
  15. spring-core-3.0.7.RELEASE.jar
  16. spring-expression-3.0.7.RELEASE.jar
  17. spring-web-3.0.7.RELEASE.jar
  18. wsdl4j-1.6.2.jar
  19. xmlschema-core-2.0.3.jar

CXF MTOM File Upload Example

I am creating a simple web service project used for uploading different file formats using CXF MTOM implementation.

The service is using simple POJO (Plain Old Java Object) bean.

Firstly create a Dynamic Web Project (File->New->Dynamic Web Project) named "CXFUpload" according to following screenshot

Create CXF MTOM Project CXF File Upload With SOAP MTOM

Create a FileUploader Object

This is a pojo class used to mapping the binary data, that we are going to upload

package com.student;

import javax.activation.DataHandler;

public class FileUploader {
private String Name;
private String FileType;
private DataHandler Dfile;

public String getName() {
return this.Name;

public void setName(String Name) {
this.Name = Name;

public DataHandler getDfile() {
return this.Dfile;

public void setDfile(DataHandler Dfile) {
this.Dfile = Dfile;

public String getFileType() {
return FileType;

public void setFileType(String FileType) {
this.FileType = FileType;

1 2 3 Next

4 Responses to "CXF File Upload With SOAP MTOM"
  1. skanda 2013-04-18 08:37:17.0
  1. skanda 2013-04-19 08:37:17.0
  1. Bob Rivers 2013-04-20 08:37:17.0
  1. FerminLucky 2013-04-21 08:37:17.0

Your email address will not be published. Required fields are marked *