Using client script to host xml configuration

To make an appserver rule configurable, we often need to store some parameters as a separate xml file. The only problem with this approach is that we have to remember to copy the xml file to the (production) server.

In Pivotal, the more practical way to store the configuration is to host the xml string inside a client script. Since the client script is part of the BM, it will always be available and there is no special deployment required.

Below is the example on how to retrieve xml configuration from a client script.

<?xml version="1.0" encoding="utf-8"?>
<config>
  <logging logFile = "D:\PivotalLog.txt" logLevel = "2">
  </logging>
</config>

Fig. Sample of XML Configuration hosted as a client script

string ClientScriptMapping = "CMS_Config";
string mapping = 
    m_pivotalSystem.ClientScripts[ClientScriptMapping].Text;
string logSettingString = 
    string.Empty;
 
try
{
 
    XmlDocument xd = new XmlDocument();
    xd.LoadXml(mapping);
    string xPathString = "/config/logging";
    XmlNode xNode = xd.SelectSingleNode(xPathString);
    logFile = xNode.Attributes["logFile"].Value;
    logSettingString = xNode.Attributes["logLevel"].Value;
    logSetting = (LogLevel)Convert.ToUInt16(logSettingString);
}

Fig. .NET ASR to retrieve xml string a client script

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s


%d bloggers like this: