aspose file tools*
The moose likes Web Services and the fly likes minOccurs and maxOccurs in wsdl being igored by Axis WSDL2Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "minOccurs and maxOccurs in wsdl being igored by Axis WSDL2Java" Watch "minOccurs and maxOccurs in wsdl being igored by Axis WSDL2Java" New topic
Author

minOccurs and maxOccurs in wsdl being igored by Axis WSDL2Java

Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
I have a wsdl file with a webservice method that is supposed to return a list of Java objects.
The element is defined as
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="1000">

However when I generate the client classes using org.apache.axis.wsdl.WSDL2Java, I am not getting a List as the return type.

Does axis ignore maxOccurs? What can I do to construct the classes correctly?

Thanks in advance!

Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Axis 1.x is based on JAX-RPC 1.1 (JSR-101).

JAX-RPC 1.1 (JSR-101) wrote:An element in a complex type with the maxOccurs attribute set to a non-negative integer greater than 1 or unbounded is mapped to a Java array with a pair of setter and getter methods in the JavaBeans class. The Java type of the array is mapped from the type attribute of the XML element. Refer to the following example. The JAX-RPC specification does not require support for all different combinations of the occurrence constraints (minOccurs, maxOccurs)


In other words the Java type that the XML is being mapped to is under no obligation to actually enforce the actual minOccurs/maxOccurs limits. It's obligations are
  • types with maxOccurs > 1 are mapped to an array
  • types that map to primitive Java types have to map to the corresponding Wrapper type (e.g. int -> Integer) if minOccurs=0 and maxOccurs=1

  • See also the topic Axis2 support for collections for suggestions for general List <-> Array conversions.

    "Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
    Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: minOccurs and maxOccurs in wsdl being igored by Axis WSDL2Java
     
    Similar Threads
    WSDL2Java stub class receiving ArrayList instead of single object
    Error on Axis 1,4 on invoking a web service
    Axis 1.4 does not validate input parameters?
    wsdl2java - arrays not created
    Setter method not generated in stub classes