I have used below getter method level XmlElement annotation for generating xsd from Java class.
@XmlElement(type=Integer.class, required=true)
public int [] getTestArrayInt () { …. }
Generated XML element:
<xsd:element name="testArrayInt" type="xsd:int"/>
minOccurs’s default value is said to be 1. Hence, it is not being displayed here.
But maxOccurs=”unbounded” which should be listed for Array elements is missing. Soap UI expects maxOccurs=”unbounded” to be present for the array elements. As a result, in Soap UI, this element is not being treated as an array.
When I removed type=Integer.class from the annotation, I started getting maxOccurs=”unbounded” in the XML.
@XmlElement(required=true) generated below element:
<xsd:element name="testArrayInt" type="xsd:int" maxOccurs="unbounded"/>
But I need this type specially for primitive datatypes. Without type in annotation, minOccurs=1 gets missing for elements which are not required (i.e. required =true is not set).
Can someone help me in this?
Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
The issue you describe appears to occur in EclipseLink JAXB (MOXy) but not the JAXB reference implementation. MOXy is the default JAXB provider in WebLogic 12.1.1 (see: http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb-provider-in.html). You can track our progress on this issue using the following bug. If you are a WebLogic customer please enter a bug so that you may receive the appropriate patch.
Java Model
Schema (Generated by JAXB RI)
Schema (Generated by EclipseLink JAXB (MOXy))
Schema Generation Code