JAX is a common term used for JAX-B and JAX-WS technologies which are basic building blocks of WebService. WebService is a distributed web application which uses open XML-based standards and transport protocols to exchange data between remote devices. Starting from Java6 the said WebService fundamental classes are bundled within JDK itself. The main intention is to help WebService development instead of using an application container like Tomcat / WebSphere. JDK also bundles a light weight WebService container to host the WebService testing.
1) What is JAXB?
JAXB is also known as Java API for XML binding. JAXB technology make easier to transform and access data from XML within Java and also to create an XML from the representing Java objects. For JAXB, JDK provides API's (javax.xml.bind), compiler tools (xjc & schemagen) and a framework with implementation that automates mapping between
a) In memory Java Objects to XML
b) XML to in memory Java Object.
a) is commonly called as JAXB marshal while b) is commonly called as JAXB un-marshal. JAXB Marshalling provides a client application the ability to convert a JAXB-derived Java object tree back into XML data form. JAXB Marshalling process can be compared to Object serialization where java object is converted into network friendly way. JAXB Unmarshalling provides a client application the ability to convert XML data into JAXB-derived Java objects. JAXB UnMarshalling process can be compared to Object de-serialization, where network transmitted Object bytes are converted back to Java Objects.
JAXB provides an efficient and standard way of mapping between XML and Java Object. Comparing to XML parsing using DOM / SAX, JAXB uses lesser memory footprint. JAXB create objects based on demand and thus uses memory efficiently.
2) What are all JAXB Compilers tools?
JAXB compilers are used to generated JAXB artifact which are essential during JAXB runtime, for Marshalling and Un-Marshalling.
i) xjc : generate fully annotated Java classes from a XML schema file.
usage : xjc [-options ...] <schema file>
ii) schemagen : can generate a schema file from JAXB annotated Java classes
usage: schemagen [-options ...] [java source files]
3) What is JAX-WS technology?
JAX-WS means Java API for XML Web Services and it the technology helps to build client server Web Services. JAX-WS implementation under the hood utilizes JAXB for XML to Java and Java to XML conversion for WebService communication. Old implementations of WebServices were based on Remote procedure Call (RPC) which uses RMI underneath. JAX-WS hides all SOAP operation form a WebService developer and he is not supposed to know in depth about SOAP unless if some problem rises for debugging.
With JAX-WS, WebService, it is supported through open standards a JAX-WS client (java client) can access any other compatible service provided (either it can Java service, or can be a .Net service). This is feasible because JAX-WS uses technologies defined by the World Wide Web Consortium (W3C): HTTP, SOAP, and the Web Service Description Language (WSDL). WSDL specifies an XML format for describing a service as a set of endpoints operating on messages.
4) What are all JAX-WS tooling supported by JDK?
Like the JAX-RPC tooling, the JAX-WS tooling provides tools to help with bottoms-up (wsgen) and top-down (wsimport) development approaches.
i) wsgen (with JAX RPC this was called java2wsdl)
wsgen tool help to generate WebService artifacts from an annotated Java class. The tool produces Java classes from the annotated class, required to build the WSDL.
Usage : wsgen [–options] [Java service class (SEI)]
ii) wsimport (with JAX RPC this was called wsdl2java)
wsimport tool helps to write a Java Web Service client using artifact generated by wsgen.
Usage: wsimport [-options] [WSDL file]