CXF REST File Upload

CXF REST File Upload explains step by step details of Implementing a REST service for uploading attachment using Apache CXF, Spring and Eclipse

JAX-RS is Java API for RESTful Webservices which is very rely upon Representational State Transfer model, you can view JAX-RS specification 

JAX-RS uses annotations for simplifying the development efforts.

Below you can see an example of How to upload an attachment using CXF JAX-RS(REST based) file upload


If you want to upload using SOAP MTOM, You can follow CXF File Upload With SOAP MTOM

Required Libraries

You need to download

  1. JDK 7
  2. Eclipse 4.2
  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. httpasyncclient-4.0-beta3.jar
  4. httpclient-4.2.1.jar
  5. httpcore-4.2.2.jar
  6. httpcore-nio-4.2.2.jar
  7. neethi-3.0.2.jar
  8. spring-aop-3.0.7.RELEASE.jar
  9. spring-asm-3.0.7.RELEASE.jar
  10. spring-beans-3.0.7.RELEASE.jar
  11. spring-context-3.0.7.RELEASE.jar
  12. spring-core-3.0.7.RELEASE.jar
  13. spring-expression-3.0.7.RELEASE.jar
  14. spring-web-3.0.7.RELEASE.jar
  15. wsdl4j-1.6.2.jar
  16. jaxb-api-2.2.6.jar
  17. jaxb-impl-2.2.6.jar
  19. xmlschema-core-2.0.3.jar
  20. jettison-1.3.3.jar (JSON library)

CXF REST File Upload

I am creating a simple restful service project that used to upload Multipart (MediaType.MULTIPART_FORM_DATA) attachment

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

Create CXF Project CXF REST File Upload

1 2 3 Next

1 Responses to "CXF REST File Upload"
  1. Ramon 2016-10-11 14:33:08.0

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