Hi folks:

Currently when we have a service which uses HashMaps, like the interop echo tests, the 
WSDL that gets generated looks like this:

 <schema targetNamespace="http://xml.apache.org/xml-soap"; 
xmlns="http://www.w3.org/2001/XMLSchema";>
  <complexType name="Map">
   <complexContent>
    <extension base="tns3:AbstractMap">
     <all /> 
    </extension>
   </complexContent>
  </complexType>
  <element name="Map" nillable="true" type="tns2:Map" /> 
 </schema>
 <schema targetNamespace="http://util.java"; xmlns="http://www.w3.org/2001/XMLSchema";>
  <complexType name="AbstractMap">
   <all /> 
  </complexType>
 </schema>

Obviously this isn't too useful.  It should look something like this:

 <schema targetNamespace="http://xml.apache.org/xml-soap"; 
xmlns="http://www.w3.org/2001/XMLSchema";>
  <complexType name="Map">
   <sequence>
    <element name="item" minOccurs="0" maxOccurs="unbounded">
     <complexType>
      <all>
       <element name="key" type="xsd:anyType"/>
       <element name="value" type="xsd:anyType"/>
      </all>
     </complexType>
    </element>
   </sequence>
  </complexType>
 </schema>

This is one case where we use a non "standard" mapping between a Java concept and a 
Schema concept.  There will be others as well, and we want to support them.

So I'm working on an architectural change to deal with this by having the Serializer 
for a given class be the responsible party in generating a schema fragment which 
represents the XML encoding which that Serializer produces.  Then the WSDL generation 
subsytem simply finds the Serializer for the class in question and queries it.

This enables us to hard code the Map schema into the MapSerializer, and to allow other 
people to write custom serializers which map Java to XML in ways beyond what our bean 
mapping can do.  It also will prevent the WSDL generator from producing schema for 
types which are not explicitly mapped in our engine, which IMHO is a good thing (since 
this indicates a configuration problem).

--Glen

Reply via email to