This project has moved and is read-only. For the latest updates, please go here.

ENV settings / encoding problems

Topics: Bindings File, Settings Management and SSO
Apr 3, 2012 at 12:32 PM
Edited Apr 3, 2012 at 1:58 PM

Hi,

I've spent a long time creating a master bindings file with the markup as described in the documentation:

<TransportTypeData>
 <CustomProps>
  <AdapterConfig vt="8">
   <Send>
   <!-- ifdef ${ _xml_preprocess} -->
   <!-- <connectionString>${SQL_ConfigCS}</connectionString> -->
   <!-- else -->
   <connectionString>Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Config;Data Source=.</connectionString>
    <!-- endif -->
    <outputRootElementName>Response</outputRootElementName>
     <documentTargetNamespace>http://Orchestrations.CustomerInvoices.InsertTracking</documentTargetNamespace>
    <!-- ifdef ${ _xml_preprocess} -->
    <!-- <uri>${SQL_Config}</uri> -->
    <!-- else -->
    <uri>SQL://./Config/</uri>
    <!-- endif -->
   </Send>
 </AdapterConfig>
</CustomProps>

 If I use the following settings:

<UsingMasterBindings>True</UsingMasterBindings>
<RequireXmlPreprocessDirectives>False</RequireXmlPreprocessDirectives>
<ApplyXmlEscape>True</ApplyXmlEscape>

Then the default values are used and not the ENV settings.

If I use the following settings:

<UsingMasterBindings>True</UsingMasterBindings>
<RequireXmlPreprocessDirectives>True</RequireXmlPreprocessDirectives>
<ApplyXmlEscape>True</ApplyXmlEscape>

Then the PortBinding.xml is encoded wrongly (note the &amp;lt; and &amp;gt;):

<TransportTypeData>&lt;CustomProps&gt;&lt;AdapterConfig vt="8"&gt;&amp;lt;Send&amp;gt;&amp;lt;connectionString&amp;gt;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Config;Data Source=SS2K8R2&amp;lt;/connectionString&amp;gt;&amp;lt;outputRootElementName&amp;gt;Response&amp;lt;/outputRootElementName&amp;gt;&amp;lt;documentTargetNamespace&amp;gt;http://Orchestrations.CustomerInvoices.InsertTracking&amp;lt;/documentTargetNamespace&amp;gt;&amp;lt;uri&amp;gt;SQL://SS2K8R2/Config/&amp;lt;/uri&amp;gt;&amp;lt;/Send&amp;gt;&lt;/AdapterConfig&gt;&lt;/CustomProps&gt;</TransportTypeData>

I really don't want to change the markup because it will be a lot of work. Is there a reason why this is happening?

Thanks

Iain

Apr 3, 2012 at 5:24 PM

OK,

after a day of screaming and smacking my head against a brick I don't think it's an encoding issue. The question remains why do the bindings import when I set:

<RequireXmlPreprocessDirectives>False</RequireXmlPreprocessDirectives>

but when I set:

<RequireXmlPreprocessDirectives>True</RequireXmlPreprocessDirectives>

I get the error malformed XML.

Any ideas?

Apr 3, 2012 at 6:35 PM

RequireXmlPreprocessDirectives completely changes how you set up the replacement tokens in the file.  With it True, you must use the ifdef/endif, etc. as you have in your very first example.  With it False, you do not need any ifdef/endif at all; you simply switch out the value you want to replace with the replacement token ${aValueNameFromSettingsSpreadsheet}.

With it False, your very first example becomes:

<TransportTypeData>
 <CustomProps>
  <AdapterConfig vt="8">
   <Send>
     <connectionString>${SQL_ConfigCS}</connectionString>
     <outputRootElementName>Response</outputRootElementName>
     <documentTargetNamespace>http://Orchestrations.CustomerInvoices.InsertTracking</documentTargetNamespace>
     <uri>${SQL_Config}</uri>
   </Send>
 </AdapterConfig>
</CustomProps>

A note on your original example: the else side of the preprocessor directives is only useful if you directly try to import the PortBindingsMaster.xml, which there's little reason to ever do.  I never bother including the 'else' condition.

Thanks,
Tom

Apr 4, 2012 at 1:10 PM

Tom,

OK well that explains how I should markup the bindings file in future. However, it doesn't solve my issue. Following the logic, the problem must be somewhere in the commented out section of the bindings file. It's going to be very painful to find. Are you aware of any way to identify binding file issues?

Regards

Iain

Apr 4, 2012 at 4:21 PM

It's a delicate balance with the binding files.  The best way to validate the generated file is to have a known-good bindings file exported from BizTalk Admin that you can use a diff tool like WinMerge to compare side to side.  Some elements are double-encoded, and I believe that this is one of them.  ElementTunnel.exe encodes the XML in the following order:

/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/ReceiveLocationTransportTypeData/CustomProps/AdapterConfig
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/ReceiveLocationTransportTypeData/CustomProps/BindingConfiguration
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/ReceiveLocationTransportTypeData
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/ReceivePipelineData
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/SendPipelineData
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData/CustomProps/StaticAction
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData/CustomProps/AdapterConfig
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData/CustomProps/BindingConfiguration
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData
/BindingInfo/SendPortCollection/SendPort/ReceivePipelineData
/BindingInfo/SendPortCollection/SendPort/SendPipelineData
/BindingInfo/PartyCollection/Party/CustomData

One validation step is to set ApplyXmlEscape to False and use the BTDF menu in Visual Studio to preprocess the bindings file.  Look in PortBindings.xml and verify that your replacement connection string is in place and the XML looks good.  If it does, then set ApplyXmlEscape back to True.

Next you could configure this one port manually in BizTalk Admin, export the bindings file, then compare that chunk of the exported file to the matching chunk of PortBindings.xml.  It's so touchy that sometimes even an extra CR/LF in the bindings file will cause it to fail.

Thanks,
Tom

Apr 5, 2012 at 10:08 AM

In the end I started from scratch and it worked. I'm so glad I spent the time creating a tool to update the known-good bindings with the ENV parameters. I never worked out what the problem was.

Thanks for your help.

Iain