axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sapozhnikov, Michael" <msapozhni...@axsone.com>
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
Keith,
 
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.setMinOccurs(0);
        field = (ElementDesc)requestChoice.getTypeDesc().getFieldByName("umbrella");
        field.setMinOccurs(0);
2. Make change in your schema to set each element's minOccurs to zero. This way you don't
have to set minOccurs programmatically.
Thanks,
Mike
 
 
 -----Original Message-----
From: Keith Bohnenberger [mailto:kbohnenberger@mcdonaldbradley.com]
Sent: Wednesday, November 12, 2003 3:14 PM
To: axis-user@ws.apache.org
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:choice>
           <xsd:element name="shirt" type="xsd:string"/>
           <xsd:element name="hat" type="xsd:string"/>
           <xsd:element name="umbrella" type="xsd:string"/>
        </xsd:choice>
     </xsd:complexType>
     <xsd:element name="requestChoice" type="MyChoice"/>
     <xsd:element name="responseChoice" type="MyChoice"/>
  </xsd:schema>
 </wsdl:types>
 <wsdl:message name="showChoiceResponse">
    <wsdl:part element="impl:responseChoice" name="body"/>
 </wsdl:message>
 
 <wsdl:message name="showChoiceRequest">
    <wsdl:part element="impl:requestChoice" name="body"/>
 </wsdl:message> 
 ...
 ....
 
An axis client using WSDL2Java on the above wsdl sends the following SOAP message:
...
<soapenv:Body>
  <requestChoice xmlns="http://schema.mbi.com">
   <shirt>its a shirt</shirt>
   <hat xsi:nil="true"/>
   <umbrella xsi:nil="true"/>
  </requestChoice>
 </soapenv:Body>
...
 
 
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
side?
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?
 
 
Thanks
 
Keith
 
 
 

Mime
View raw message