JBossWS minOccurs Annotation Question
Issue
private java.lang.String arg0;
Issue
We create our web services via the 'bottom up' approach by annotating our classes with @WebService.
However, this generates stuff like:
<xs:complexType name="addUser">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
<xs:element minOccurs="0" name="arg1" type="xs:string"/>
<xs:element minOccurs="0" name="arg2" type="xs:string"/>
</xs:sequence>
...
Is there a way to manage the minOccurs value? Each of these arguments are required exactly once.
Environment
- JBoss Enterprise Application Platform (EAP)
- 4.3
- 5.x
- JAX-WS
Resolution
There is no annotation that will directly control the 'minOccurs' attribute, but you can use a JAXB annotation to omit the minOccurs attribute (which defaults to "1"). The key is "required=true":
@javax.xml.bind.annotation.XmlElement(required=true,nillable=false,name = "arg0")
private java.lang.String arg0;
This annotation is added to a class-level field in the transfer object that contains the field with the minOccurs attribute. Note that this may be in one of the JAX-WS wrapper classes.
As an alternative, once you generate the WSDL, you can manually edit the WSDL and then make your web service use your customized WSDL via the @WebService annotation:
@javax.jws.WebService(wsdlLocation="path/to/your/customized.wsdl")
Environment
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
