axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "R J Scheuerle Jr" <>
Subject Enumeration Support Is Ready
Date Wed, 31 Oct 2001 22:07:09 GMT
Heads up...

When I split the Emitter into separate classes (Emitter, TypeFactory, Type,
I added the groundwork for the support of JAX-RPC enumeration classes.

I have completed/tested the initial support of enumeration classes, and
Russell Butek will
integrate this code sometime over the next few days.

Here is a summary of the changes:
  1) Changed AddressBook sample.  The state field was changed from an
     "xsd:string" to a new enumeration type called "stateType".

  2) Changed Emitter.writeEnumType(...) method to generate the appropriate
     java class for an enumeration XML type.  (An accompanying Holder class
     automatically generated.)

  3) Added an org.apache.axis.encoding.EnumSerializer class to
     an enumeration type.  The class structure is similar to
BeanSerializer, DateSerializer, etc.

  4) Note that the * code and the deploy.xml file
contain logic to
     register a QName with a Bean Serializer/Deserializer.  It seems rather
useless to
     introduce a whole new architecture here for Enum Serialization. (We
would need <enumMapping>
     elements in the deploy.xml, plus additional code in the, etc.)
     Instead the Bean Serialization/Deserializer code is re-used for
     Enum Serialization/Deserialization.  A little extra code is added to
the BeanSerializer
     to determine if the java class is a true bean class or if it is an
enumeration-style class.
     If it is an enumeration-style class, the serialization/deserialization
is delegated to an
     EnumSerializer.  (In reality the BeanSerialization class should have
been named something
     like ClassSerialization, and ClassSerialization could then delegate to
     EnumSerialization, or whatever...)

Here are some more details...

The AddressBook.wsdl document now has a stateType enumeration:

   <!-- type defs -->
    <xsd:schema targetNamespace="urn:AddressFetcher2"

      <xsd:simpleType name="stateType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="TX"/>
            <xsd:enumeration value="IN"/>
            <xsd:enumeration value="OH"/>

      <xsd:complexType name="phone">
            <xsd:element name="areaCode" type="xsd:int"/>
            <xsd:element name="exchange" type="xsd:string"/>
            <xsd:element name="number" type="xsd:string"/>

      <xsd:complexType name="address">
            <xsd:element name="streetNum" type="xsd:int"/>
            <xsd:element name="streetName" type="xsd:string"/>
            <xsd:element name="city" type="xsd:string"/>
            <xsd:element name="state" type="typens:stateType"/>
            <xsd:element name="zip" type="xsd:int"/>
            <xsd:element name="phoneNumber" type="typens:phone"/>
The Wsdl2java emitter generates the following class.  The
mapping for this class matches the mapping specified in JAX-RPC.  The
concepts are very similar to the enumeration mapping in CORBA idl->java.

 * This file was auto-generated from WSDL
 * by the Apache Axis Wsdl2java emitter.

package samples.addr;

public class StateType implements {
    private java.lang.String _value_;
    private static java.util.HashMap _table_ = new java.util.HashMap();

    // Constructor
    protected StateType(java.lang.String value) {
        _value_ = value;

    public static final java.lang.String _TX = "TX";
    public static final java.lang.String _IN = "IN";
    public static final java.lang.String _OH = "OH";
    public static final StateType TX = new StateType(_TX);
    public static final StateType IN = new StateType(_IN);
    public static final StateType OH = new StateType(_OH);
    public java.lang.String getValue() { return _value_;}
    public static StateType fromValue(java.lang.String value)
          throws java.lang.IllegalStateException {
        StateType enum = (StateType)_table_.get(value);
        if (enum==null) throw new java.lang.IllegalStateException();
        return enum;
    public boolean equals(Object obj) {return (obj == this);}
    public int hashCode() { return _value_.hashCode();}
    public String toString() { return _value_;}
Here is what the AddressBook addEntry call looks like going
over the wire (from tcpmon).  Note that the state field properly
references the new stateType instance.  Also note that the
stateType instance does not contain any elements, it simply contains
the appropriate content (IN).

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV
="" xmlns:xsd
="" xmlns:xsi
  <ns3:addEntry xmlns:ns3="urn:AddressFetcher2">
   <name xsi:type="xsd:string">Purdue Boilermaker</name>
   <address href="#id0"/>
  <multiRef id="id0" xsi:type="ns7:address" xmlns:ns7
   <phoneNumber href="#id1"/>
   <zip xsi:type="xsd:int">47907</zip>
   <streetNum xsi:type="xsd:int">1</streetNum>
   <state href="#id2"/>
   <streetName xsi:type="xsd:string">University Drive</streetName>
   <city xsi:type="xsd:string">West Lafayette</city>
  <multiRef id="id2" xsi:type="ns19:stateType" xmlns:ns19
  <multiRef id="id1" xsi:type="ns21:phone" xmlns:ns21
   <exchange xsi:type="xsd:string">494</exchange>
   <areaCode xsi:type="xsd:int">765</areaCode>
   <number xsi:type="xsd:string">4900</number>


Rich Scheuerle
ORB/IDLC Development
512-838-5115  (TL 678-5115)

View raw message