Wednesday, September 19, 2007

Export/Import large amounts of Parties using BindingImport

The party management of Biztalk gets a little bit slow and unhandy with a a large amount of trading Partners.
Exporting about 12.000 BizTalk parties with the Binding Export tool takes about 6 hours on a fast machine resulting in a 200 MB XML binding file.

For an import in smaller slices you can split the binding file in smaller pieces with a small program using XPathNavigator and XmlTextWriter:
XPathDocument xPathDocument = new XPathDocument (@"Bindingfile.xml");
XPathNavigator nav = xPathCocument.CreateNavigator();
XPathNodeIterator partyCollection = nav.Select("/BindingInfo/PartyCollection/Party");

Iterate over the partyCollection and create XML documents
XmlTextWriter xmlWriter = new XmlTextWriter(@"SmallBinding.xml",Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("BindingInfo");
xmlWriter.WriteStartElement("PartyCollection");
...

Finally use BTS-Task to import the slice:

Process process = new Process();
process.StartInfo.FileName = @"C:\...\BTSTask.exe";
process.StartInfo.Arguments = "importbindings -Source:" + @"SmallBinding.xml";
process.Start();
process.WaitForExit();

No comments: