This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Services and the fly likes MaxLength Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "MaxLength" Watch "MaxLength" New topic


Suri Babs
Ranch Hand

Joined: Mar 27, 2003
Posts: 50
Hi All,

Apache Axis 1.4 WSDL2Java is not generating code for maxLength

<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<xsd:maxLength value="10"/>

Is there any alternative on how to handle this or Is there any way to make Axis generate this code?

Help is required on this.

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
I am not entirely sure, but I think that JAXB will not generate code that enforces maxLength either.
What you can do is:
1) Add code to enforce maxLength in the generated class.
A less good approach, if you ever re-generate the code.
2) Create a subclass of the generated class and override method(s) to enforce maxLength.
A better approach.
3) Use AOP to instrument the generated class to add enforcement of the maxLength.
Also a better approach, compared to 1.
Best wishes!
I agree. Here's the link:
subject: MaxLength
Similar Threads
Problem with SOAP
Information lost on error.
maxlength validation not working
Displaying date in text box
Struts Validator-Validating an Integer Form Field