> If I use Integer interval with @XmlElement(required = true) or > @XmlElement(nillable = false) - the attribute is exposed as int.
Isn't this what you want? In the wsdl, it would look like a required "int" that the user must specify. If they don't specify it, you would get null for the Integer object. (although you COULD turn on schema validation in which case it would throw a fault back to the user) Dan On Saturday, September 17, 2011 9:26:52 PM MosheElisha wrote: > I have a web sercice method that recieves an object. One of the attributes > is "interval" which is an integer. > > I would like to make this atribute required but without providing any > default value - I want the user to be required to explicitly set a value. > > If I use int interval - the attribute is exposed as int and if the user does > not explicitly set the attribute, a zero (Java default for primitive int) > will be sent. > > If I use Integer interval - the attribute is exposed as Integer and is > declared optional in the WSDL so the user can't see it is required before > sending the request. > > If I use Integer interval with @XmlElement(required = true) or > @XmlElement(nillable = false) - the attribute is exposed as int. > > The attribute can have any integer - negative, zero and positive so I can't > use a default value to indicate that the attribute was not explicitly set. > > I can use BigInteger interval with @XmlElement(required = true) but than we > are missing the advantages of using the core type Integer. > > I would like to expose the attribute as Integer so I will get null if the > user did not set the attribute and at the same time I would like the WSDL to > expose that the attribute is required so users will know it is required > simply by looking at the WSDL. > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/How-to-declare-an-attribute-required-and-no > n-primitive-tp4815370p4815370.html Sent from the cxf-user mailing list > archive at Nabble.com. -- Daniel Kulp [email protected] http://dankulp.com/blog Talend - http://www.talend.com
