Bensonius
Bensonius

Reputation: 1541

Biztalk Preload output message before Map transform

I have 2 correlated incoming messages from 2 different systems (SystemA and SystemB) and I just want to basically copy over a couple fields from the SystemA message to the SystemBmessage.

So my Construct Message shape looks like this:

enter image description here

The Message Assignment shape just has this code inside it:

xmlIncomingNoAttachHolder = new System.Xml.XmlDocument();
xmlIncomingNoAttachHolder = msgMultiPartInNoAttachment.BodySegments;

// assigning the SsytemB version (no attachment) first.
// Also, since we are only copying a couple fields, this can serve as the base.
msgComboWithAttach = xmlIncomingNoAttachHolder;
msgComboWithAttach(XMLNORM.TargetCharset) = "UTF-8";

The map then just has the 2 input (SystemA schema and SystemB schema) ORU messages on left and the output ORU message on the right, which also shares the same schema as the SystemB input message.

My hope was that I could just use the message assignment code above to assign the Output msgComboWithAttach message, then use the mapper to map over the few fields that we need from the SystemA message to the SystemB message.

But it seems that as soon as I apply the map, it clears the pre-loaded msgComboWithAttach message before performing the transform and then applies the map. The resulting message then contains ONLY those fields that are copied over in the map and none of the other segments/fields that were assigned in the message assignment pre-load.

Is this expected behaviour, in which case, I would have to do a Mass-Copy on all the segments in the Map? Or is there a way to pre-load/copy the message like I want and then only Map a couple fields over?

Upvotes: 0

Views: 393

Answers (2)

DTRT
DTRT

Reputation: 11040

Yes, that is the expected behavior since the transform will create a new message. You cannot use Xslt to modify a document in that way.

Dijkgraaf's solution will work. As an alternative, you can use the Orchestration xpath() function to read and set specific values in Message. See: http://msdn.microsoft.com/en-us/library/ee268159(v=bts.10).aspx

Upvotes: 2

Dijkgraaf
Dijkgraaf

Reputation: 11527

Yes, that is expected behaviour.

What you want to do is

  1. Distinguish the fields in the schema(s) (target and source, in your case they may be the same one if I understand what you are saying).
  2. Have the map first making sure that your map creates the fields you want to populate with some dummy values.
  3. Have an assignment shape after that just has one line for each of the fields in the format msgDestination.record.field = msgSource.record.field; (Note: you might have multiple levels of records).

This works only for non-reoccurring fields. For reoccurring fields you need to use a multi-part map instead.

Upvotes: 1

Related Questions