File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes XS Element mandatory/required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "XS Element mandatory/required" Watch "XS Element mandatory/required" New topic
Author

XS Element mandatory/required

thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
<xs:element name="RequestType" type="tns:Type" minOccurs="1" maxOccurs="1"/>

According to documentation for xs elements,it is not required to have minOccurs and maxOccurs set to "1",as "1" is default values for minOccurs and maxOccurs .

I am using my XSD for Webservice.When compile and run it,It does not show any validation for mandatory/required fields.It just pass through as if there is no mandatory check.I have alreay set minOccurs and maxOccurs to "1",It should give me some kind of validation,if I do not provide value for it.Am I right? Why its not taking consideration of this?

What changes I need to make RequestType mandatory or required in XSD?

When I go to generated class it shows as given below
@XmlElement(required = true)
protected Type requestType;


What is to be done for making this element mandatory and when I call without having value assigned to it,it should warn that this element is mandatory.

Thanks

[edit by moderator: changed from all caps subject line to mixed case]
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I assume that JAXB is responsible for marshalling and unmarshalling XML data and thus also responsible for validating the data.
You can try by trying to unmarshall some XML data which is incomplete.
For an example program, see page 288 in http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
I am not entirely certain whether validation is turned on by default.
Best wishes!
thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
Everthing is working fine.I could use these elements to get and set values and also I am able to get simple type on it.

I do not find any error on it.

There should be some way to do it
 
Don't get me started about those stupid light bulbs.
 
subject: XS Element mandatory/required
 
Similar Threads
XSD element validation
Error in SOAP response when webservice is deployed in Weblogic
wsimport command error --Undefined symbol or complex type
Axis 1.4 does not validate input parameters?
XML schema fails to load