In my last entry, I discussed some ways that can making working with binding
files a bit easier. Here is another post in that same vein that addresses
a common pain point...
One of the annoying things about binding files is that adapters only have a
string element available to store adapter-specific information for send ports
and receive locations. As a result, adapters will store escaped XML (or
even "doubly escaped" xml...) This can be extremely hard to manage,
especially for adapters such as MQSeries that keep quite a bit of information
in this form.
To solve this problem, I introduced a new command-line tool in the most
recent version of the
Deployment Framework called "ElementTunnel.exe" (the source for which is
in the
Tools download.) This utility will take in an xml file, along with
a file containing xpaths to elements that should be "encoded" or
"decoded". The end result is that you can choose to manage a "master"
binding file (not directly useable) and run ElementTunnel on it immediately
prior to deployment. (You may also run XmlPreProcess on the same file for
macro expansion! The sample in the deployment framework shows both occurring -
XmlPreProcess should occur first!)
So what does this mean? An example for a single Send Port snippet: It
means that, in the case of MQSeries, instead of storing and maintaining this
mess:
<SendPort Name="SomeQueue" IsStatic="true"
IsTwoWay="false">
<TransmitPipeline Name="SomeAssembly.SomeQueue"
FullyQualifiedName="SomeAssembly.SomeQueue,
SomeAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=bb955d799cc915b9" Type="2" />
<PrimaryTransport>
<Address>MQS://SomeServer/SomeQM/SomeQueue</Address>
<TransportTypeData><CustomProps><AdapterConfig
vt="8">&lt;Config xmlns:xsd=
;"http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&
amp;gt;&lt;uri&gt;MQS://SomeServer/SomeQM/ SomeQueue& amp;lt;/uri&gt;&lt;queueDetails&
amp;gt;SomeServer/SomeQM/SomeQueue&lt;/queueDetails&
amp;gt;&lt;transactionSupported&gt;yes&
amp;lt;/transactionSupported&gt;&lt;dataConversion&gt;no&lt;/dataConversion&
amp;gt;&lt;segmentationAllowed&gt;no&lt;
/segmentationAllowed&gt;&lt;fragmentationSize&
amp;gt;500&lt;/fragmentationSize&gt;&lt;ordered& amp;gt;no&lt;/ordered&gt;&lt;/Config&
amp;gt;</AdapterConfig& gt;</CustomProps></TransportTypeData>
<RetryCount>3</RetryCount>
<RetryInterval>5</RetryInterval>
...
</SendPort>
You can store and maintain this:
<SendPort Name="SomeQueue" IsStatic="true" IsTwoWay="false">
<TransmitPipeline Name="SomeAssembly.SomeQueue"
FullyQualifiedName="SomeAssembly.SomeQueue,
SomeAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=bb955d799cc915b9" Type="2" />
<PrimaryTransport>
<Address>MQS://SomeServer/SomeQM/SomeQueue</Address>
<TransportTypeData> <CustomProps>
<AdapterConfig vt="8">
<Config>
<uri>MQS://SomeServer/SomeQM/SomeQueue</uri>
<queueDetails>SomeServer/SomeQM/SomeQueue</queueDetails>
<transactionSupported>yes</transactionSupported>
<dataConversion>no</dataConversion>
<segmentationAllowed>no</segmentationAllowed>
<fragmentationSize>500</fragmentationSize>
<ordered>no</ordered>
</Config>
</AdapterConfig>
</CustomProps> </TransportTypeData>
<RetryCount>3</RetryCount>
<RetryInterval>5</RetryInterval>
...
</SendPort>
Ahhh, isn't that better? Of course, similar goodness for all other
adapters. And, in the clean version, you'll find it easier to
place/maintain XmlPreProcess macros.
In the Deployment Framework sample, you'll see that we pass the following xpaths to
ElementTunnel (along with the "master" binding file itself):
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/
ReceiveLocationTransportTypeData/CustomProps/AdapterConfig
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/
ReceiveLocationTransportTypeData
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData/CustomProps/AdapterConfig
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData
If you want to "unescape" your binding file (generally a one-time thing, just
to get clean content) you'll want to pass these xpaths in a slightly different order,
because of the "double escaping":
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/
ReceiveLocationTransportTypeData
/BindingInfo/ReceivePortCollection/ReceivePort/ReceiveLocations/ReceiveLocation/
ReceiveLocationTransportTypeData/CustomProps/AdapterConfig
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData
/BindingInfo/SendPortCollection/SendPort/*/TransportTypeData/CustomProps/AdapterConfig
So! If you are managing large binding files (where escaped xml is getting in
your way), you might find this technique handy...Grab the tool, and give it a go.