32.4. Lists
Overview
primeList, using a list type is shown in Example 32.7, “List Type Example”.
Example 32.7. List Type Example
<primeList>1 3 5 7 9 11 13<\primeList>
List<T> objects. The only variation to this pattern is when a message part is mapped directly to an instance of an XML Schema list type.
Defining list types in XML Schema
simpleType element. The most common syntax used to define a list type is shown in Example 32.8, “Syntax for XML Schema List Types”.
Example 32.8. Syntax for XML Schema List Types
<simpleType name="listType">
<list itemType="atomicType">
<facet value="value" />
<facet value="value" />
...
</list>
</simpleType>Table 32.3. List Type Facets
| Facet | Effect |
|---|---|
length | Defines the number of elements in an instance of the list type. |
minLength | Defines the minimum number of elements allowed in an instance of the list type. |
maxLength | Defines the maximum number of elements allowed in an instance of the list type. |
enumeration | Defines the allowable values for elements in an instance of the list type. |
pattern | Defines the lexical form of the elements in an instance of the list type. Patterns are defined using regular expressions. |
simpleList element shown in Example 32.7, “List Type Example”, is shown in Example 32.9, “Definition of a List Type”.
Example 32.9. Definition of a List Type
<simpleType name="primeListType"> <list itemType="int"/> </simpleType> <element name="primeList" type="primeListType"/>
Example 32.10. Alternate Syntax for List Types
<simpleType name="listType">
<list>
<simpleType>
<restriction base="atomicType">
<facet value="value"/>
<facet value="value"/>
...
</restriction>
</simpleType>
</list>
</simpleType>Mapping list type elements to Java
List<T> object. The template class used by the List<T> is the wrapper class mapped from the list's base type. For example, the list type defined in Example 32.9, “Definition of a List Type” is mapped to a List<Integer>.
Mapping list type parameters to Java
List<T> object. The base type of the array is the wrapper class of the list type's base class.
Example 32.11. WSDL with a List Type Message Part
<definitions ...>
...
<types ...>
<schema ... >
<simpleType name="primeListType">
<list itemType="int"/>
</simpleType>
<element name="primeList" type="primeListType"/>
</schemas>
</types>
<message name="numRequest">
<part name="inputData" element="xsd1:primeList" />
</message>
<message name="numResponse">;
<part name="outputData" type="xsd:int">
...
<portType name="numberService">
<operation name="primeProcessor">
<input name="numRequest" message="tns:numRequest" />
<output name="numResponse" message="tns:numResponse" />
</operation>
...
</portType>
...
</definitions>Example 32.12. Java Method with a List Type Parameter
public interface NumberService {
@XmlList
@WebResult(name = "outputData", targetNamespace = "", partName = "outputData")
@WebMethod
public int primeProcessor(
@WebParam(partName = "inputData", name = "primeList", targetNamespace = "...")
java.lang.Integer[] inputData
);
}
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.