Social Groups

JAX-WS is mainly used for working with SOAP based web services and SOAP based web services are primarily based on XML: SOAP message (which is the format for message exchange in SOAP web services ) itself is XML and WSDL (which is the description of a SOAP web service) is also XML based. So we will discuss few important points about JAX-WS and XML.

It is always preferred to use JAXB and JAX-WS specific newer APIs than other technologies mentioned here, like JAXP, SAAJ, MTOM etc. if possible. Older technologies are given here as it may be required for exams such as Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam (IZ0-897).

Important points about JAX-WS and XML

To provide interoperability between web services written in different programming languages, web services uses XML Schema (XSD) which is a shared types system.

The SOAP with Attachments API for Java or SAAJ provides a standard way to send XML documents over the Internet from the Java platform.

SOAP mechanism for carrying large payloads and binary data as an attachment rather than inside the SOAP message envelope.

Developers can also use it to write SOAP messaging applications directly instead of using JAX-RPC or JAX-WS.

SAAJ 1.3 is the supported version for data binding with SOAP.

Older versions of JAX-WS (JAX-RPC) used JAXP API for processing XML

The Java API for XML Processing, or JAXP, is a Java XML Application programming interfaces (API) that provides the capability of validating and parsing XML documents.

JAXP provide developers with a vendor and parser-implementation independent API to process XML.

The three basic parsing interfaces for JAXP are:

The Document Object Model parsing interface or DOM interface

The Simple API for XML parsing interface or SAX interface

The Streaming API for XML or StAX interface (part of JDK 6; separate jar available for JDK 5)

You can still work with JAXP APIs with JAX-WS, but JAXB is the preferred way.

MTOM a method of efficiently sending binary data to and from Web services.

MTOM is the W3C Message Transmission Optimization Mechanism.

MTOM (Message Transmission and Optimization Mechanism) together with XOP (XML Binary Optimized Packaging) defines how an XML binary data such as xs:base64Binary or xs:hexBinary can be optimally transmitted over the wire.

MTOM is specialized way of sending attachments. It can be used by JAX-WS or even SAAJ APIs.

MTOM feature is disabled in JAX-WS by default.

It can be enabled on the client and server.

You can enable MTOM on a web service endpoint deployed in an EE container by specifying:

@MTOM annotation on the endpoint's class

<enable-mtom> in webservices.xml deployment descriptor

a wsoma:MTOM policy in WSDL

You can enable MTOM at client by calling setMTOMEnabled(true); on the SOAPBining object.

​An MTOM optimized infoset+attachment for a large binary data saves around 30% in size when compared to original infoset.

The HTTP content-type header when a message is optimized using MTOM will be multipart/related.

Important Note

It is always preferred to use JAXB and JAX-WS specific newer APIs than other technologies mentioned here, like JAXP, SAAJ, MTOM etc. if possible. Older technologies are given here as it may be required for exams such as Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam (IZ0-897).

You are here

This is a personal technical blog where we share our understanding on various concepts and is neither an official page or documentation for the products described here, nor the official views of the companies we work with.

Keywords used in this website are trademarks of their respective owners. This website is not affiliated with Oracle™ and/or any of the JEE frameworks like Spring™, Struts™, Hibernate™ and JSF™.

All contents and materials are provided freely without any warranty or liability and nothing within the site should be considered as professional advice. In any doubt, please ask, and we will try to help you based on our knowledge. Please let us know if you feel anything is not right here (including any copyright violation) and we will act upon it as fast as we can.