You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by R J Scheuerle Jr <sc...@us.ibm.com> on 2002/03/26 20:21:01 UTC

Re: Does WSDL2Java handle "choice groups"

Jeff,

According to XML Schema, your example is correct.

I will try to make some time today to fix the problem in WSDL2Java

Thanks,

Rich Scheuerle
XML & Web Services Development
512-838-5115  (IBM TL 678-5115)


                                                                                                                                       
                      Jeff P Lee                                                                                                       
                                               To:      R J Scheuerle Jr/Austin/IBM@IBMUS                                              
                      03/26/2002 12:29         cc:                                                                                     
                      PM                       From:    Jeff P Lee/Rochester/IBM@IBMUS                                                 
                                               Subject: Re: Does WSDL2Java handle "choice groups"(Document link: R J Scheuerle Jr)     
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       



Hi Rich,
Does a <choice> need to be inside a <sequence> in order for WSDL2Java to
work?
For example, this works:

<xsd:complexType name="foo">
  <xsd:sequence>
    <xsd:choice>
        <xsd:element name="one" type="xsd:string"/>
        <xsd:element name="two" type="xsd:string" />
      <xsd:element name="three" type="xsd:string" />
    </xsd:choice>
  </xsd:sequence>
</xsd:complexType>

... but this doesn't (no methods besides equals() get generated):

<xsd:complexType name="foo">
    <xsd:choice>
        <xsd:element name="one" type="xsd:string"/>
        <xsd:element name="two" type="xsd:string" />
      <xsd:element name="three" type="xsd:string" />
    </xsd:choice>
</xsd:complexType>




                                                                                                                                       
                      R J Scheuerle Jr                                                                                                 
                                               To:      Jeff P Lee/Rochester/IBM@IBMUS                                                 
                      03/06/02 05:21 PM        cc:      Russell Butek/Austin/IBM@IBMUS                                                 
                                               From:    R J Scheuerle Jr/Austin/IBM@IBMUS                                              
                                               Subject: Re: Does WSDL2Java handle "choice groups"(Document link: Jeff Lee)             
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       



Jeff,

I assume that you are familiar with the specification JAX-RPC JSR-101 ?

This specification defines the java <-> xml schema mappings.  The current
specification
indicates that support of xsd:choice and xsd:groups is optional...and it
does not define
a mapping for these xml types.  Therefore anything that we implement is
likely to change.

So here is what Axis (WSDL2Java) supports:
   An element under a xsd:choice is treated just like any elements
   underneath an xsd:all or xsd:sequence.  There is no difference in the
   way it is mapped to the java bean.
   The "anonymous" version of xsd:group is supported, and the elements
   underneath the group are treated like elements underneat xsd:all or
   xsd:sequence.  Here is an example of an "anonymous" group usage:
<xsd:complexType name="foo">
  <xsd:sequence>
    <xsd:choice>
      <xsd:group>
        <xsd:element name="one" type="xsd:string"/>
        <xsd:element name="two" type="xsd:string" />
      </xsd:group>
      <xsd:element name="three" type="xsd:string" />
    </xsd:choice>
    <xsd:element name="four" type="xsd:four" />
  </xsd:sequence>
</xsd:complexType>

Here is what Axis does not support:
   Full support for Axis would require runtime checks to ensure proper
   semantics of choice.  For example in the above code, the runtime would
   need to make sure that either one and two was specified or three was
   specified.  This affects both serialization and deserialization.
   The Java2WSDL emitter will not generate choice or group wsdl
   elements....This is due to the fact that choice and group are mapped
   just like sequence elements.
   WSDL2Java does not support named groups.  The xml schema below is the
   same as above using named groups.  Supporting named groups would require
   some extensive changes to the WSDL2Java symbol table...would take me
   several days to implement.

<xsd:complexType name="foo">
  <xsd:sequence>
    <xsd:choice>
      <group ref="myGroup"/>
      <xsd:element name="three" type="xsd:string" />
    </xsd:choice>
    <xsd:element name="four" type="xsd:four" />
  </xsd:sequence>
</xsd:complexType>
<xsd:group name="myGroup">
     <xsd:element name="one" type="xsd:string"/>
     <xsd:element name="two" type="xsd:string" />
</xsd:group>

If you require support for choice/group, please send me a detailed summary
of the level of support.
Also send me your prefered choice<->java mapping so that I can run it by
the Axis Committers.
If the mapping seems reasonable, we may be able to get the JSR 101 expert
group to consider the mapping
for the next version of the specification.

Thanks,

Rich Scheuerle
XML & Web Services Development
512-838-5115  (IBM TL 678-5115)


                                                                                                                                       
                      Jeff P Lee                                                                                                       
                                               To:       R J Scheuerle Jr/Austin/IBM@IBMUS                                             
                      03/06/2002 04:46         cc:                                                                                     
                      PM                       From:     Jeff P Lee/Rochester/IBM@IBMUS                                                
                                               Subject:  Does WSDL2Java handle "choice groups"                                         
                                                                                                                                       
                                                                                                                                       
                                                                                                                                       



Hi Rich,
I'm developing eServer Web Services support, and we've been instructed to
use AXIS as our reference tools environment.  (BTW - I spoke with you
earlier today, and your suggestion to download the Feb 28 nightly build
solved the problem I was having.)

I have another question for you:  Do you happen to have an example of a
WSDL <choice> group that WSDL2Java handles correctly?  There was a post on
the axis-user mailing list on 2/26 by Luis Novais who seemed to be having
the same problem - that is, that <choice> groups are ignored by WSDL2Java.
You responded by asking Luis for a copy of his WSDL.

- Jeff Lee, IBM Toolbox for Java team, IBM-Rochester, Minnesota
-  tie-line 553-2779