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).
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:
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>
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.
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.
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.
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.