| BizTalk Training 3 - customize filename dynamically |
Overview
This tutorial shows how to customize output filename inside orchestration.
There are 9 tutorials in this training.
- BizTalk Training 1 - basic send/receive xml message
- BizTalk Training 2 - receive/send plain text
- BizTalk Training 3 - customize filename dynamically
- BizTalk Training 4 – using Functiods in Map
- BizTalk Training 5 - using FTP Adapter
- Working on…
Objectives
- Learn how to change filename of the output file.
Prerequisites
- BizTalkTraining 2 project.
- Configuration on BizTalk Administration for BizTalkTraining application.
Topics
- Add variable in the orchestration.
- Add msgPerson2.
- Add Message Assignment to the orchestration.
- Test application.
Step-by-step
Suppose that I want to change name of outgoing file. As in training 2, the input filename is *.txt format but I want the outgoing message type as xml format and also add “output_�? text before. E.g. incoming filename is “person1.txt�?, outgoing filename will be “output_person1.xml�?.
- Add variable in the orchestration.
- Open Orchestration1 in BizTalkTraining. (Project from BizTalk Training 2).

- Switch to Orchestration View, right click on Variables and select New Variable.

- Click on the variable.
- On Variable Property, change Identifier to “fileName�?.
- Change Type to “string�?.

- Now you’ve add variable name “fileName�? as string to the Orchestration1.
- Open Orchestration1 in BizTalkTraining. (Project from BizTalk Training 2).
- Add msgPerson2.
- Create new Message on the orchestration name “msgPerson2�? and set Message Type as the same as msgPerson (BizTalkTraining.FlatFilePersonSchema).

- Create new Message on the orchestration name “msgPerson2�? and set Message Type as the same as msgPerson (BizTalkTraining.FlatFilePersonSchema).
- Add Message Assignment to the orchestration.
- Drag Message Assignment from Toolbox to bottom of the Orchestration1.

- Click on ConstructMessage_1 object. Notice that you highlights entire Construct Message object.
- On Construct Message Properties, check msgPerson2 in Message Constructed and change Name to “Construct msgPerson2�?.

- Click on Message Assignment (the object inside Construct Message) and change Name to “Assign fileName�? in Message Assignment Properties.

- Double click on Message Assignment and fill in the code below and click OK.
msgPerson2 = msgPerson;
fileName = msgPerson2(FILE.ReceivedFileName);
fileName = fileName.Replace(”.txt”,”.xml”);msgPerson2(FILE.ReceivedFileName) = “output_” + fileName;
The code above assigns msgPerson to msgPerson2 and assigns incoming filename to “filename�? variable, modify string and assign back to “msgPerson2�?.

- Add new send component to the bottom of the orchestration and change Message to “msgPerson�?.

- Create new send logical port.
- Right click on Port Surface area, select New Configured Port.

- Set name to “SendXMLPersonPort�?.
- Set Port Type as following configurations.
Port Type: Create a new Port Type
Port Type Name: SendXMLPersonPortPortType
Communication Pattern: One-Way
Access Restrictions: Internal

- Set Port Binding as below.
Port direction: I’ll always be sending messages on this port.
Port binding: Specify Now.
Transport: FILE
URI: C:\FILE2\OUT\%SourceFileName%
Send pipeline: XMLTransmit

- Right click on Port Surface area, select New Configured Port.
- Connect green button from Send component to SendXMLPersonPort.

- Deploy the project.

- Drag Message Assignment from Toolbox to bottom of the Orchestration1.
- Test the application.
Resources
You can download the example source code (zip file) at here.
The zip file contains
- BizTalkTraining folder which is the example project on Visual Studio 2005.
- FILE2 folder which contains IN and OUT empty sub folders for test receive and send message and person1.txt which is an example text message.
- binding.xml file which is a configuration file for import in BizTalk Administration.





























September 25th, 2008 at 2:13 am
So where’s the output_person1.txt file? I just see the person1.txt and person1.xml files.
September 26th, 2008 at 9:00 am
It was my mistake. The output should be output_person1.xml not person1.xml. I’ll correct it soon.