Click here to Skip to main content
15,886,091 members
Articles / Programming Languages / C#

Integrating WCF Services into UDDI based enterprise SOA

Rate me:
Please Sign up or sign in to vote.
4.87/5 (16 votes)
27 Jan 2009CPOL18 min read 69.1K   749   42  
Shows how to integrate WCF services into a UDDI based SOA. This includes the discovery of WCF services at runtime and the runtime configuration of the client.
using System.Configuration;

namespace UDDIServiceFactory.Configuration
{
    /// <summary>
    /// Provides access to configuration files for client applications. 
    /// This class cannot be inherited.
    /// </summary>
    public static class ConfigurationAgent
    {
        #region Fields

        /// <summary>
        /// Represents a particular configuration applicable to an application.
        /// </summary>
        private static System.Configuration.Configuration _appConfig = null;

        /// <summary>
        /// Used to synclock access to critical sections.
        /// </summary>
        private static object _syncLock = new object();

        #endregion

        #region Accessors

        /// <summary>
        /// Gets the <see cref="System.Configuration.Configuration"/> object.
        /// </summary>
        public static System.Configuration.Configuration Configuration
        {
            get
            {
                if (null == _appConfig)
                {
                    lock (_syncLock)
                    {
                        _appConfig = ConfigurationAgent.OpenExeConfiguration(ConfigurationUserLevel.None);
                    }
                }
                return _appConfig;
            }
        }

        #endregion

        #region Public methods

        /// <summary>
        /// Retrieves a specified configuration section for the current
        /// application's default configuration.
        /// </summary>
        /// <param name="sectionName">The configuration section path and name.</param>
        /// <returns>A <see cref="System.Configuration.ConfigurationSection"/> object.</returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">
        /// A configuration file could not be loaded.</exception>
        public static System.Configuration.ConfigurationSection GetSection(string sectionName)
        {
            // Returns the specified ConfigurationSection object.
            return _appConfig.GetSection(sectionName);
        }

        /// <summary>
        /// Opens the configuration file for the current application
        /// as a <see cref="System.Configuration.Configuration"/> object.
        /// </summary>
        /// <param name="level">The <see cref="ConfigurationUserLevel"/> object for which you are opening the configuration.</param>
        /// <returns>A <see cref="System.Configuration.Configuration"/> object.</returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">
        /// A configuration file could not be loaded.</exception>
        public static System.Configuration.Configuration OpenExeConfiguration(ConfigurationUserLevel level)
        {
            // Get the application configuration file.
            lock (_syncLock)
            {
                _appConfig = ConfigurationManager.OpenExeConfiguration(level);
            }
            return _appConfig;
        }

        /// <summary>
        /// Opens the specified client configuration file as a <see cref="System.Configuration.Configuration"/>
        /// object that uses the specified file mapping and user level.
        /// </summary>
        /// <param name="fileMap">An <see cref="ExeConfigurationFileMap"/> object that references configuration
        /// file to use instead of the application default configuration file.</param>
        /// <param name="level">The <see cref="ConfigurationUserLevel"/> object for which you are opening the configuration.</param>
        /// <returns>A System.Configuration.Configuration object.</returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">
        /// A configuration file could not be loaded.</exception>
        public static System.Configuration.Configuration OpenMappedExeConfiguration(ExeConfigurationFileMap fileMap, ConfigurationUserLevel level)
        {
            // Get the application configuration file.
            lock (_syncLock)
            {
                _appConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, level);
            }
            return _appConfig;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Germany Germany
being IT-Engineer since 1995 I am freelancing since then. From networks to programming, from system administration to DBA, from AIX to Windows I offer a wide range of IT-Skill's without considering me the ultimate expert in each area.
I try to avoid complexity wherever I can and so my philosophy is to strictly follow KISS principles.

Comments and Discussions