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 Mandatory fields in WSDL2Java classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Mandatory fields in WSDL2Java classes" Watch "Mandatory fields in WSDL2Java classes" New topic
Author

Mandatory fields in WSDL2Java classes

Muthukrishnan Manoharan
Ranch Hand

Joined: Aug 27, 2008
Posts: 91

I have a WSDL, with which I created Java Classes through WSDL2Java tool. But the problem is not all attributes that are returned from the response SOAP XML will have a value. Some may be null also. So when I construct back the objects from the response, it is not able to parse double object or Integer object as the nulls encounter NumberFormatException. Is there anyway I can specify to by pass null objects during Java Classes creation through the tool or do we have other good way to handle this.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you have the opportunity to be able to edit the WSDL, then use minOccurs="0" for elements that are optional.
There is also a nillable attribute for elements that can be set to true to allow for null values: nillable="true"
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Muthukrishnan Manoharan
Ranch Hand

Joined: Aug 27, 2008
Posts: 91

Thanks Ivan.

Any other alternatives than changing the WSDL? Because we dont have an independence to change the WSDL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mandatory fields in WSDL2Java classes