
Learn how to use MTOM by building a simple prototype
With web services-based SOA now being deployed across Global 2000 enterprises, transmitting attachments such as MRI Scans, X-Rays, Design Documents and Business Contracts using SOAP messages has become a common practice. SOAP Message Transmission Optimization Mechanism (MTOM), is a W3C Recommendation designed for optimizing the electronic transmission of attachments. Through electronic transmission of documents, corporations can realize significant cost savings and better service levels by eliminating the use of postal mail. Paper-based manual tasks can be replaced with simple and efficient electronic processes where binary data can be transmitted between organizations through standards such as MTOM.
MTOM provides an elegant mechanism of efficiently transmitting binary data, such as images, PDF files, MS Word documents, between systems. The Figure below shows the steps involved in transmitting data between a Consumer and Producer using MTOM.
The Consumer application begins by sending a SOAP Message that contains complex data in Base64Binary encoded format. Base64Binary data type represents arbitrary data (e.g., Images, PDF files, Word Docs) in 65 textual characters that can be displayed as part of a SOAP Message element. For the Send SOAP Message Step 1 in the Figure above, a sample SOAP Body with Base64Binary encoded element <tns:data> is as follows:
<soap:Body>
<tns:ByteEcho>
<tns:data>JVBERi0xLjYNJeLjz9MNCjE+DQpzdGFyNCjEx0YNCg==</tns:data>
</tns:ByteEcho>
</soap:Body>
An MTOM-aware web services engine detects the presence of Base64Binary encoded data types, <tns:data> in our example, and makes a decision – typically based on data size – to convert the Base64Binary data to MIME data with an XML-binary Optimization Package (xop) content type. The data conversion, shown in Step 2 of the Figure above, results in replacing the Base64Binary data with an <xop:Include> element that references the original raw bytes of the document being transmitted. The raw bytes are appended to the SOAP Message and are separated by a MIME boundary as shown below:
<soap:Envelope>
<soap:Body>
<tns:ByteEcho>
<tns:data><xop:Include href="cid:1.633335845875937500@example.org"/></tns:data>
</tns:ByteEcho>
</soap:Body>
</soap:Envelope>
--MIMEBoundary000000
content-id: <1.633335845875937500@example.org>
content-type: application/octet-stream
content-transfer-encoding: binary
The raw binary data along with the SOAP Message and the MIME Boundary is transmitted over the wire to the Producer. The Producer then changes the raw binary data back to Base64Binary encoding for further processing. With this conversion between Base64Binary and raw binary MIME types, MTOM provides two significant advantages:
In this paper, we will deploy a web service for processing binary data ByteEcho(byte[] data) and examine using this service without MTOM and with MTOM enabled.
For a hands-on understanding of MTOM, we will build web services with simple operation that will echo a byte stream. In this section, we will focus on setting up the SOA Testing framework for MTOM by installing the following components. Install the three products below in the listed sequence:
All three components can be installed on a Windows 2000/XP/2003/Vista machine with moderate resources. The web services Producer is the .NET WebMatrix server that supplies a web service with the ByteEcho(byte[] data) operation that applications can invoke, over HTTP. In addition, it produces the WSDL file that defines the web service interface. This file provides all the necessary information for the consumer, SOAPSonar, to send SOAP requests to the target web service. SOAPSonar consumes and interprets the WSDL-based API published by the producer and invokes the web service.
To build a simple web service that illustrates handling binary data, follow these steps:
Note: The OK button will be grayed until all the information on this panel is filled out.
[WebMethod]
public byte [] ByteEcho(byte[] data) {
return data;
}
to commit changes and
to execute the test. You will see the SOAP response in the Response Panel.
on in the Request Panel to review the Header information for
the request. Select the (Sent Request) Tab as show in the Figure below.
The SOAP request and the Header information are also shown below. Make
a note of the following information:So far, you have successfully loaded a WSDL into the test client, SOAPSonar and setup a simple consumer (SOAPSonar) to producer (webMatrix) Framework to send base64Encoded bytes to the webMatrix server that reflects the bytes to SOAPSonar in the SOAP Response. Next, we will enable MTOM and review its impact on the SOAP Request and Response.
In the section, we will enable MTOM for WebMatrix and the SOAPSonar test client. To enable MTOM for webMatrix as follows:
<messaging>
<mtom clientMode="Off" serverMode="always"/>
</messaging>
to execute the test.
Review the request sent to the server by clicking on the (Send Request)
Tab in the Request Panel. The SOAP request and the Header information
are also shown below. Make a note of the following information:
Note: The Header Content Length for the Message Request with MTOM turned-on is 244K compared to 325K with the Message Request without MTOM. This corresponds to a ~25% reduction in message size even for a moderately sized message.
You should be now be comfortable with sending base64Binary encoded and MTOM encoded messages to a test server and viewing the responses in wire format and base64Binary encoded formats.
MTOM provides an efficient mechanism for transmitting binary data. MTOM’s approach of reducing the number of standards required for transmission while reducing the data bloat caused by Base64Binary encoding the entire attachment makes it an ideal standard for transmission of large binary content. Obviously, nothing comes for free. The gain in network transmission efficiency by reducing “wire footprint” is at the expense of CPU resources. The client has to expend processing resources to convert Base64Binary encoded type to MIME type before transmitting it over the wire. The receiver then performs another data type transformation from MIME to Base64Binary data. MTOM is ideal for use cases where a large number of external organizations want to transmit sizeable documents to an enterprise over the internet with low bandwidth availability.
Website: www.crosschecknet.com
Email: support@crosschecknet.com
US Phone: 1-888-CROSSCK (276-7725)
International Phone: 1-617-938-3956
<Crosscheck your Web Services/>?
| Contact | About | News | Privacy | Terms of Use | © 2004-2007 Crosscheck Networks, Inc. All Rights Reserved. |