Return-Path: Delivered-To: apmail-ws-axis-user-archive@www.apache.org Received: (qmail 41775 invoked from network); 12 Nov 2003 22:09:06 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Nov 2003 22:09:06 -0000 Received: (qmail 91333 invoked by uid 500); 12 Nov 2003 22:08:37 -0000 Delivered-To: apmail-ws-axis-user-archive@ws.apache.org Received: (qmail 91317 invoked by uid 500); 12 Nov 2003 22:08:37 -0000 Mailing-List: contact axis-user-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-user@ws.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-user@ws.apache.org Received: (qmail 91241 invoked from network); 12 Nov 2003 22:08:36 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C3A969.872DD240" Subject: RE: xsd choice problem using castor serialization on the server side and axis wsdl2java on the client side Date: Wed, 12 Nov 2003 17:08:40 -0500 Message-ID: <8B508C0CF15D4F4D82C9EA3B67B5274C11D821@corpmx1.ctronsoft.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: xsd choice problem using castor serialization on the server side and axis wsdl2java on the client side Thread-Index: AcOpXGklRdxBRW4aRGGeJo7arSfhAgACny7A From: "Sapozhnikov, Michael" To: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C3A969.872DD240 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Keith, =20 Until choice will be fully implemented in AXIS, I could suggest two = workarounds: =20 1. Programmatically in you client code similar to this: =20 org.apache.axis.description.ElementDesc field; field =3D = (ElementDesc)requestChoice.getTypeDesc().getFieldByName("hat"); field.setMinOccurs(0); field =3D = (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 =20 =20 -----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. =20 Given the following wsdl with an xsd:choice group (this is just an = academic example to show the problem) =20 ... =20 =20 ... .... =20 An axis client using WSDL2Java on the above wsdl sends the following = SOAP message: ... its a shirt ... =20 =20 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 =20 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. =20 Why does axis serialization marshall a "MyChoice" object, with the = "shirt" choice set, into an xml message with the = and 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? =20 =20 Thanks =20 Keith =20 =20 =20 ------_=_NextPart_001_01C3A969.872DD240 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Keith,
 
Until=20 choice will be fully implemented in AXIS, I could suggest two=20 workarounds:
 
1.  Programmatically in you client code similar to=20 this:
 
       =20 org.apache.axis.description.ElementDesc = field;
        field =3D=20 (ElementDesc)requestChoice.getTypeDesc().getFieldByName("hat");
       =20 field.setMinOccurs(0);
        field =3D=20 (ElementDesc)requestChoice.getTypeDesc().getFieldByName("umbrella");
       =20 field.setMinOccurs(0);

2.=20 Make change in your schema to set each element's minOccurs to zero. This = way you=20 don't have to set minOccurs = programmatically.

Thanks,

Mike

 
 
 -----Original=20 Message-----
From: Keith Bohnenberger=20 [mailto:kbohnenberger@mcdonaldbradley.com]
Sent: Wednesday, = November=20 12, 2003 3:14 PM
To: = axis-user@ws.apache.org
Subject: xsd=20 choice problem using castor serialization on the server side and axis=20 wsdl2java on the client side

I=20 am using Axis 1.1 (not the CVS version with castor serialization) and = doing=20 the castor serialization on the server side by=20 hand.

 

Given=20 the following wsdl with an xsd:choice group = (this is=20 just an academic example to show the = problem)

 

  = ...

  <xsd:schema ...">

     = <xsd:complexType = name=3D"MyChoice">

        = <xsd:choice>

          =20 <xsd:element name=3D"shirt"=20 type=3D"xsd:string"/>

          =20 <xsd:element name=3D"hat"=20 type=3D"xsd:string"/>

          =20 <xsd:element name=3D"umbrella"=20 type=3D"xsd:string"/>

        = </xsd:choice>

     = </xsd:complexType>

     = <xsd:element name=3D"requestChoice"=20 type=3D"MyChoice"/>

     = <xsd:element name=3D"responseChoice"=20 type=3D"MyChoice"/>

  </xsd:schema>

 </wsdl:types>

 <wsdl:message = name=3D"showChoiceResponse">

    <wsdl:part element=3D"impl:responseChoice"=20 name=3D"body"/>

 </wsdl:message>

 

 <wsdl:message = name=3D"showChoiceRequest">

    <wsdl:part element=3D"impl:requestChoice"=20 name=3D"body"/>

 </wsdl:message>=20

 ...

 ....

 

An = axis client=20 using WSDL2Java on the above wsdl sends the following SOAP=20 message:

...

<soapenv:Body>

  <requestChoice=20 xmlns=3D"http://schema.mbi.com">

   <shirt>its a=20 shirt</shirt>

   <hat xsi:nil=3D"true"/>

   <umbrella xsi:nil=3D"true"/>

 =20 </requestChoice>

 </soapenv:Body>

...

 

 

On = the server side=20 the castor unmarshalling throws this = exception

ValidationException: The element 'hat' = cannot exist at=20 the same time that element 'shirt' also exists.;

-        =20 location of error: XPATH: = requestChoice

 

Based on the=20 definition of an xsd:choice group, it seems = like=20 castor is doing the right thing on the server side and axis is doing = the wrong=20 thing on the client side.

 

Why = does axis=20 serialization=20 marshall a=20 “MyChoice” object, with the “shirt” choice = set, into an xml message with the=20 <hat xsi:nil=3D"true"/> and = <umbrella=20 xsi:nil=3D"true"/> elements in there?

Is = there a way to=20 stop the xsi:nil elements from being added = to the=20 soap message on the axis side?

With = the axis cvs=20 release will the castor serialization behave any=20 differently?

With = the axis cvs=20 release will the axis client side behave any=20 differently?

 

 

Thanks

 

Keith

 

 

 

------_=_NextPart_001_01C3A969.872DD240--