2

I am trying to make my @webparam mandatory using (@XmlElement(required=true) but the generated XSD still shows this as minOccurs="0". Also tried setting nillable=false but still not working.

Here is my web method :

@WebMethod
@WebResult(name = "Biller")
public Biller getBiller(@XmlElement(required=true) @WebParam(name = "billerId") Integer billerId){}

Please suggest.

Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
Mrinal Sharma
  • 97
  • 2
  • 10

1 Answers1

1

As specified by me in comments - either you need to wrap your Integer variable into some Java POJO and apply rules for specific fields in that POJO or change to primitive type because - reference types are always optional but constituent fields of wrapper types can be made required or optional. Primitive types are always required.

Refer this answer

Then comes the question about default values - and for that refer Answers to this question and summary is - if nothing is specified -

minOccurs and maxOccurs default to 1

Now why your call succeeds with SOAP UI - Your xsd is correct and that is acknowledged by SOAP UI so my guess is client might be attaching some default values when its missing. I haven't used SOAP UI. Try examining your request ans see if value is really missing. If value is indeed missing in request then try to examine as why validation is not kicking in.

Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
  • Thanks for the anwer, SOAP UI started validating my request against XSD schema when I added @com.sun.xml.ws.developer.SchemaValidation to my Web service class . But now I am getting com.sun.xml.ws.encoding.soap.DeserializationException for response which I am trying to figure out. Thanks agian :) – Mrinal Sharma Apr 05 '18 at 05:06