“use of unconstructed message ‘<MessageName>'” error
A quick search of the web suggests that this is a common error and a source of confusion and frustration!
You try to build your orchestration and the build fails with the highlighted error below, for example:
In my case, I’m trying to assign a value to a message but the compiler won’t let me: instead, a copy of the original message needs to be made and then the value can be assigned to the copy.
This is a core feature of BizTalk and demonstrates a tenet of the framework: received messages are immutable (can’t be changed). What this means is that a full message audit trail is maintained which is critical when your application is “in the field” and a BizTalk admin needs to trace message processing through BizTalk using perhaps the BizTalk Admin Console.
So, for example, in the case of the orchestration below, I have an assign message shape (indicated with a red square) where I am incorrectly attempting to assign a value to the original message rather than a copy of it:
In order to fix this, I need to make a couple of changes to the assign message shape:
- Modify the “Messages Constructed” property from the original message to a different message of the same type
- Change the message assignment: instead of assigning a value directly to the original message, I instead “clone” the original message and assign to this copy of the original message
Finally, I change the last Send shape to ensure that the message copy is sent rather than the original message.
(Incidentally, a big clue that a new message needs to be created as part of the assignment is that the message assignment shape comes with a construct message shape).
In conclusion, this post demonstrates a core feature of BizTalk: message immutability. This is a foundational principle of BizTalk as a framework and as demonstrated, is enforced by the compiler.