Java Reference
In-Depth Information
Optimizing Transmission of Binary Content on the
Server
Problem
You have a web service that must send and receive binary data, such as an image or a PDF,
and you want to optimize performance.
Solution
Use the javax.xml.ws.soap.MTOM annotation on your web service endpoint implementation.
Discussion
When you define a web service that includes operations for sending and receiving binary data,
the encoding to xs:base64Binary can get very verbose, as all binary content must be en-
coded and set with the message as text. A character encoding of base64Binary will increase
the size of the message by 1.33 times the original size when UTF-8 is used. It's necessary to
compress this content, much as you might use HTTP compression in a web server. Luckily,
it's very easy to do.
By default, JAX-WS disables MTOM-encoding. To enable it on your web service, just use the
MTOM annotation:
@WebService
@MTOM
public class MyService { ... }
MTOM is intended to replace MIME attachments (Microsoft's DIME attachments are all but
obsolete) as a method for binary optimization, relying on XOP (XML Binary Optimized Pack-
aging). Though the optimized form compacts the character sequence of the binary content in
the message, the content can still be reconstructed at the receiver.
NOTE
Visit http://www.w3.org/TR/soap12-mtom/ to read the MTOM specification.
MTOM is widely supported, portable, and interoperable. In addition to Glassfish and WebLo-
gic10gR3, MTOM is implemented in Axis 2. You can read about how to use MTOM in Axis
2 at http://ws.apache.org/axis2/1_0/mtom-guide.html .
Search WWH ::




Custom Search