Using a javax.activation.DataHandler for a SOAP attachment improves performance.
JAX-RPC specifies:
A mapping of certain MIME types to Java types.
Any MIME type is mappable to a javax.activation.DataHandler .
As a result, send a SOAP attachment as a .gif or XML file to an RPC style web service by utilizing the Java type mappings. When passing in any of the mandated Java type mappings which are appropriate for the attachment's MIME type as an argument for the web service, the JAX-RPC runtime handles these as SOAP attachments. For example, to send out an image or a gif attachment, use java.awt.Image, or create a DataHandler wrapper over your image. The advantages of using the wrapper are:
Reduced coding: You can reuse generic attachment code to handle the attachments because the DataHandler determines the content type of the contained data automatically. This feature is especially useful when using a document style service. Since the content is known at runtime, there is no need to make calls to attachment.setContent (stringContent, "image/gif"), for example.
Improved Performance: Informal tests have shown that using DataHandler wrappers doubles throughput for image or GIF MIME types, and multiplies throughput by approximately 1.5 for text and XML or java.awt.Image for image/* types.