Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Integrating WCF Services into UDDI based enterprise SOA

, 27 Jan 2009 CPOL
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.
DynamicWCFFactory.zip
DynamicWCFFactory
DynamicWCFFactory
Behaviours
bin
Debug
Configuration
Properties
DynamicWCFFactory.gpState
DynamicWCFFactory.vsmdi
DynamicWCFFactoryTests
bin
Debug
Properties
Service References
ServiceReference
configuration.svcinfo
configuration91.svcinfo
DynamicWCFFactoryTests.ServiceReference.CompositeType.datasource
Reference.svcmap
Service1.disco
Service1.wsdl
LocalTestRun.testrunconfig
TestResults
UDDIServiceFactory
bin
Debug
Configuration
Lib
Microsoft.Uddi.dll
Properties
WcfService
App_Data
bin
Properties
Service1.svc
WcfService.csproj.user
using System.Configuration;

namespace DynamicWCFFactory
{
    /// <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)

Share

About the Author

Tobias Manthey
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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150305.1 | Last Updated 27 Jan 2009
Article Copyright 2009 by Tobias Manthey
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid