Using metadata to map XML to a Java type
Mapping XML to a Java type requires creating a collection of descriptors in the class to associate each Java attribute with its corresponding XML element. This mapping system manages any naming differences between the Java and XML pairs to support the serialization and deserialization of the data.
The WSDL2Java tool generates a static type descriptor for each Java and XML pair. The following code maps the qualified names of the Java attribute and XML element for User in the Login class:
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(Login.class, true);
 
static {
typeDesc.setXmlType(new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11", "Login"));
org.apache.axis.description.ElementDesc elemField =
new org.apache.axis.description.ElementDesc( );
elemField.setFieldName("user");
elemField.setXmlName(new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11", "User"));
elemField.setXmlType(new javax.xml.namespace.QName(
"http://www.w3.org/2001/XMLSchema", "string"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
A class generated from a WSDL type is typically a JavaBean. The JavaBean uses classes from the org.apache.axis.encoding.ser package to encode and decode SOAP messages. In the following code example, getSerializer( ) instantiates and returns a reference to a BeanSerializer object using the Java and XML type descriptors:
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}