Runtime components : Core components : Web services access : Accessing Web services : Defining the Web services mapper
  
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 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 UDTT).
See
Prerequisites
Mapping a data field to an integer data type
Mapping a data field to a string
Mapping a keyed collection to a JavaBean
Mapping an indexed collection to an array of integers
Mapping an indexed collection that contains string objects to an array of strings
Mapping an indexed collection that contains string objects to a Java list with string element
See also
Accessing Web services
Prerequisites
To enable the Web services mappers for use, you must first declare the implementation classes of the Web services 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" />
See also
Defining the Web services mapper
Mapping a data field to an integer data type
The following example is a Web services mapper that is designed to map a data field from 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>
See also
Defining the Web services mapper
Mapping a data field to a string
The following example is a definition of a Web services mapper that is designed to map a data field to a string from a Web services data model. In the following example, 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>
See also
Defining the Web services mapper
Mapping a keyed collection to a JavaBean
The following example is a definition of a Web services mapper that is designed to map a kColl from to 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>
See also
Defining the Web services mapper
Mapping an indexed collection to an array of integers
The following example is a definition of a Web services mapper that is designed to map an iColl from to an array of integers from a Web service data model. In the following example, IColl_Context2IntArray.* is used to substitute for all the elements that are contained in the iColl, and array.* is used to substitute 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>
See also
Defining the Web services mapper
Mapping an indexed collection that contains string objects to an array of strings
The following example is a definition of a Web services mapper that is designed to map an iColl from 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>
See also
Defining the Web services mapper
Mapping an indexed collection that contains string objects to a Java list with string element
The following example is a definition of a Web services mapper that is designed to map an iColl from 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>
See also
Defining the Web services mapper