BizTalk Training – Customize filename dynamically inside Orchestration

Posted: October 23, 2009 in BizTalk
Tags: , ,

This is a basic step, to accomplish this you have to define the message context property of the output message.

The message context is a container for various properties that are used by BizTalk Server when processing the document. Each property in the Message Context is composed of three things, a name, a namespace, and a value.

In orchestration:

  • Double click in Message Assignment shape (of the output message) and type:
msgOutput(FILE.ReceivedFileName) = “out_” + msgInput(FILE.ReceivedFileName);


In BizTalk Administration Console:

  • Set Send port:
    • Port type: Static One-Way
    • Transport: FILE
      • DestinationFolder: (To OUT folder)
      • FILENAME: %SourceFileName%
    • Send pipeline: XMLTransmit

Test application:

  • Create two folders (IN and OUT), configure the receive location to get from IN folder, and the send port send to OUT folder

Download the example source code:

Customize filename dynamically inside BizTalk Orchestration (108.7 KB)
Microsoft | MSDN Code Gallery

Comments
  1. Sandro says:

    Hi,There are others Message Context Properties associated with other adapters, this is one example: msg(WSS.Filename) = "file.txt";

  2. Dhiraj says:

    Hi,

    what if when my request message is coming from webservice using SOAP adapter?

    • Hi Dhiraj,

      When you receive a message through webservice using SOAP adapter, WCF adapter or even for example HTTP adapter… your don’t have the property FILE.ReceivedFileName defined in the receive message, so you need to define the output file name: static, perhaps based on some content of the message or programatic.

      msgOutput(FILE.ReceivedFileName) = “out_file.xml”;
      msgOutput(FILE.ReceivedFileName) = “out_” + msgInput.MyAttribute + “.xml”;
      msgOutput(FILE.ReceivedFileName) = “out_” + System.DateTime.Now + “.xml”;

      Another option is: you can create a custom component for the receive pipeline that promotes the FILE.ReceivedFileName in the received message, again based on some content of the message, static or programatic.

  3. Harsha says:

    Hi Sandro,

    Thanks for the article! I have a question:
    Background: I’m using a dynamic FTP send port (because I need to alter the directory and some other parameters each transaction, programmatically). I’m using a MessageAssignment shape to specify the FTP parameters.
    But in addition to this, I also need to output a very specific file name. I have already tried this method of using – OutputMsg(FILE.ReceivedFileName) = “SampleOutputFileName.txt”;
    It does not work because there is no way for me to specify the macro %SourceFileName% anywhere.
    Question: Do you know how I would be able to manipulate the output file name in a dynamic FTP send port?

    Thanks in advance!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s