Generating XML Constructs in SOAP Messages
A WSDL or schema can contain choice, list, or union elements. Web service transformations can generate SOAP messages that contain these elements.
Choice Element
A choice element restricts a child element to one of the elements in the <choice> declaration.
To map ports to a SOAP message that contains choice elements, create one input group that includes all the elements in the choice construct. For example, an item description might be a dimension or a weight:
item: description, choice {dimension, weight}
When the description is a dimension, the description is a complex type that contains, length, width, and height.
When the description is a weight, the description is a simple string type.
The input data has the following columns and rows:
description | length | width | height | weight |
---|
box | 20cm | 18cm | 15cm | NULL |
coffee | NULL | NULL | NULL | 500g |
The SOAP message contains an Item group that contains dimensions or weight descriptions:
Item
Description
Dimension
Length
Width
Height
Weight
The NULL values in the input data become missing elements in the XML output.
The SOAP message contains the following data:
<item>
<desc>box</desc>
<dimension>
<length>20cm</length>
<width>18cm</width>
<height>15cm</height>
</dimension>
</item>
<item>
<desc>coffee</desc>
<weight>500g</weight>
</item>
List Element
A list is an XML element that can contain multiple simple type values in the same element or attribute. The Data Integration Service can process a list in the input data if the list is represented as consolidated string of data.
If each item in the list is a separate element, such as ClassDates1, ClassDates2, and ClassDates3, the Data Integration Service cannot process the items as a list. You can use an Expression transformation to combine them into a string if you need to return a list in a SOAP message.
The following input rows contain a list element called ClassDates that contains days of the week:
CourseID | Name | ClassDates |
---|
Math 1 | Beginning Algebra | Mon Wed Fri |
History 1 | World History | Tue Thu |
The Data Integration Service can return a SOAP message with the following XML structure:
<class>
<courseId>Math 1</courseId>
<name>Beginning Algebra</name>
<classDates>Mon Wed Fri</classDates>
</class>
<class>
<courseId>History 1</courseId>
<name>World History</name>
<classDates>Tue Thu</classDates>
</class>
Union Element
The union element is a simple type that is a union of more than one type. When a SOAP message contains a union element, you must map a single input port that contains the data in a string.
For example, the SOAP message contains an element called size. Size is a union of integer and string:
<xs:element name="size">
<xs:simpleType>
<xs:union memberTypes="size_no size_string" />
</xs:simpleType>
</xs:element>
The input rows contain items with a description and size. An item can have a numeric size, such as 42. Or, an item can have a size that is a string value, such as large, medium, or small.
The following table shows input rows with a numeric size and a string size:
Desc | Size |
---|
shoes | 42 |
shirt | large |
Create one port for the item size. Map the port as a string. The SOAP message contains the following elements:
<item>
<desc>shoes</desc>
<size>42</size>
</item>
<item>
<desc>shirt</desc>
<size>large</size>
</item>