2.3 Other Java-XML Technologies
Up to now, we have discussed the Web service-specific technologies that are a mandatory part of the J2EE platform. As such, these technologies must be present in any J2EE implementation from any vendor. Apart from these, there are other Java-XML technologies that, while not a mandatory requirement of the J2EE platform, still prove very useful for implementing Web services. While there are a number of such technologies, we discuss here only those referenced throughout this book. One such non-mandatory but useful Java-XML technology is the Java Architecture for XML Binding (JAXB), which standardizes the representation of an XML document as an in-memory object.
As we have already seen, when two parties communicate by passing XML documents between them, the XML documents should follow some structure so that the communicating parties can understand the contents of the documents. XML document structure is defined using the standard schema facility for XML documents. Of course, while developers can use a DOM or SAX parser to parse such documents, it is much easier if the various parts of the XML documents are mapped or bound to in-memory objects that truly represent the document's intended meaning, as per the schema definition. In addition to using these objects, developers have access to the schema definitions as part of their logic. Such a facility is commonly called an XML data-binding facility. JAXB provides a good quality XML data-binding facility for the J2EE platform. Figure 2.8 shows the overall architecture of the JAXB data-binding facility.
Figure 2.8 JAXB Architecture19862 Figure caption Figure 2.6 JAXB Architecture
JAXB consists of three main components:
A binding compiler that creates Java classes (also called content classes) from a given schema. Complex type definitions within the schema are mapped to separate content classes, while simple types (such as attribute/element declarations) are mapped to fields within a content class. Developers use get and set methods (similar to JavaBeans get and set methods) to access and modify the object contents.
A binding framework that provides runtime servicessuch as marshalling, unmarshalling, and validationthat can be performed on the contents classes.
A binding language that describes binding of the schema to Java classes. This language enables a developer to override the default binding rules, thereby helping the developer to customize the content classes that are created by the binding compiler.
For more details on JAXB, refer to the JAXB specification available through the link provided in the next section.
Apart from JAXB, there are other emerging Java technologies that support Web service standards in terms of long-lived transactions, business process workflow, and so forth. At the time of this writing, they have not been finalized and hence will be dealt with in a future version of this book.