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

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

    • Typed web service messages require requires binding of XML Schema types and the programming language types (e.g. java data types).

    • The types section of a WSDL holds, points to, or imports an XSD. 

      • Although the WSDL 2.0 specification allows for alternatives to XML schema, XML schema is the default and the dominant type system used in WSDL.

      • The types section is optional.

        • If the types section is empty, then the service uses only simple data types such as xsd:string and xsd:long.

  2. Under the hood, pacakges in JAX-WS uses JAXB for the bindings between XSD types and Java types.

    • JAXB stands for Java Architecture for XML Binding and provides a Java API that can map Java objects to XML content and XML content to Java objects. Read more @ http://javajee.com/introduction-to-jaxb-2.

    • JAXB is the most preferred way of binding in JAX-WS.

  3. 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.

  4. 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. 

  5. 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).

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) Arrays (1) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (55) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (9) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (7) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)