I'm creating a web service with JAX-WS. In an operation, I get an object that contains some attributes and I want these attributes to always come with value.
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RequestConsultarMargem {
@XmlElement(name = "usuario-webservice", required = true, nillable = false)
public String usuarioWebservice;
}
In% annotation% specified @XmlElement
to validate if element came in XML, and required = true
, to validate if element content is not empty.
For the validation to be performed, I put the nillable = false
annotation in the service:
@WebService
@SchemaValidation
public class MargemWS {
@WebMethod(operationName = "consultarMargem")
@WebResult(name = "retorno-consulta-margem")
public ResponseConsultarMargem consultarMargem(@WebParam(name = "consultar-margem")
@XmlElement(required = true, nillable = false) RequestConsultarMargem request) {
...
}
}
However, when uploading the server and checking the generated XSD, the @SchemaValidation
attribute was not placed in the attribute:
<xs:complexType name="requestConsultarMargem">
<xs:sequence>
<xs:element name="usuario-webservice" type="xs:string"/>
</xs:sequence>
</xs:complexType>
nillable
worked because the element in XSD did not come with the nillable = false
attribute.
I'm using JAX-WS in version 2.2.10.
What could be wrong?