In many cases it can be useful to know the exact name of your output file that will be sent from your Orchestration using the File Adapter. This can be difficult if you are using the %MessageId%.xml macro to write the file since this it set after the message is sent from the Orchestration.
Delivery Notification can help you determine if your message was sent successfully but it can not give you the file name.
BizTalk 2004 has two ways to dynamically name your files from inside the Orchestration. The two ways to accomplish this are either to use a Dynamic Send Port or to use the %SourceFileName% macro on the Send Port.
Dynamic Send Port
Dynamitic Send Ports are powerful and useful if you need to send your files to many different locations on the file system like sometime to C:\data\ and other times c:\root\. The downside is you need to have all this information inside your message or hard code it in the Orchestration. So, it can be difficult to change.
Source File Name Macro
This is my preferred approach to Output File Naming. This does not require your data or the Orchestration to have any idea as to the directory you want to write your file to. This requires using the %SourceFileName% macro to set the output file name inside the Send Port.
Don’t want the same name as your input file you say? Now, here is the trick. Just change the File.ReceivedFileName property inside the Orchestration to be anything you want! This can be done by creating a new message and changing the context property. The code inside a Message Assignment shape would look like this:
// Create a new message
OutMessage = InMessage;
// Set the ReceivedFileName context property
OutMessage(FILE.ReceivedFileName) = “SetInOrch.xml”;
It is not required to demote this value into your message. So, this method works with the Pass Through Send Pipeline because this context value is used by the File Adapter and not the pipeline.
CRITICAL: The %SourceFileName% macro does not need an additional extension (like .xml or .txt) after it like the %MessageId% macro.
I have put together a simple sample showing both of these types of file naming. For information on how to run the samples, please see the Read Me file.
DOWLOAD: Sample Naming Output Files
Recent Comments