users@jax-ws.java.net

Mapping Hashmaps

From: Sameer Tyagi <styagi_at_usc.edu>
Date: Thu, 24 May 2007 10:55:36 -0400

I have an exception class that holds a hashmap as its field.
I annotated it as below

@XmlAccessorType(XmlAccessType.FIELD)
@WebFault
@XmlSeeAlso(MapedException.class)
public class POProcessingProblem extends WebServiceException {

        @XmlJavaTypeAdapter(HasMapAdapter.class)
        @XmlElement(name = "errorfields", required = true, nillable = false)
        private HashMap<String, ArrayList> mappings;


The adaptor maps the hasmap to a bean MapedException.class that can be marshalled/unmarshalled to XML.

However when the schema is generated it looks like this. The name is not the same as that annotated above (errorfields) and I dont see the mapped class from the adaptor. Is there something wrong with this code or is this a bug ?


 <xs:complexType name="POProcessingProblem">
    <xs:sequence>
      <xs:element name="mappings">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="key" minOccurs="0" type="xs:anyType"/>
                  <xs:element name="value" minOccurs="0" type="xs:anyType"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>





/s