Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.6
-
None
-
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); }