Copying XML input into a Message header and passing through the XML input to the output

Userlevel 5
Badge +1



I need to pass some XML through an XMLMap connector, but I also want to preserve the original XML input, for later use.

My thought was to do this in a script before it hits the XMLMap


But I don’t know how to 

  1. copy the Script connector input, straight out to the output
  2. copy the Script connector input into a message header



Best answer by James B 4 June 2024, 20:40

View original

2 replies

Userlevel 5
Badge +1

I think I’ve worked it out:


<arc:set attr="output.header:raworiginalorder" value="[_message.body]" />
<arc:set attr="" value="[_message.body]" />

<arc:set attr="output.filename" value="[FileName]" />
<arc:push item="output" />


Userlevel 6

I see what you mean now. You could also do this directly in the XML Map with a Script step inside the XML Map:



The code here is:

<arc:set attr="_message.header:originalXML" value="[_message.body | regexreplace('>\s+<','><')]" />

Note that this regexreplace is meant to minify the XML if it’s not already minified (headers can’t be multiline values - you can also base64encode the content if you want to preserve whitespace), and that the body of the message isn’t fully loaded until after the first Foreach loop