Wednesday, January 02, 2008

Orchestration Expressions: exists and succeeded operators

exists Operator

This operator inside an Orchestration allow us to determine if a message context property exists in a message.

Syntax:
<Message Property Name Message Part Property Name> exists <Message Variable Name Message Part Name>

Example:
BTS.AckType exists msgIn

This is util to avoid 'There is no value associated with the
property <property> in the message.' error message when we get the value of a property, for example:

if (BTS.AckType exists msgIn)
{
myAckType = msgIn(BTS.AckType);
}


succeeded Operator

This operator is very usefull when we want to use a message (that is constructed inside a transaction) in a handling exception block inside an Orchestration.

For example, if we construct msgOut inside transaction Transaction_1 and in the handling exception block, we write in a expression shape:

System.Diagnostics.Debug.WriteLine ("Received Port was: " + msgOut(BTS.ReceivePortName));

We will receive this error: use of unconstructed message 'msgOut'

But if we write this code, we get the desired behaviour and no compilation error:

if (succeeded(Transaction_1))
{
System.Diagnostics.Debug.WriteLine ("Received Port was: " + msgOut(BTS.ReceivePortName));
}