LibraryToggle FramesPrintFeedback

In XML Schema elements are defined using element elements. element elements has one required attribute. The name specifies the name of the element as it appears in an XML document.

In addition to the name attribute element elements have the optional attributes listed in Table 10.1.


Example 10.1 shows a simple element definition.


An element can also define its own type using an in-line type definition. In-line types are specified using either a complexType element or a simpleType element. Once you specify whether the type of data is complex or simple, you can define any type of data needed using the tools available for each type of data.

Example 10.2 shows an element definition with an in-line type definition.


By default, globally defined elements are mapped to JAXBElement<T> objects where the template class is determined by the value of the element element's type attribute. For primitive types, the template class is derived using the wrapper class mapping described in Wrapper classes. For complex types, the Java class generated to support the complex type is used as the template class.

To support the mapping and to relieve the developer of unnecessary worry about an element's QName, an object factory method is generated for each globally defined element, as shown in Example 10.3.


For example, the element defined in Example 10.1 results in the object factory method shown in Example 10.4.


Example 10.5 shows an example of using a globally scoped element in Java.


If a globally scoped element is used to define a message part, the generated Java parameter is not an instance of JAXBElement<T>. Instead it is mapped to a regular Java type or class.

Given the WSDL fragment shown in Example 10.6, the resulting method has a parameter of type String.


Example 10.7 shows the generated method signature for the sayHi operation.


Comments powered by Disqus
loading table of contents...