Dynamically Reading Receive Location Context Properties
A situation present itself occur where an orchestration uses a receive port that is sourced by multiple receive locations to receive a message and a specific context property must be read from the incoming message. Because the message is coming from different receive locations, an evaluation of the to location may be necessary to determine the proper context property. For example, the following receive port is set up to accept an incoming message from four different receive locations:
In this example, the file is not only coming in from four receive locations, but each location is a different type (a windows folder, a SharePoint document folder, an FTP site or email). To get a file property such as the file name, an orchestration will need to read the context property ReceivedFileName associated with the specific receive location. When multiple locations are used as with the example above, some conditional logic is necessary to read the property from the correct received location. For the “FILE” receive location, the context property is “FILE.ReceivedFileName, for an FTP site, it’s “FTP.ReceivedFileName” and for Windows SharePoint Services, “WSS.FileName”. In this situation, the inbound transport type of the incoming message can be evaluated in an standalone Expression shape to determine the correct ReceivedFileName context property to read.
if (msgClientData(BTS.InboundTransportType) == “FILE”)
fileName = msgClientData(FILE.ReceivedFileName);
else if (msgClientData(BTS.InboundTransportType) == “FTP”)
fileName = msgClientData(FTP.ReceivedFileName);
else if (msgClientData(BTS.InboundTransportType) == “Windows SharePoint Services”)
fileName = msgClientData(WSS.Filename);
fileName = msgClientData(BTS.MessageID);
In this code fragment, the specific context property associated with the receive location is read for “FTP”, “FILE” and “WSS” receive location types. If the file is received from any other location, the filename variable is defaulted to the Message ID. Again, this code can only be used in a standalone Expression shape since Boolean (if-else) logic is not allowed inside a Construct Message shape.
In addition, not all receive locations contain the same property sets. For example the “FILE” receive location, contains a context property to determine the date/time of when the file was received whereas the “FTP” location does not have that property. The logic above can be expanded to accommodate these variations amongst to context properties between receive locations as well.