Example of JAXB Annotations Specifying Default Serialization of Fields and Properties XmlAccessorType Annotation

5-10 Getting Started With JAX-WS Web Services for Oracle WebLogic Server The default mapping of Java objects to XML Schema for the supported built-in and user-defined types are listed in the following sections: ■ Section 5.3.1.2, Java-to-XML Mapping for Built-In Data Types ■ Section 5.3.2.2, Supported Java User-Defined Data Types

5.4.1 Example of JAXB Annotations

The following provides an example of the JAXB annotations. XmlRootElementname = ComplexService, namespace =http:examples.org XmlAccessorTypeXmlAccessType.FIELD XmlTypename = basicStruct, propOrder = { intValue, stringArray, stringValue public class BasicStruct { protected int intValue; XmlElementnillable = true protected ListString stringArray; protected String stringValue; public int getIntValue { return intValue; } public void setIntValueint value { this.intValue = value; } public ListString getStringArray { if stringArray == null { stringArray = new ArrayListString; } return this.stringArray; } public String getStringValue { return stringValue; Table 5–5 JAXB Mapping Annotations Annotation Description XmlAccessorType Specifies whether fields or properties are mapped by default. See Section 5.4.2, Specifying Default Serialization of Fields and Properties XmlAccessorType Annotation. XmlElement Maps a property contained in a class to a local element in the XML Schema complex type to which the containing class is mapped. See Section 5.4.3, Mapping Properties to Local Elements XmlElement. XMLMimeType Associates the MIME type that controls the XML representation of the property with a textual representation, such as imagejpeg. See Section 5.4.4, Specifying the MIME Type XmlMimeType Annotation. XmlRootElement Maps a top-level class to a global element in the XML Schema that is used by the WSDL of the Web service. See Section 5.4.5, Mapping a Top-level Class to a Global Element XmlRootElement. XmlSeeAlso Binds other classes when binding the current class. See Section 5.4.6, Binding a Set of Classes XmlSeeAlso. XmlType Maps a class or enum type to an XML Schema type.See Section 5.4.7, Mapping a Value Class to a Schema Type XmlType. Using JAXB Data Binding 5-11 } public void setStringValueString value { this.stringValue = value; } }

5.4.2 Specifying Default Serialization of Fields and Properties XmlAccessorType Annotation

The XmlAccessorType annotation specifies whether fields or properties are mapped by default. The annotation can be specified for the following Java program elements: ■ Package ■ Top-level class The XmlAccessorType can be specified with the XmlType see Section 5.4.7, Mapping a Value Class to a Schema Type XmlType and XmlRootElement see Section 5.4.5, Mapping a Top-level Class to a Global Element XmlRootElement annotations. The following table lists the optional element that can be passed to the XmlAccessorType annotation. For more information, see the javax.xml.bind.annotation.XmlAccessorType Javadoc at http:download.oracle.comjavaee5apijavaxxmlbindannotatio nXmlAccessorType.html . An example is provided in Section 5.4.1, Example of JAXB Annotations.

5.4.3 Mapping Properties to Local Elements XmlElement