JSR 222 (JAXB) annotations

In this section, we will be looking at some of the useful annotations introduced in the JSR 222 (JAXB) specification. JAXB is a specification which defines how JavaBeans can be data bound to XML. We will be looking into the following annotations:

  • javax.xml.bind.annotation.XmlRootElement
  • javax.xml.bind.annotation.XmlAccessorType
  • javax.xml.bind.annotation.XmlElement

javax.xml.bind.annotation.XmlRootElement

This annotation is used for mapping a top-level class to a global element in the WSDL's XML schema. This annotation is defined as follows:

@Retention(RUNTIME)
@Target({TYPE})
public @interface XmlRootElement {
String namespace() default "##default";
String name() default "##default";
}

This annotation contains two properties— ...

Get Apache Axis2 Web Services Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.