IBM WebSphere Multichannel Bank Transformation Toolkit, Version 7.1

Defining the Web services mapper

This section provides examples of how to define Web services mappers.

The examples here only cover the situation that the source data is from IBM® WebSphere® Multichannel Bank Transformation Toolkit and the destination data is from Java Web services. Users can easily change the attributes value of 'from' and 'to' to construct the WS Mapper for the other situation (from Java Web services to WebSphere Multichannel Bank Transformation Toolkit).

Prerequisites

To enable the Web services mappers to be implemented, you must first declare the implementation classes of the mappers in the btt.xml file. To declare the implementation classes, you must add the following two fields to the classTable kColl of the format kColl in the btt.xml file:

<field id="wsMapperConverter" value="com.ibm.btt.base.ws.WSMapperConverter" />
<field id="mapper" value="com.ibm.btt.base.DataMapperFormat" />

Mapping a data field to an integer data type

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit data field to an int data type from a Web service data model. The value of the byReference attribute that is specified in the <mapper> tag does not affect the data mapping because the value is assigned directly to the destination data at run time.

<!-- Context to int -->
<fmtDef id="fmt_Context2Int">
	<wsMapperConverter isPrimitive="true" javaClass="int">
		<mapper from="intField" to="*" byReference="true" />
	</wsMapperConverter>
/fmtDef

Mapping a data field to a string

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit data field to a string from a Web services data model. In the following sample, the asterisk sign (*) is used to substitute for the data from the Web service data model that is of the type java.lang.String.

<!-- Context to String -->
<fmtDef id="fmt_Context2String">
	<wsMapperConverter isPrimitive="false" javaClass="java.lang.String">
		<mapper from="strField" to="*" byReference="true" />
            </wsMapperConverter>
</fmtDef>

Mapping a keyed collection to a JavaBean

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit kColl with a JavaBean from a Web service data model. A kColl can be mapped to a JavaBean because they have the same data structure. Only data that share the same structure can be mapped to each other.

<!-- Context to JavaBean -->
<fmtDef id="fmt_Context2JavaBean">
	<wsMapperConverter isPrimitive="false" javaClass="com.ibm.btt.test.Bean">
		<mapper from="beanKColl" to="*" byReference="true"/>
	</wsMapperConverter>
</fmtDef>

A kColl can also be mapped to a JavaBean by mapping the individual fields of the kColl to the individual fields of the JavaBean.

<!-- Context to JavaBean -->
<fmtDef id="fmt_Context2JavaBean">
	<wsMapperConverter isPrimitive="false" javaClass="com.ibm.btt.test.Bean">
		<mapper from="beanKColl.field1" to="name" byReference="true"/>
                        <mapper from="beanKColl.field2" to="age" byReference="true"/>
<mapper from="beanKColl.field3" to="sex" byReference="true"/>
	</wsMapperConverter>
</fmtDef>

Mapping an indexed collection to an array of integers

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit iColl with an array of integers from a Web service data model. In the following sample, IColl_Context2IntArray.* is used to substitute for all the elements that are contained in the iColl and array.* is used to substituted for all the elements that are contained in the array. An iColl can be mapped to an array because they have the same data structure. Only data that share the same structure can be mapped to each other.

<fmtDef id="fmt_Context2IntArray">
	<wsMapperConverter isPrimitive="false" javaClass="int[]">
		<mapper from="IColl_Context2IntArray.*" to="array.*" 
			byReference="false"/>
	</wsMapperConverter>
</fmtDef>

Mapping an indexed collection that contains string objects to an array of strings

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit iColl that contains string objects to an array of strings from a Web service data model.

<fmtDef id="fmt_Context2StringArray">
	<wsMapperConverter isPrimitive="false" javaClass="java.lang.String[]">
		<mapper from="IColl_Context2StringArray.*" to="array.*">
			<byReference="false" />
	</wsMapperConverter>
</fmtDef>

Mapping an indexed collection to a Java list

The following sample Web services mapper is designed to map a WebSphere Multichannel Bank Transformation Toolkit iColl to a list of string objects.

<fmtDef id="fmt_Context2List">
	<wsMapperConverter isPrimitive="false" javaClass="java.util.List[java.lang.String]"
		<mapper from="IColl_Context2List.*" to="array.*" byReference="false"/>
	</wsMapperConverter>
</fmtDef>


Feedback