webMethods and Intelligent Business Operations 10.2 | Designing and Implementing Composite Applications | webMethods CAF and OpenCAF Development Help | Working with Web Services | About XSD Schema Choice Declarations
 
About XSD Schema Choice Declarations
When a service request element XSD schema contains a complex type with a choice declaration, all potential choice elements are considered optional. When the choice elements are of complex type, apart from populating the fields of the optional element, you must also initialize the optional element itself by using the setter method of the parent bean.
For example:
<element name="Parent">
<complexType>
<choice>
<element ref="tns:Red"/>
<element ref="tns:Blue"/ >
</choice >
</complexType>
</element >
<element name="Red" >
<complexType >
<sequence >
<element name="redField" type="string"/ >
</sequence >
</complexType >
</element >
<element name="Blue" >
<complexType >
<sequence >
<element name="blueField" type="string"/ >
</sequence >
</complexType >
</element >

Red myRed = new Red() ;
myRed.setRedField("test") ;
parent.setRed(myRed);

Copyright © 2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release