Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:
repository/samples/directory that includes all Integration profile samples is changed to
repository/samples/resources/directory that includes all artifacts related to the Integration profile samples is changed to
This sample demonstrates how you can use content optimization mechanisms such as Message Transmission Optimization Mechanism (MTOM) and SOAP with Attachments ( SwA) with the ESB.
By default ESB serializes binary data as Base64 encoded strings and sends them in the SOAP payload. MTOM and SwA define mechanisms over which files with binary content can be transmitted over SOAP web services.
For a list of prerequisites, see Prerequisites to Start the ESB Samples.
Building the sample
The XML configuration for this sample is as follows:
This configuration file
synapse_sample_51.xml is available in the
<property name="enableMTOM" value="true" scope="axis2"/>
When this is enabled, all outgoing messages will be serialized and sent as MTOM optimized MIME messages.You can override this configuration per service in the
<property name="enableSwA" value="true" scope="axis2"/>
When this is enabled, incoming SwA messages are automatically identified by axis2.
The above properties can also be defined in
To build the sample
Start the ESB with the sample 51 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.
The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."
Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Deploy the back-end service
MTOMSwASampleService. For instructions on deploying sample back-end services, see Deploying sample back-end services.
Executing the sample
The sample client used here is the Optimize Client. For further details on this sample client, see Optimize Client.
To execute the sample client
Run the following command from the
<ESB_HOME>/samples/axis2Clientdirectory, specifying MTOM optimization.
Next, run the following command from the
<ESB_HOME>/samples/axis2Clientdirector, specifying SwA optimization.
Analyzing the output
The configuration sets a local message context property, and forwards the message to
During response processing, by checking the local message property, the ESB can identify the past information about the current message context, and can use this knowledge to transform the response back to the client in the same format as the original request.
When the client executes successfully, it will upload a file containing the ASF logo and will receive its response back again and save it into a temporary file.
When you analyze the log once the client is run specifying MTOM optimization, you will see an output as follows:
If you use TCPMon and send the message through it, you will see that the requests and responses sent are MTOM optimized or sent as http attachments as follows:
When you analyze the log once the client is run specifying SwA optimization, you will see an output as follows:
If you use TCPMon and send the message through it, you will see that the requests and responses sent are SwA optimized or sent as http attachments as follows: