|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis article walks through the motions of creating a custom name using the %SoursFileName% macro for send handlers within BizTalk 2004. ScenarioWhen working on a particular project I had to adhere to a naming convention for one of our customers for one of the data files we were sending. The convention was: AAA_AA_NNNNNNNNN.xml (A=alpha/N=numeric) The number part always needed to be 9 numbers and in sequence. So for ease a database table is used to record each time a sequence number is created.
C# AssemblyI then created a C# class which connects to the database to return the sequence number value. (See downloadable source code). I created three methods. 1 – ‘GetSequenceNumber’: This method (as the name suggests) uses the database methods to retrieve a new sequence number. 2 – ‘PadSequenceNumber’: This method returns the number of 0s to be placed in front of the sequence number returned from the database. 3 – ‘GetFileName’: This method is the one called in the BizTalk Orchestration to start the get the file name. public static string GetFileName(string id) {
string num = GetSequenceNumber(id);
int i = num.Length; string name = PadSequenceNumber(i);
string res = name + num; return res;
}
BizTalk 2004 ProjectFor the purpose of this article I have created a simple BizTalk project which takes an address from an xml file and outputs as an xml file. Within this project there is the address schema, the mapping between the schemas for the xml output and an orchestration for specifying the file name. Orchestration
The flow of the orchestration is as follows:
Within the Message Assignment shape (after the Transform Shape) is the code that sets the file name. //get file name
filename = BizTalk.CustomOutputFile.CSharp.Filename.GetFileName("Address");
//sets the received file name to what is specifed below
Address_Output(FILE.ReceivedFileName) = "VIS_HA_" + filename + ".xml";
As you can see the message receive name is changed. This is done using the %SourceFileName% macro available for send handlers within BizTalk 2004. See below for other macros available:
Port ConfigurationI created a receive and sent port, specifying locations where I wanted the files to be dropped. On the send port I set the File name property to %SourceFileName%
Finally…Once I had done this, I deployed the project. Started the orchestration and dropped a test file in the location and watch it create a file name with using a sequence number. End Note
i.e. %MessageID%+ %time%.xml
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||