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

  • Home
  • SEARCH
  • 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 6653723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:18:17+00:00 2026-05-26T01:18:17+00:00

I have a web sercice method that recieves an object. One of the attributes

  • 0

I have a web sercice method that recieves an object. One of the attributes is “interval” which is an integer.

I would like to make this atribute required but without providing any default value – I want the user to be required to explicitly set a value.

If I use int interval – the attribute is exposed as int and if the user does not explicitly set the attribute, a zero (Java default for primitive int) will be sent.

If I use Integer interval – the attribute is exposed as Integer and is declared optional in the WSDL so the user can’t see it is required before sending the request.

If I use Integer interval with @XmlElement(required = true) or @XmlElement(nillable = false) – the attribute is exposed as int.

The attribute can have any integer – negative, zero and positive so I can’t use a default value to indicate that the attribute was not explicitly set.

I can use BigInteger interval with @XmlElement(required = true) but than we are missing the advantages of using the core type Integer.

I would like to expose the attribute as Integer so I will get null if the user did not set the attribute and at the same time I would like the WSDL to expose that the attribute is required so users will know it is required simply by looking at the WSDL.

  • 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-05-26T01:18:18+00:00Added an answer on May 26, 2026 at 1:18 am

    With @XmlElement(required = true) the WSDL was correct but the problem was that when using org.apache.cxf.tools.wsdlto.WSDLToJava tool on my WSDL the client was generated
    with int interval instead of Integer interval.

    The solution is to pass the “-b” option to the wsdl2java tool with a path to a jaxb bindings file that maps xsd:int to java.lang.Integer:

    <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               jaxb:version="2.0">
      <jaxb:globalBindings>
        <jaxb:javaType name="java.lang.Integer"
                       xmlType="xsd:int" />
      </jaxb:globalBindings>
    </jaxb:bindings>
    

    Using @XmlElement(required = true) and the “-b ” option, kept the element required (minOccurs=”1″) and exposed it as an Integer to the Java client.

    More info: http://cxf.547215.n5.nabble.com/How-to-declare-an-attribute-required-and-non-primitive-td4815370.html

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

Sidebar

Related Questions

I have a Web Service with Just one Web Method that returns a boolean
I have a web service method where I would like to throw some custom
I have the web service, which has method State() that returning the List. where
I have a web service (ASMX) and in it, a web method that does
I have a web service method in which I create a particular type of
When I call, the service's method, I have Web Service Exception happening which I
Short and sweet version: Is there a single web service method that would return
I have a web service method, this calls functionality that's pretty complex in a
I have a web service that looks like this: public class TheService : System.Web.Services.WebService
I have a simple web service method that returns a simple java class as

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.