Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2699

MapType does not output XML that matches the generated schema

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.6
    • Fix Version/s: 2.2.7
    • Component/s: Aegis Databinding
    • Labels:
      None
    • Environment:

      windows xp, java 5

      Description

      The MapType class (in org.apache.cxf.aegis.type.collection) creates the schema element for maps. It does not set nillable for the value in the entry.

      It is legal to have

      HashMap<String, Object> myMap containing

      {myKey->null}

      and to return such a map from a call to a web method.

      The following wsdl is generated :

      ...
      <xsd:element name="myMap" nillable="true" type="string2anyTypeMap" />
      ...

      <xsd:complexType name="string2anyTypeMap">
      <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="entry">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element minOccurs="0" name="key" type="xsd:string" />
      <xsd:element minOccurs="0" name="value" type="xsd:anyType" />
      </xsd:sequence>
      </xsd:complexType>

      On a query that retrieves myMap I can get

      ...
      <entry>
      <key>myKey</key>
      <value ns6:nil="true" xmlns:ns6="http://www.w3.org/2001/XMLSchema-instance"/>
      </ns1:entry>

      which does not conform to the generated schema.

      In type MapType createElement should probably be renamed to createKeyElement and a new createValueElement method that sets nillable to the result of type.isNillable().

      Current method:
      /**

      • Creates a element in a sequence for the key type and the value type.
        */
        private void createElement(XmlSchemaSequence seq, QName name, Type type) { XmlSchemaElement element = new XmlSchemaElement(); seq.getItems().add(element); element.setName(name.getLocalPart()); element.setSchemaTypeName(type.getSchemaType()); element.setMinOccurs(0); element.setMaxOccurs(1); }

        Attachments

          Activity

            People

            • Assignee:
              dkulp Daniel Kulp
              Reporter:
              alistairmclean alistair
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: