axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sapozhnikov, Michael" <>
Subject RE: xsd choice problem using castor serialization on the server side and axis wsdl2java on the client side
Date Wed, 12 Nov 2003 22:08:40 GMT
Until choice will be fully implemented in AXIS, I could suggest two workarounds:
1.  Programmatically in you client code similar to this:
        org.apache.axis.description.ElementDesc field;
        field = (ElementDesc)requestChoice.getTypeDesc().getFieldByName("hat");
        field = (ElementDesc)requestChoice.getTypeDesc().getFieldByName("umbrella");
2. Make change in your schema to set each element's minOccurs to zero. This way you don't
have to set minOccurs programmatically.
 -----Original Message-----
From: Keith Bohnenberger []
Sent: Wednesday, November 12, 2003 3:14 PM
Subject: xsd choice problem using castor serialization on the server side and axis wsdl2java
on the client side

I am using Axis 1.1 (not the CVS version with castor serialization) and doing the castor serialization
on the server side by hand.
Given the following wsdl with an xsd:choice group (this is just an academic example to show
the problem)
  <xsd:schema ...">
     <xsd:complexType name="MyChoice">
           <xsd:element name="shirt" type="xsd:string"/>
           <xsd:element name="hat" type="xsd:string"/>
           <xsd:element name="umbrella" type="xsd:string"/>
     <xsd:element name="requestChoice" type="MyChoice"/>
     <xsd:element name="responseChoice" type="MyChoice"/>
 <wsdl:message name="showChoiceResponse">
    <wsdl:part element="impl:responseChoice" name="body"/>
 <wsdl:message name="showChoiceRequest">
    <wsdl:part element="impl:requestChoice" name="body"/>
An axis client using WSDL2Java on the above wsdl sends the following SOAP message:
  <requestChoice xmlns="">
   <shirt>its a shirt</shirt>
   <hat xsi:nil="true"/>
   <umbrella xsi:nil="true"/>
On the server side the castor unmarshalling throws this exception
ValidationException: The element 'hat' cannot exist at the same time that element 'shirt'
also exists.;
-         location of error: XPATH: requestChoice
Based on the definition of an xsd:choice group, it seems like castor is doing the right thing
on the server side and axis is doing the wrong thing on the client side.
Why does axis serialization marshall a "MyChoice" object, with the "shirt" choice set, into
an xml message with the <hat xsi:nil="true"/> and <umbrella xsi:nil="true"/> elements
in there?
Is there a way to stop the xsi:nil elements from being added to the soap message on the axis
With the axis cvs release will the castor serialization behave any differently?
With the axis cvs release will the axis client side behave any differently?

View raw message