I have a web sercice method that gets an object. One attribute is the "interval", which is an integer.
I would like to make this attribute necessary, but without providing a default value - I want the user to explicitly set the value.
If I use int interval- the attribute is displayed as int, and if the user does not explicitly set the attribute, zero will be sent (Java default for primitive int).
If I use Integer interval- the attribute is displayed as Integer and is declared optional in the WSDL, so the user cannot see that it is needed before sending the request.
If I use Integer intervalwith @XmlElement(required = true)or @XmlElement(nillable = false)- the attribute is displayed as int.
An attribute can have any integer - negative, zero, and positive, so I cannot use the default value to indicate that the attribute is not explicitly set.
I can use BigInteger intervalwith @XmlElement(required = true), but we miss the benefits of using the main type Integer.
I would like to show the attribute as Integer, so I will get null if the user has not set the attribute, and at the same time I would like the WSDL to detect that the attribute is required, so that users know what is required just by looking at the WSDL.
source
share