TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Editing: BizTalk Server: Application Configuration options
Wiki
>
TechNet Articles
>
BizTalk Server: Application Configuration options
Article
Edit
History
Title
<html> <body> [toc] <h1><a name="Introduction"></a>Introduction</h1> <p>There are a couple of options a developer can have when comes to using application configurable values. These options can be divided into three categories:</p> <ul> <li><strong>File</strong>: BTSNTSvc.exe.config, Custom config file, Enterprise Library </li><li><strong>Database</strong>: Business Rule Engine, SSO, or Custom database </li><li><strong>Registry</strong> </li></ul> <p>This article will provide guidance on each of possible options.</p> <h1><a name="BTSNTSvc_exe_config_file"></a>BTSNTSvc.exe.config file</h1> <p>The BizTalk orchestration engine uses an XML file called <a target="_blank" href="http://msdn.microsoft.com/en-us/library/aa561903%28v=bts.70%29.aspx"> BTSNTSvc.exe.config</a> to determine certain behaviors. This file attaches to the main executable BTSNTSvc.exe. Any changes placed in BTSNTSvc.exe.config apply to all host instance regardless of their names. This file is always located in the same directory as the BTSNTSvc.exe file, which is usually C:\Program Files\Microsoft BizTalk Server 2010. Any changes in this file will result in a restart of BizTalk Host Instance. Values can be obtained through code in expression shape in an orchestration.<span style="font-size:12px"><br> </span></p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#008200">//Get Configuration parameters from BTSNTsvc.exe.config</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">BTSNTsvcConfigValue1=System.Configuration.ConfigurationSettings.AppSettings.Get(</code><code style="color:blue">"Value1"</code><code style="color:#000000">);</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">BTSNTsvcConfigValue2=System.Configuration.ConfigurationSettings.AppSettings.Get(</code><code style="color:blue">"Value2"</code><code style="color:#000000">);</code></span></div> </div> <p> </p> <h2><a name="Blogs"></a>Blogs</h2> <ul> <li><a target="_blank" href="http://sandroaspbiztalkblog.wordpress.com/2009/04/03/working-with-biztalk-configuration-file-btsntsvc-exe-config/">Working with BizTalk Configuration File – BTSNTSvc.exe.config</a> </li></ul> <h1><a name="Custom_Config_File"></a>Custom Config File</h1> <p>A custom configuration file (.config) can be option to store application configuration data that you can use within BizTalk orchestration for instance. A custom config can be easier to maintain that <a target="_blank" href="#BTSNTSvc_exe_config_file">BTSNTSvc.exe.config</a> file. You can choose whether or not to use <a target="_blank" href="http://geekswithblogs.net/paulp/archive/2008/06/11/122803.aspx"> Enterprise Library</a> or custom code. Enterprise Library may be too much overhead to just access a custom file. Accessing a .config file can be done using simple .NET code, using the <a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.configuration.aspx"> System.Configuration</a> namespace. </p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// <summary></code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// Return configuration value</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// </summary></code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// <param name="key">Key in configuration</param></code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// <param name="nameConfigFile">Name of configuration file</param></code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#808080">/// <returns></returns></code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#006699; font-weight:bold">public</code> <code style="color:#006699; font-weight:bold">static</code> <code style="color:#006699; font-weight:bold"> string</code> <code style="color:#000000">GetConfigValue(</code><code style="color:#006699; font-weight:bold">string</code> <code style="color:#000000">key, </code><code style="color:#006699; font-weight:bold">string</code> <code style="color:#000000">nameConfigFile)</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">{</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Get the application configuration file path.</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Combining location of config file with name of config file</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#006699; font-weight:bold">string</code> <code style="color:#000000">exeFilePath = System.IO.Path.Combine(Environment.GetEnvironmentVariable(</code><code style="color:blue">"BizTalkConfigOptions"</code><code style="color:#000000">, EnvironmentVariableTarget.Machine), nameConfigFile);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Map to the application configuration file.</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Instantiate ExeConfigurationFileMap</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">ExeConfigurationFileMap configFile = </code><code style="color:#006699; font-weight:bold">new</code> <code style="color:#000000"> ExeConfigurationFileMap();</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Bind filepath to configFile object</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">configFile.ExeConfigFilename = exeFilePath;</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Instantiate Configuration object and assign configFile</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#008200">// Return desired value from configuration file</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#006699; font-weight:bold">return</code> <code style="color:#000000">config.AppSettings.Settings[key].Value.ToString();</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">}</code></span></div> </div> <br> When using custom config file in a multi-machine environment you need to maintain config on each machine. Another back draw is I/O with reading from file. You might need to implement some caching to avoid delays in reading from physical file.<br> <br> <h2><a name="Blogs"></a>Blogs</h2> There are some blogs that discuss this option:<br> <ul> <li><a target="_blank" href="http://soa-thoughts.blogspot.com/2007/07/biztalk-and-configuration-files.html">BizTalk and Configuration Files</a> </li><li><a target="_blank" href="http://geekswithblogs.net/paulp/archive/2008/06/11/122803.aspx">Storing BizTalk settings in custom configuration file using Enterprise Library </a></li></ul> <h1><a name="Enterprise_Library"></a>Registry</h1> <p>Another option is accessing the registry to obtain application configuration values. Through custom code in .NET Helper Class using <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.aspx">Microsoft.Win32</a> namespace you can access the registry and read values. See code below to access the registry.</p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">[Serializable]</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">public static class REGISTRYConfigHelper</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">{</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// Return value from registry</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// </</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"subKey"</code><code style="color:#000000">>subKey in the Hive</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"value"</code><code style="color:#000000">>Value from subKey</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">>Request value from the subKey</</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">public static string Read(string subKey, string value)</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Create value variable</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">string retValue = null;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Opening the registry key</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">RegistryKey rk = Registry.CurrentUser;</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Open a subKey as read-only</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">RegistryKey sk1 = rk.OpenSubKey(subKey,RegistryKeyPermissionCheck.ReadSubTree,System.Security.AccessControl.RegistryRights.FullControl);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// If the RegistrySubKey does exist</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">if (sk1 != null)</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">try</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:48px!important"><code style="color:#000000">// If the RegistryKey exists get its value or null is returned.</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:48px!important"><code style="color:#000000">retValue = (string)sk1.GetValue(value.ToUpper());</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">catch (Exception e)</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:48px!important"><code style="color:#000000">System.Diagnostics.Trace.WriteLine(e.Message);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:48px!important"><code style="color:#000000">throw;</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:36px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Return value</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">return retValue;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">}</code></span></div> </div> <br> Storing values in registry is an option, however it is not easy to maintain. In a multiple machine BizTalk deployment this is far from ideal option as you have to maintain multiple registries. The same accounts for using custom file or BTSNTSvc.exe.config. <br> <h1><a name="Business_Rule_Engine"></a>Business Rule Engine</h1> <p>So far registry and file options have been discussed. Not the best options when you want to consider a central store for your application custom configuration data. A database would be a better option from an administrative viewpoint. Business Rule Engine (BRE) can be used to store configuration data. Using a <a href="http://msdn.microsoft.com/en-us/library/aa560288.aspx"> vocabulary</a> with custom definitions containing constant values. Code below shows how to access custom definition in a vocabulary.</p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// Obtain value from Definition in a Vocabulary</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// </</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"definitionName"</code><code style="color:#000000">>Definition Name e.g. Value1</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"vocabularyName"</code><code style="color:#000000">>Name of Vocabulary i.e. Config</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">>Return Constant Value</</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">></code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">public static string Read(string definitionName, string vocabularyName)</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// RuleStore Object</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">RuleStore rlsRuleStore;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Vocab Info collection</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">VocabularyInfoCollection vicVocabInfo;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Vocab itself</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">Vocabulary vocVocab;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Provides the default deployment driver used to import, export, deploy, un-deploy, and </code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// set tracking configuration for published rule sets and vocabularies, </code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// and to retrieve their deployment characteristics. </code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">RuleSetDeploymentDriver rsdDriver = new RuleSetDeploymentDriver();</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// The current RuleStore</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">rlsRuleStore = rsdDriver.GetRuleStore();</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Set Vocabulary based on Vocabulary collection</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">vicVocabInfo = rlsRuleStore.GetVocabularies(vocabularyName, RuleStore.Filter.All);</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Get the vocabulary itself</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">vocVocab = rlsRuleStore.GetVocabulary(vicVocabInfo[0]);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Get the definition</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">VocabularyDefinition vocDef = vocVocab.Definitions.GetByName(definitionName);</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Set LiteralDefition</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">LiteralDefinition literalDefinition = vocDef as LiteralDefinition;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">// Return Value</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">return literalDefinition.Value.ToString();</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">}</code></span></div> </div> <div class="code"><br> From administrative standpoint maintaining configuration files in BRE can be complex compared to using SSO or CustomDb.<br> <br> <h2><a name="Blogs"></a>Blogs</h2> <ul> <li><a target="_blank" href="http://geekswithblogs.net/FMRuiz/archive/2009/08/14/temp.aspx">BizTalk configuration with the Business Rule Engine</a> </li></ul> </div> <h1><a name="SSO_Database"></a>SSO Database</h1> <p>One of popular and easy options of retrieving application configuration data is using SSO. Microsoft has built a <a href="http://www.microsoft.com/download/en/details.aspx?id=14524">SSO Application Configuration snap in</a> that provides an good user experience maintaining custom configuration data. When downloading the snap in you will also get code for a .NET Helper Class to support retrieval of data in BizTalk. See code below for retrieving data from SSO.<br> <br> </p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// Read method helps get configuration data</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// </</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">> </code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"appName"</code><code style="color:#000000">>The name of the affiliate application to represent the configuration container to access</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"propName"</code><code style="color:#000000">>The property name to read</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">></code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// The value of the property stored in the given affiliate application of this component.</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// </</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">></code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">public static string Read(string appName, string propName)</code></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">{</code></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">try</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//Instantiate SSOConfigStore Object</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">SSOConfigStore ssoStore = new SSOConfigStore();</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//Instantiate ConfigurationPropertyBag</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//Get value based on appName</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//Create propertyValue object</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">object propertyValue = null;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//Read property</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">appMgmtBag.Read(propName, out propertyValue, 0);</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">//return property value</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">return (string)propertyValue;</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">catch (Exception e)</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">{</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">System.Diagnostics.Trace.WriteLine(e.Message);</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="margin-left:24px!important"><code style="color:#000000">throw;</code></span></span></div> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="margin-left:12px!important"><code style="color:#000000">}</code></span></span></div> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">}</code></span></div> </div> <div class="code"><br> This approach has some major benefits. Data is cached and has a built in refresh mechanism (ESSO Service) and secure. It offers ability to store sensitive information. <br> <br> <h2><a name="Blogs"></a>Blogs</h2> <ul> <li><a href="http://blogs.msdn.com/b/skaufman/archive/2010/08/31/storing-application-configuration-information-in-sso.aspx" target="_blank">Custom Configuration options for BizTalk Solution</a> </li><li><a href="http://blogs.msdn.com/b/teekamg/archive/2009/08/19/sso-configuration-application-mmc-snap-in.aspx" target="_blank">SSO Configuration Application MMC Snap-In</a> </li><li><a href="http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalksyn/archive/2010/08/31/storing-application-configuration-information-in-sso.aspx" target="_blank">Storing Application Configuration Information in SSO</a> </li></ul> </div> <h1><a name="Custom_Database"></a>Custom Database</h1> <p>Instead of using one of existing BizTalk databases you can use a custom database to store application configuration data. You can use an .Net Helper Class that supports retrieving the data from database (see code below).<br> <br> </p> <div class="reCodeBlock" style="border:1px solid #7f9db9; overflow-y:auto"> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// Get value from custom database table</code></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// </</code><code style="color:#006699; font-weight:bold">summary</code><code style="color:#000000">></code></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">param</code> <code style="color:#808080">name</code><code style="color:#000000">=</code><code style="color:blue">"value"</code><code style="color:#000000">>name to search in database table</</code><code style="color:#006699; font-weight:bold">param</code><code style="color:#000000">></code></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">/// <</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">>Value of the name</</code><code style="color:#006699; font-weight:bold">returns</code><code style="color:#000000">></code></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">public static string Read(string name)</code></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">{</code></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">string result = null;</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">// Connectionstring, you have to change this setting your own Data Source</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">// Connectionstring could be obtain from config file</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">using (var conn = new SqlConnection("Data Source=WIN-8BPNTQKTJ5M;Initial Catalog=ConfigDb;Integrated Security=True"))</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">using (var cmd = conn.CreateCommand())</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">{</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">conn.Open();</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">cmd.CommandText = "SELECT Value FROM ConfigValues WHERE Name='" + name + "'";</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px; margin-left:0px!important"> </span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">//Execute command</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">SqlDataReader reader = cmd.ExecuteReader();</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">//Read result</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">while (reader.Read())</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">{</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:36px!important"><code style="color:#000000">result = reader.GetString(0);</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">}</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">//Close reader</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">reader.Close();</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"> </span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">//Close connection</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:24px!important"><code style="color:#000000">conn.Close();</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">} </code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">// return value</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#ffffff"><span style="font-size:12px"><code> </code><span style="font-size:12px; margin-left:12px!important"><code style="color:#000000">return result;</code></span></span></div> <span style="font-size:12px"></span> <div style="background-color:#f8f8f8"><span style="font-size:12px; margin-left:0px!important"><code style="color:#000000">}</code></span></div> </div> <br> Custom database can be option, but it does not offer the security like SSO. Maintaining custom database is less intuitive as with SSO Application Configuration snap in.<br> <h1><a name="Samples"></a>Samples</h1> <p>There are a couple of samples available demonstrating the options:</p> <ul> <li><a href="http://code.msdn.microsoft.com/Custom-Configuration-6c807804" target="_blank">Custom Configuration options for BizTalk Solution</a> </li><li><a target="_blank" href="http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx">Where do I store my custom configuration for a BizTalk solution</a> </li></ul> <hr> <h1><a name="See_Also"></a>See Also</h1> <p>Read suggested related topics:</p> <ul> <li><a href="http://blogs.msdn.com/b/vishalag/archive/2008/06/22/biztalk-configuration-store.aspx" target="_blank">BizTalk Configuration Store</a> </li></ul> Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is <a href="http://social.technet.microsoft.com/wiki/contents/articles/2240.biztalk-server-resources-on-the-technet-wiki.aspx" target="_blank"> BizTalk Server Resources on the TechNet Wiki</a>. <hr> </body> </html>
Comment
Tags
Please add 3 and 8 and type the answer here: