16 January 2007

Using Configuration in BizTalk Map

Sorry for delay guys, I am coming with remaining pipeline articles very soon. Meanwhile, here is an interesting and useful thing to share.

During BizTalk map definition, sometime you might require to read some configuration value. For example, during use of database related functoids, you have to make connection string configurable. You can use BizTalk config file and scripting functoid to handle such scenario.

 Here is what you need to do -

1. Open "BTSNTSvc.exe.config" file from "drive:\Program Files\Microsoft BizTalk Server 2006 ".

2. Add configuration setting there such as -

<appSettings>

     <add key="CONNSTR" value="Data Source=SQL-SERVER;Initial Catalog=SAMPLE_DB;Integrated Security=SSPI"/>

</appSettings>

3. In map file, drag and drop script functoid and write following inline c# script.

   public string GetConnectionString()
   {
               string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("CONNSTR").ToString();
               return connString;
    }

4. While using any database related functoid, drag output of script functoid as input in database functoid. And do not forget to put it in correct parameter sequence.

That’s it.

One more last thing, you cannot test config value in map at design time because configuration values are read BTS host at runtime.

 

 

Filed under:
 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Sanket Bakshi said:

To test the config value in map at the design time, you will need to add the same configuration string to the visual studio config.

Definitely not a very impressive thing to do. But can help a lot when debugging complex maps.

--Sanket

22 January 07 at 7:04 AM
# Harmjan Menninga said:

During BizTalk map definition, sometime you might require to read some configuration value. For example

30 May 07 at 2:50 AM
# menin said:

i tried this but it gives me Object refrence error,i found that there are limited number of namespaces allowed in Inline C#, does System.configuration allowed in script functiod

07 August 07 at 2:01 AM
# Kelvin said:

Hi,

   First of all, Thank you giving ideas in blogs.I got to know how i can pass connection string now. But is it not possible if we dont used this scripting Functoid where it has declare"System.Configuration.ConfigurationSettings.AppSettings.Get("CONNSTR").ToString();" If, Yes, Can you tell us how we can go for that.

08 April 08 at 12:29 AM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker