Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:14:46+00:00 2026-06-15T07:14:46+00:00

Question : Using CXFs wsdl2java, is it possible to include restrictions of the schema

  • 0

Question: Using CXFs wsdl2java, is it possible to include restrictions of the schema elements and types in the generated Java stubs?

Use case:
if my WSDL includes the following type:

 <xs:complexType name="TestResponse">
  <xs:sequence>
    <xs:element name="code">
      <xs:simpleType>
        <xs:restriction base="xs:int">
          <xs:maxInclusive value="5"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:element>
    <xs:element name="text">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:maxLength value="5"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:element>
   </xs:sequence>
 </xs:complexType>

wsdljava by default generates stubs with setters such as:

public void setCode(Integer value) {
    this.code = value;
}

public void setText(String value) {
    this.text = value;
}

where it would be great to have something similar to:

public void setCode(Integer value) {
    if (value > 5) throw new ValidationException();
    this.code = value;
}

public void setText(String value) {
    if (value.length() > 5) throw new ValidationException();
    this.text = value;
}

Is it correct that no such tool/JAXB plugin currently exists for XJC and hence CXFs wsdljava?

What I found out so far:

At least in 2010, according to this post in the Oracle Java
Programming forum, it seems that it is not supported out of the box or with any of the available plugins.

I am aware of the following possible alternative approaches to this (but haven’t tested them completely):

  • Using the krasa-jaxb-tools JAXB plugin to generate JSR-303 annotations on the stubs as has been discussed on stackoverflow here and here already
  • Dumping XJC and CXFs wsdl2java and using XmlBeans to generate stubs (which for me is not an option since our project relies on CXF heavily)
  • Wait for CXF to validate the stubs once they are serialized as discussed here (however, this means to loose the validation while calling the setters)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:14:48+00:00Added an answer on June 15, 2026 at 7:14 am

    I haven’t seen an XJC plugin that will do this. If you would like to pursue writing one for some of the basic validation steps, we would certainly appreciate the contribution.

    CXF’s wsdl2java does support XMLBeans if you would like to flip to using XMLBeans as the datamodel. Add the “-db xmlbeans” flag to the command line and it should generate XMLBeans stuff instead of JAXB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Are PHP short tags acceptable to use? I have a question using
This question: Using Proxy with web browser control Told me to use InternetSetOption. How
In question Using char as key in stdmap there is advised to use custom
Question: Using VB.NET/C#, is it really not possible to read the below XML in
The thing starts from my previous question : Using jQuery is it possible to
As I understand from the question below it should be possible to use different
Question: Using Ruby it is simple to add custom methods to existing classes, but
I recently posted a question using a lambda function and in a reply someone
Quick question about using IQueryable objects. Can I do something like that and if
I have a question about using HTTPS in a JBossAS7 web application (a universal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.