Thursday, October 11, 2012

How can I make a WebMethod parameter required

I've verified that Metro 2.0 does allow you to set @XmlElement(required=true) on a parameter. The generated xsd does not have minOccurs=0. It leaves minOccurs out of the generated xsd so it assumes the default value of 1.
You also have to upgrade your JDK by putting the JAX-WS 2.2 webservices-api.jar in the endorsed/ directory.
I posted the same question on the Java forums.
Thanks to jitu for both the answer and pointing out that minOccurs defaults to 1 so leaving it out of the .xsd has the desired effect.
When @XmlElement(required=true) is set on the parameter SoapUI no longer indicates that the parameter as optional.

http://stackoverflow.com/questions/2210346/how-can-i-make-a-webmethod-parameter-required

No comments:

Post a Comment