1. Problem
You would like to transform an XML message, or multiple XML messages, into the format of another specified XML schema.
2. Solution
Using the Transform shape
within the BizTalk Orchestration Designer allows you to transform XML
messages into the format of another specified XML schema. As an example,
assume an orchestration message (Customer schema) requires transformation (mapping) in preparation for a publication to another line-of-business application.
<Customer>
<FirstName> </FirstName>
<LastName> </LastName>
<MiddleInit> </MiddleInit>
<Age></Age>
<Address>
<AddrLine1> </AddrLine1>
<AddrLine1> </AddrLine1>
<AddrLine1> </AddrLine1>
<Zip> </Zip>
<State> </State>
<Country></Country>
</Address>
</Customer>
In this example, the outbound specification (CustomerRecord) has a different structure and form than that required by the line-of-business application.
<CustomerRecord >
<Name> </Name>
<MiddleInit> </MiddleInit>
<Address> </Address>
<Zip> </Zip>
<State> </State>
<Country> </Country>
<DateTime> </DateTime>
</CustomerRecord>
To use the Transform shape within the Orchestration Designer, follow these steps:
Open the BizTalk project that contains the orchestration.
Ensure that two orchestration messages have been created. The msgCustomers message should reference the Customer schema, and the msgCustomerRecords message should reference the CustomerRecord schema.
Drag
a Transform shape from the BizTalk Orchestrations section of the
toolbox. Place the shape under the Receive shape on the design surface.
This automatically creates a Construct Message container and a Transform
shape.
Click the exclamation mark (tool tip) on the Transform message shape within the Construct Message boundary.
Click
the missing or invalid mapping configuration value in the drop-down
list. The Transform Configuration dialog box will appear.
In
the Enter Configuration Information Input section of the Transform
Configuration dialog box, select the Existing Map radio button. (The New
Map option allows you to configure the Construct shape by creating a
new map.)
For the Fully Qualified Map Name Input option, select the map desired for the transformation. In this example, the Transform_Sample.mapCustomer map was selected.
Under the Transform node, select Source. Then, click the Source_Transform input, and select the msgCustomers
orchestration message. This is the orchestration message assigned to
the orchestration and is the same schema as that of the inbound map: Transform_Sample.mapCustomer.
Under the Transform node, select Destination. Then, click the Destination_Transform input, and select the msgCustomerRecords
orchestration message. This is the orchestration message assigned to
the orchestration and is the same schema as that of the outbound map, Transform_Sample.mapCustomer. Figure 1 shows the completed configuration.
Click
OK to complete the configuration of the Transform shape. Notice that
the Construct Message shape is automatically configured with the Messages Constructed property of CustomerRecords.
This indicates that the message constructed in the message transform is
that of the destination schema specified in the transform map.
3. How It Works
The Transform shape allows
you to map messages from one format to another within the BizTalk
Orchestration Designer. This functionality assists in addressing common
enterprise integration challenges, where destination processes and
systems require a different format to that specified by the source
process or system.
The Transform shape
allows the assignment of an existing map or the creation of a new map
within the Transform Configuration dialog box. Also, you can transform
one or multiple source messages into one or multiple destination
formats. To enable this, create a new map within the Transform shape
configuration, by specifying multiple input messages and/or multiple
destination messages. This will automatically create a map with the
specified source and destination messages. This capability is useful
when you need to partition message calls for the destination process or
system. Figure 2 shows creating a destination with three schemas (two are identical in this example), and Figure 3 illustrates a BizTalk map with multiple messages.
NOTE
Native multiple message mapping can be done only inside an orchestration.
Message transformation may
be required to perform deterministic data enrichment, required by the
destination system. For example, this scenario is very common within the
enterprise resource planning (ERP) application paradigm, where target
integration processes (for example purchase orders, advance shipment
notices, and invoices) require additional information to persist and
update ERP process information based on the process and source context
of a message.
A further consideration of
using the Transform shape is that of implementing exception handling. By
using the Transform shape in conjunction with a Scope shape, you can
handle exceptions. Based on message transformation failure,
orchestration logic can be implemented to take a course of action to
handle the exception. This approach is different from that of
implementing mapping within send or receive ports. Here, exceptions must
be handled by the failure context of the port object.
Message
transformation and message mapping are fundamental requirements for any
enterprise integration platform, and BizTalk enables this capability via
its mapping and orchestration tool set.