In BizTalk, you can export and import and export bindings to/from the BizTalk Database using the BizTalk Administration Console and/or BTSTask.exe (command line utility).

The binding file has five major sections:

1) ModuleRefCollection (Orchestrations a.k.a. “Services” and Orchestration bindings)
2) SendPortCollection (Send Ports)
3) DistributionListCollection (Send Port Groups)
4) ReceivePortCollection (Receive Port and their related Receive Locations)
5) PartCollection (Trading Partner Management [TPM] Parties)

Structure of Binding File – Top-Most Elements (Sections)

<?xml version="1.0" encoding="utf-8"?>
<BindingInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Assembly="Microsoft.BizTalk.Deployment, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Version="3.5.1.0" BindingStatus="FullyBound" BoundEndpoints="18" TotalEndpoints="18">

  <Timestamp>2020-03-30T10:19:30.8927543-05:00</Timestamp>
  
  <ModuleRefCollection>
     <TrackedSchemas...
     <Service...
  </ModuleRefCollection>
  
  <SendPortCollection>
  </SendPortCollection>
  
  <DistributionListCollection />
  
  <ReceivePortCollection>
  </ReceivePortCollection>
  
  <PartyCollection xsi:nil="true" />

</BindingInfo>

Creating the Binding File

The normal process is to go to an application in BizTalk Admin Console, right click, and select “Export”, then “Bindings…”. You will be prompted for a file name (the directory defaults to: C:\Users\YourUser\AppData\Local\BizTalk\Binding Files\, but you can change it). By default, the filename is the name of your application followed by “_Bindinginfo.xml”.

So for example, for the Application called “Lesson1”, then binding file by default would be:
C:\Users\YourUser\AppData\Local\BizTalk\Binding Files\Lesson1.BindingInfo.xml

Editing the binding file

You can open the binding file in NotePad++ or your favorite editor. It’s just XML, don’t be afraid of it.
For example, when you deploy from test to production environments, you often need to change directory names, SQL Server/Database Names, and/or WebSite URLs.

Duplicating a SendPort

To duplicate a Send Port, you can export the bindings for the app, remove everything except the root element, the and the one you want to duplicate. Change the name of the SendPort, and save the file. You can use an XML plugin to NotePad++ to make sure the file is still standard XML. Usually the URI (disk path or URL) will be changed as well. Then import back into the same application, and voila – your Send Port is copied or duplicated.

You can do similarly for Receive Ports, but note two things:
1) A Receive Port can have multiple ReceiveLocations, and Receive Locations always exist “under” the Receive Port.
2) The Receive Locations URI must be unique (change it before you import it).

Example of a Send Port Binding

    <SendPort Name="sp_Lesson1_Outbound" IsStatic="true" IsTwoWay="false" BindingOption="0" AnalyticsEnabled="false">
      <Description xsi:nil="true" />
      <TransmitPipeline Name="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit" FullyQualifiedName="Microsoft.BizTalk.DefaultPipelines.PassThruTransmit, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Type="2" TrackingOption="None" Description="" />
      <PrimaryTransport>
        <Address>c:\BizTalk\Lesson1\Outbound\%MessageID%_%SourceFileName%</Address>
        <TransportType Name="FILE" Capabilities="11" ConfigurationClsid="5e49e3a6-b4fc-4077-b44c-22f34a242fdb" />
        <TransportTypeData>&lt;CustomProps&gt;&lt;UseTempFileOnWrite vt="11"&gt;0&lt;/UseTempFileOnWrite&gt;&lt;AllowCacheOnWrite vt="11"&gt;0&lt;/AllowCacheOnWrite&gt;&lt;CopyMode vt="19"&gt;1&lt;/CopyMode&gt;&lt;FileName vt="8"&gt;%MessageID%_%SourceFileName%&lt;/FileName&gt;&lt;/CustomProps&gt;</TransportTypeData>
        <RetryCount>3</RetryCount>
        <RetryInterval>1</RetryInterval>
        <ServiceWindowEnabled>false</ServiceWindowEnabled>
        <FromTime>2020-02-09T08:00:00</FromTime>
        <ToTime>2020-02-10T07:59:59</ToTime>
        <Primary>true</Primary>
        <OrderedDelivery>false</OrderedDelivery>
        <DeliveryNotification>1</DeliveryNotification>
        <SendHandler Name="BizTalkServerApplication" HostTrusted="false">
          <TransportType Name="FILE" Capabilities="11" ConfigurationClsid="5e49e3a6-b4fc-4077-b44c-22f34a242fdb" />
        </SendHandler>
      </PrimaryTransport>
      <SecondaryTransport>
        <Address />
        <RetryCount>3</RetryCount>
        <RetryInterval>5</RetryInterval>
        <ServiceWindowEnabled>false</ServiceWindowEnabled>
        <FromTime>2020-02-09T08:00:00</FromTime>
        <ToTime>2020-02-10T07:59:59</ToTime>
        <Primary>false</Primary>
        <OrderedDelivery>false</OrderedDelivery>
        <DeliveryNotification>1</DeliveryNotification>
        <SendHandler xsi:nil="true" />
      </SecondaryTransport>
      <ReceivePipelineData xsi:nil="true" />
      <Tracking>204</Tracking>
      <Filter>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;Group&gt;
    &lt;Statement Property="BTS.ReceivePortName" Operator="0" Value="rp_Lesson1_Inbound" /&gt;
  &lt;/Group&gt;
&lt;/Filter&gt;</Filter>
      <Transforms />
      <OrderedDelivery>false</OrderedDelivery>
      <Priority>5</Priority>
      <StopSendingOnFailure>false</StopSendingOnFailure>
      <RouteFailedMessage>false</RouteFailedMessage>
      <ApplicationName>Lesson1</ApplicationName>
    </SendPort>

The trickiest part of the above is this:

        <TransportTypeData>&lt;CustomProps&gt;&lt;UseTempFileOnWrite vt="11"&gt;0&lt;/UseTempFileOnWrite&gt;&lt;AllowCacheOnWrite vt="11"&gt;0&lt;/AllowCacheOnWrite&gt;&lt;CopyMode vt="19"&gt;1&lt;/CopyMode&gt;&lt;FileName vt="8"&gt;%MessageID%_%SourceFileName%&lt;/FileName&gt;&lt;/CustomProps&gt;</TransportTypeData>

This is sometimes called encoding. The value of is actually more XML, but it is different depending on what adapter you use in your Send Port. So BizTalk encodes that XML with something like URLEncoding.

To make it more readable, you can do two change all commands in NotePad++:
1) Change > to >
2) Change < to < However I do not recommend going the other direction, there may be some conflicts. After that, and formatting it, it looks like this:

<TransportTypeData>
	<CustomProps>
		<UseTempFileOnWrite vt="11">0</UseTempFileOnWrite>
		<AllowCacheOnWrite vt="11">0</AllowCacheOnWrite>
		<CopyMode vt="19">1</CopyMode>
		<FileName vt="8">%MessageID%_%SourceFileName%</FileName>
	</CustomProps>
</TransportTypeData>

Send Ports for WCF and SQL are much more complicated then the simple one below, as they can have a dozen or more parameters.

The “Filter” section is also encoded:

      <Filter>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;Group&gt;
    &lt;Statement Property="BTS.ReceivePortName" Operator="0" Value="rp_Lesson1_Inbound" /&gt;
  &lt;/Group&gt;
&lt;/Filter&gt;</Filter>

Unencoded, it looks like this:

      <Filter><?xml version="1.0" encoding="utf-16"?>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Group>
    <Statement Property="BTS.ReceivePortName" Operator="0" Value="rp_Lesson1_Inbound" />
  </Group>
</Filter></Filter>

This shows you that the Send Port has a subscription (filter) on BTS.ReceivePortName = "rp_Lesson1_Inbound". The "equal" sign is encoded into the Operator=0 statement. I don't have an quick listing of the possible values of the Operator attribute.

Filed under: Binding