MTOM service - Technotes


Getting started
Locating source code
Reviewing coding notes


Getting started

This Sample illustrates the use of SOAP Message Transmission Optimization Mechanism (MTOM) to transmit binary files using a JAX-WS Web service. 

The MTOM service Sample implements a Web service that returns the binary content of a file to the client. The Sample includes a servlet client, org.apache.axis2.jaxws.sample.servlet.SampleServlet, and a MTOM service thin client application, org.apache.axis2.jaxws.sample.mtom.SampleMTOMTests. The service client servlet and the thin client application use common code to work with the service using dispatch and proxy-based clients in the SampleMTOMTests.java source file.

Locating source code

The Java code for the annotated MTOM service Sample client servlet and the thin client application is located in the profile_root/samples/src/JaxWSServicesSamples/SampleMTOMClient/src directory.

The Java code for the MTOM service application is located in the profile_root/samples/src/JaxWSServicesSamples/SampleMTOMService/src directory.

On z/OS operating systems: The source code tree for these JAX-WS Samples is not provided on the z/OS operating system because the Sample applications are not built on the z/OS operating system.

Reviewing coding notes

The MTOM service Sample was generated using the Rational Application Developer tool from two Web Services Description Language (WSDL) files that define the services. One of the service endpoints that is provided uses SOAP 1.1, and the other uses SOAP 1.2. The server automatically identifies incoming MTOM optimized messages based on the content-type and deserializes the messages accordingly. Therefore, there is no explicit code in the MTOM service Sample to handle MTOM in the services.

On the client side, however, MTOM must be enabled before the service transaction. Within the MTOM service thin client application, org.apache.axis2.jaxws.sample.mtom.SampleMTOMTests.java, in both the testMtomWithDispatch and testMtomWithProxy methods, there is an invocation of the setMTOMEnabled method on the binding. After this method is invoked, outgoing messages are serialized and sent as MTOM optimized messages. If the setMTOMEnabled method is not set the binding, then all the binary data in binary content nodes is serialized as Base64 encoded strings.

The client servlet, org.apache.axis2.jaxws.sample.servlet.SampleServlet.java, has no service-specific code and calls the methods provided in the file, SampleMTOMTests.java.

The client provided in this Sample invokes the MTOM service using both the dispatch and the proxy programming models. The client demonstrates how to access the both the dispatch and proxy methods.

For more information about enabling MTOM for JAX-WS Web services, see the WebSphere Application Server Information Center Library.