Now when I deploy and test the HelloWorld application, I get the following error

xlang/s engine event log entry: Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘Microsoft.Samples.BizTalk.HelloWorld.HelloSchedule(e0eddb10-5fb9-a44c-aa06-423456a70585)’.The service instance will remain suspended until administratively resumed or terminated. If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.InstanceId: fbaf254b-ac0f-4b8d-b1ed-94a58d7f8cd9Shape name: ConstructInvoiceShapeId: 619c4eb0-2371-4cb6-a60c-eae729be8693Exception thrown from: segment 1, progress 6Inner exception: There is no value associated with the property ‘BTS.MessageID’ in the message.

REASON

There are 2 ways message gets created in the message box

1. Message is published by receive port or orchestration.
–In this case message ID will be created as soon as the message gets into the MessageBox database.

2. Message is created in orchestration using construct shape.
–In this case the message will be created first in-memory representation on orchestration and it will be created into the MessageBox database only once the persistence point comes in the orchestration.

So in the above orchestration we are trying to use the Message ID of the newly created message(InvoiceMessage) in the construct shape which is not been yet created. The Message ID is created ONLY on persistence (normally the send shape adds the persistence point) or during any activity that cause the Message to be published to the MessageBox.

SOLUTION

1. If you are using Message ID as a unique identifier may be for co-relation or something like that then its advisable to use Orchestration Instance ID, Microsoft.XLANGs.Core.Service.RootService.InstanceId

For the scenario mentioned above I changed the code to following and it worked.