Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Developing web services, Part 3: File uploading web service built with Apache CFX

Kuntal Ganguly (kuntalganguly86@gmail.com), Jr. Developer, Protech Infosystems Pvt. Ltd
Kuntal Ganguly
Currently associated as a Junior Developer at Protech Infosystems Pvt. Ltd, Kolkata. Kuntal has expertise in using a wide range of open source and commercial tools (WAS CE, Eclipse, Mule ESB, EZlegacy , Active MQ , Birt , and DB2 express C) and technologies(GWT and Android).
Partha Goswami (partha.ext@gmail.com), Jr. Developer, Protech Infosystems Pvt. Ltd
Partha Goswami
Currently associated as a Junior Developer at Protech Infosystems Pvt. Ltd, Kolkata. Has expertise in using a wide range of open source and commercial tools (WASCE, Eclipse, Mule ESB, EZlegacy , Active MQ , Birt , and DB2 express C) and technologies(GWT and RSS).

Summary:  This tutorial demonstrates how to develop a CXF web service which can upload a submitted file from the user and store it in a specific directory. The example is built with widely used Eclipse IDE.

View more content in this series

Date:  17 Jun 2011
Level:  Intermediate

Activity:  43051 views
Comments:  

Before you start

Binary data with SOAP messages is send in Base64 format because SAOP messages are based on plain text, so when binary data is converted into Base64 than its size is increased. And, in case of large attachment this kills the application and brings down the server with memory problems. MTOM (SOAP Message Transmission Optimization Mechanism) which encodes binary data in base64Binary and sends the data as binary attachment rather than keeping it with actual SOAP message MTOM provides an elegant mechanism to transfer binary data such as PDF, Doc, images, and other document types. MTOM uses XML-binary Optimized Packaging (XOP) packages for transmitting binary data. CXF provides support of MTOM with XOP implementation.

This tutorial, the last of a three-part series, explains how to develop a File uploading web service using Apache CXF.

About this series

This tutorial series teaches the basic concepts of web services using different SOAP engines like Apache AXIS2, Apache CXF and JAX-WS. This tutorial series also provides a solution for sending large attachment with SOAP messages by using MTOM (SOAP Message Transmission Optimization Mechanism) which encodes binary data in base64Binary and sends the data as binary attachment rather than keeping it with actual SOAP message. This series also shows that by simply making method calls using the SAAJ API, you can read and write SOAP-based XML messages, and you can optionally send and receive such messages over the Internet.

Part 1 starts simply, explaining the basic concepts behind web services and showing you how to develop web service with Axis2 using Different Approach (Code First and Contract First).

Part 2 starts simply by developing a Hello User web Service with JAX-WS and then takes things a step further by showing an example of File Download web service(where client can download file from web service and store in its location)using MTOM with JAX-WS. It also shows how to invoke web service from SAAJ Client.

Part 3 simply shows how to develop a File uploading web service(where client can Upload file/attachment to Web service) using Apache CXF supports for MTOM with XOP implementation.


About this tutorial

This tutorial demonstrates how to develop web service that can upload a file from client machine to the server. The client application submits a file location and invokes the web service which receives the file byte by byte and stores in a fixed specified location.


Objectives

In this tutorial, you will learn how to:

  • Build a web service using CXF and deploy it in the tomcat server.
  • Learn how to send large binary attachments using the MTOM standard.

Prerequisites

This tutorial assumes familiarity with some basic concepts of the Eclipse IDE, including views, editors, panels, and so on, along with basic programming concept in Java™ and web services. For an introduction to Eclipse, Java and Web Services, view the Resources.


Software required

  • CXF-bin
  • Tomcat
  • Eclipse(optional)

1 of 7 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and web services
ArticleID=680526
TutorialTitle=Developing web services, Part 3: File uploading web service built with Apache CFX
publish-date=06172011
author1-email=kuntalganguly86@gmail.com
author1-email-cc=
author2-email=partha.ext@gmail.com
author2-email-cc=