Overview

This tutorial shows how to customize output filename inside orchestration.

There are 9 tutorials in this training.

  1. BizTalk Training 1 - basic send/receive xml message
  2. BizTalk Training 2 - receive/send plain text
  3. BizTalk Training 3 - customize filename dynamically
  4. BizTalk Training 4 – using Functiods in Map
  5. BizTalk Training 5 - using FTP Adapter
  6. Working on…

Objectives

  • Learn how to change filename of the output file.

Prerequisites

  • BizTalkTraining 2 project.
  • Configuration on BizTalk Administration for BizTalkTraining application.

Topics

  1. Add variable in the orchestration.
  2. Add msgPerson2.
  3. Add Message Assignment to the orchestration.
  4. 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�?.

  1. Add variable in the orchestration.
    • Open Orchestration1 in BizTalkTraining. (Project from BizTalk Training 2).
      BizTalkTraining2 project
    • Switch to Orchestration View, right click on Variables and select New Variable.
      Add new variable
    • Click on the variable.
      1. On Variable Property, change Identifier to “fileName�?.
      2. Change Type to “string�?.
        Change variable's type
    • Now you’ve add variable name “fileName�? as string to the Orchestration1.
  2. Add msgPerson2.
    • Create new Message on the orchestration name “msgPerson2�? and set Message Type as the same as msgPerson (BizTalkTraining.FlatFilePersonSchema).
      Change Message Type
  3. Add Message Assignment to the orchestration.
    • Drag Message Assignment from Toolbox to bottom of the Orchestration1.
      Create Message Assignment
    • 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�?.
      Set Message Assignment's properties
    • Click on Message Assignment (the object inside Construct Message) and change Name to “Assign fileName�? in Message Assignment Properties.
      Change Message Assignment's name
    • 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�?.
      Write custom code on Message Assignment

    • Add new send component to the bottom of the orchestration and change Message to “msgPerson�?.
      Add new Send component from Toolbox
    • Create new send logical port.
      1. Right click on Port Surface area, select New Configured Port.
        Create New Port
      2. Set name to “SendXMLPersonPort�?.
      3. Set Port Type as following configurations.
        Port Type: Create a new Port Type
        Port Type Name: SendXMLPersonPortPortType
        Communication Pattern: One-Way
        Access Restrictions: Internal
        Configure Port Type
      4. 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
        Configure Port Binding
    • Connect green button from Send component to SendXMLPersonPort.
      Connect line between ports
    • Deploy the project.
      Deploy the project
  4. Test the application.
    • Open BizTalk Administration and restart BizTalk host.
      Restart the host server
    • Refresh BizTalkTraining application.
      Refresh the application
    • Test application by copy person1.txt from C:\FILE2\person2.txt to C:\FILE2\IN.
      Note: You must any delete files in C:\FILE2\OUT before.
    • You’ll see output in C:\FILE2\OUT.
      Result files
    • Person1.txt
      Person1.txt
    • Person1.xml
      Person1.xml

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.
Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • description
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • Fark
  • Fleck
  • Furl
  • Reddit
  • Slashdot
  • SphereIt
  • StumbleUpon
  • Technorati
  • Blue Dot
  • description
  • MyShare
  • Spurl
  • YahooMyWeb

Related post