You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by jwstebb <je...@gmail.com> on 2013/02/05 18:39:40 UTC

Can't get wsdlToJava to generate an element of type JaxbElement

We have an element that has the properties of nillable=true and minOccurs=0 ,
but wsdl2Java is only acknowledging the nillable=true

In order to accommodate a schema where an element is defined with attributes
nillable=true and minOccurs=0, I've updated our bindings by removing the
generateElementProperty="false" attribute from the global bindings. This
caused all elements with the attributes above to generate as the correct "3
state" capable type of JAXBElement e.g.

    @javax.xml.bind.annotation.XmlElementRef(name = "description", type =
null, required = false)
    protected javax.xml.bind.JAXBElement<java.lang.String> description;

Unfortunately this did not fix all of the situations. The reason I believe
is due to how our schemas are defined for these troublesome elements.

In a base.xsd, an element is defined with nillable=true

        <xs:element name="occurrenceNumber" type="xs:int" nillable="true">
              ......
	</xs:element>

then in the sub.xsd this element gets decorated with a minOccurs="0" 

	<xs:complexType name="Element_Type">
		<xs:sequence>
			.........
			<xs:element ref="base:occurrenceNumber" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>

But cxf's wsdlToJava only detects the nillable=true property and generates
the property as an Integer instead of a JaxbElement:

    @javax.xml.bind.annotation.XmlElement(namespace = "proper namespace",
nillable = true)
    protected java.lang.Integer occurrenceNumber;

Any help in figuring out how to get JAXB to recognize these fields as
nillable=true and minOccurs=0 and to generate a JaxbElement for them would
be much appreciated.

Thanks!

Versions: 
   1) jaxb 2.2.4
   2) cxf 2.5.1-2



--
View this message in context: http://cxf.547215.n5.nabble.com/Can-t-get-wsdlToJava-to-generate-an-element-of-type-JaxbElement-tp5722767.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Re: Can't get wsdlToJava to generate an element of type JaxbElement

Posted by jwstebb <je...@gmail.com>.
We upgraded to the latest version of JAXB (v2.2.6 at this time) and it fixed
the issue around generating JaxbElement(s) at the proper time.



--
View this message in context: http://cxf.547215.n5.nabble.com/Can-t-get-wsdlToJava-to-generate-an-element-of-type-JaxbElement-tp5722767p5722807.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Re: Can't get wsdlToJava to generate an element of type JaxbElement

Posted by Daniel Kulp <dk...@apache.org>.
This is really a JAXB thing.  I really have no idea.

My suggestion would be to distill this down to a JAXB only thing (xsd + binding file passed to xjc) and post a quest/issue with the JAXB folks.     Wish I could help more, but I really don't know why this isn't working. 

Dan

 

On Feb 5, 2013, at 12:39 PM, jwstebb <je...@gmail.com> wrote:

> We have an element that has the properties of nillable=true and minOccurs=0 ,
> but wsdl2Java is only acknowledging the nillable=true
> 
> In order to accommodate a schema where an element is defined with attributes
> nillable=true and minOccurs=0, I've updated our bindings by removing the
> generateElementProperty="false" attribute from the global bindings. This
> caused all elements with the attributes above to generate as the correct "3
> state" capable type of JAXBElement e.g.
> 
>    @javax.xml.bind.annotation.XmlElementRef(name = "description", type =
> null, required = false)
>    protected javax.xml.bind.JAXBElement<java.lang.String> description;
> 
> Unfortunately this did not fix all of the situations. The reason I believe
> is due to how our schemas are defined for these troublesome elements.
> 
> In a base.xsd, an element is defined with nillable=true
> 
>        <xs:element name="occurrenceNumber" type="xs:int" nillable="true">
>              ......
> 	</xs:element>
> 
> then in the sub.xsd this element gets decorated with a minOccurs="0" 
> 
> 	<xs:complexType name="Element_Type">
> 		<xs:sequence>
> 			.........
> 			<xs:element ref="base:occurrenceNumber" minOccurs="0"/>
> 		</xs:sequence>
> 	</xs:complexType>
> 
> But cxf's wsdlToJava only detects the nillable=true property and generates
> the property as an Integer instead of a JaxbElement:
> 
>    @javax.xml.bind.annotation.XmlElement(namespace = "proper namespace",
> nillable = true)
>    protected java.lang.Integer occurrenceNumber;
> 
> Any help in figuring out how to get JAXB to recognize these fields as
> nillable=true and minOccurs=0 and to generate a JaxbElement for them would
> be much appreciated.
> 
> Thanks!
> 
> Versions: 
>   1) jaxb 2.2.4
>   2) cxf 2.5.1-2
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Can-t-get-wsdlToJava-to-generate-an-element-of-type-JaxbElement-tp5722767.html
> Sent from the cxf-dev mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com