Creating a dynamic Send Port

The send ports in BizTalk allow the user to specify how the outgoing message will be delivered. One can configure the transport (e.g. FTP or HTTP) the destination address (may be a file folder) and the other parameters that are specific to the selected transport (e.g. in case of FTP transport, the user name and password can be specified). Such type of configuration is done at design time or at the deployment time and often is sufficient. But there are instances where the type of transport to be used is governed by the nature of the message e.g. if my message is of type so-and-so OR if the value of a field in the message is xyz, then use FTP and send it to a FTP location otherwise use an HTTP and send it to another location. This is where Dynamic Send ports can be used to decide the port configuration at the time of message delivery.

Consider the following input XML message:

<ns0:Input xmlns:ns0="https://MyProject.MyMessages.Input">

    <Header>

        <FTPServer>MyServer.com</FTPServer>

        <UserName>Foo</UserName>

        <Password>Boo</Password>

        <RetryAttempts>5</RetryAttempts>

        <RetryInterval>10</RetryInterval>

<FileName>OutputMessage.xml</FileName>

     </Header>

    <Body>

        <Content>This is the actual content</Content>    

     </Body>

</ns0:Input>

Let us assume that this message would be transformed into output message like this using a map:

<ns0:Output xmlns:ns0="https://MyProject.MyMessages.Input">

    <Body>

        <Content>This is the actual content</Content>    

     </Body>

</ns0:Output>

In order to send this output message through a dynamic send port, following needs to be done:

  1. Verify that the input message has all of its properties that are required to configure the dynamic send port are promoted.
  2. Configure a receive location to accept this message. Specify the default XmlReceivePipeline since we are not going to act upon the message and modify its contents before it comes to messagebox.
  3. Create an orchestration and specify the Receive shape and set its properties such that it receives the message of type Input.
  4. Add a send port to the orchestration with the port binding as dynamic. Name the send port oprtSendDynamic.
  5. Next, add a Transform shape and specify the map for this shape that would transform the Input to Output.
  6. In the Construct Message shape surrounding t he Transform shape, add a Message Assignment shape below Transform. In the Message Assignment shape, we will configure the properties of the dynamic send port.

msgOutput.Body.Content = msInput.Body.Content

//Set the FTP properties from the input message content

oprtSendDynamic(Microsoft.XLNAGs.BaseTypes.Address) =

"ftp://" + msgInput.Header.FTPServer + "/" + msgInput.Header.FileName;

//Set other FTP properties by tapping the input message as above.

.....

7. Complete the orchestration, bind the ports and test.