0

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?

Bensonius
  • 1,501
  • 1
  • 15
  • 39

2 Answers2

2

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

Johns-305
  • 10,908
  • 12
  • 21
  • Good to know the expected behaviour. Do you have any recommendations for the scenario I'm describing? Do people usually just mass-copy the whole message over, or use xpath()? If maps are used, is there anything special that must be done (I'm thinking about recurring fields as Dijkgraaf mentions). I've only ever done very simple maps, but would like to use them for this project in case we get rid of the orchestration. – Bensonius Aug 07 '14 at 15:28
  • In this scenario, I Link by Structure/Name on the main document, then relink the field to modify to the 'changes' message. – Johns-305 Aug 07 '14 at 17:41
1

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.

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
  • I think we're not quite on the same page. The part I want to avoid is having the map do all the work copying the message and just have a map to change a couple fields in a copy of a message. I think your suggestion would work if I left out step 2 and instead did a message assignment to make a copy of SchemaB and just assign the fields from source to destination. – Bensonius Aug 07 '14 at 15:32
  • Yes, you can just copy the whole message and assign a few fields and eliminate the map entirely. – Dijkgraaf Aug 07 '14 at 21:12