Java Reference
In-Depth Information
Enabling Binary Optimization on the Client
Problem
Your client must send binary data to a SOAP-based web service, and you want to optimize it
for performance.
Solution
Encode your binary data as xs:base64Binary content. Then enable MTOM on the client side
by passing javax.xml.ws.MTOMFeature to the proxy constructor.
MTOM stands for Message Transmission Optimization Mechanism. It is a specification cre-
ated by the W3C to support the selective encoding of portions of a message. The XML infoset
is still available within the SOAP message, so it is not obfuscated by this process.
NOTE
JAX-WS-compliant vendors are required to support MTOM, so this code is portable.
So how do you set it up? If you review the WebServiceClient classes generated by JAX-WS,
you will notice that each includes two get<X>Port methods: one that takes no arguments,
and another that takes a variable length argument of WebServiceFeature objects. The catalog
WebServiceClient as generated by JAX-WS during wsimport is shown in Example 6-18 .
Example6-18.Generated web service client
@WebEndpoint(name = "CatalogPort")
public Catalog getCatalogPort() {
return super.getPort(new QName("http://ns.soacookbook.com",
"CatalogPort"), Catalog.class);
}
@WebEndpoint(name = "CatalogPort")
public Catalog getCatalogPort(WebServiceFeature... features) {
return super.getPort(new QName("http://ns.soacookbook.com",
"CatalogPort"), Catalog.class, features);
}
A WebServiceFeature is a standard manner of enabling and disabling support for a variety
of useful mechanisms at runtime. Some features come built in with JAX-WS, and vendors can
provide additional features. You can also write your own.
Search WWH ::




Custom Search