This topic provides an example of a Web services mapper
definition that is used by a Web services access operation to invoke
Web services.
The Web services function that is invoked requests a ''String'
parameter and one ''int' parameter. The execution result is a com.ibm.btt.wsc.op.test.service.UserAccount JavaBean
class. Figure 1 is an example of a Web
services mapper definition, and it contains three Web services mapper
definitions for data conversion: two input mappers and one output
mapper:
Figure 1. Example of a Web services mapper
definition.<fmtDef id="inputFmt0">
<wsMapperConverter isPrimitive="false" javaClass="java.lang.String">
<map from="arg0" to="*" byReference="true"/>
</wsMapperConverter>
</fmtDef>
<fmtDef id="inputFmt1">
<wsMapperConverter isPrimitive="true" javaClass="int">
<map from="arg1" to="*" byReference="true"/>
</wsMapperConverter>
</fmtDef>
<fmtDef id="outputFmt">
<wsMapperConverter isPrimitive="false"
javaClass="com.ibm.btt.wsc.op.test.service.UserAccount">
<map from="*" to="return" byReference="true"/>
</wsMapperConverter>
</fmtDef>
As shown in
Figure 1, a Web
services mapper definition contains the following tags:
Attributes of the <wsMapperConverter>
tag
The <wsMapperConverter> tag is connected with the
com.ibm.btt.base.ws.WSMapperConverter implementation
class, which is defined in the formatter section of the
btt.xml:
<field id="wsMapperConverter" value="com.ibm.btt.base.ws.WSMapperConverter" />
The <wsMapperConverter>
tag is the main contributor during the data conversion, and it has
the following attributes:
- isPrimitive
- The attribute is mandatory and must have one of the following
values:
- true: the Java Object in
the data conversion is a Java primitive
type (e.g. 'int', 'short', 'double').
- false: the Java Object in
the data conversion is not a Java primitive
type (e.g. 'java.lang.String', 'int[]' and JavaBean).
- javaClass
- This is a mandatory attribute. Its value is used to indicate the
actual type of the Java Object
in Java Web services operation
during data conversion.
Attributes of <map> tag
The <map>
tag is the externalizer definition for the
com.ibm.btt.base.DataMapperFormat class,
which is used to indicate the source and destination in the data mapping.
You can configure the attributes of the <map> tag to define data
conversion.
Note: The structure of the source data must be the same
as the structure of the destination data. For more information and
examples on using the Web services mapper to map data that have the
same structure, see
Defining the Web services mapper.
The
<map> tag contains the following attributes:
- from
- The attribute is mandatory. The value of this attribute indicates
the source data in the mapping process.
- to
- The attribute is mandatory. The value of this attribute indicates
the destination data in the mapping process.
- byReference
- This is an optional attribute. It indicates the Web services mapper
runtime whether to make a copy or just reference the source data to
construct the target data. The byreference attribute
must have one of the following attributes:
- True: the Web services mapper runtime references data.
- False: the Web services mapper runtime makes a data copy.