Skip to main content

How to integrate BizTalk Server 2010 / 2013 with Service Bus for Windows Server

This solution shows how to integrate a BizTalk Server 2010/2013 application with Service Bus for Windows Server using the WCF-Custom adapter to exchange messages with external systems in a reliable, flexible, and scalable manner.

C# (5.3 MB)
 
 
 
 
 
4.7 Star
(6)
1,708 times
Add to favorites
6/20/2014
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
#region Copyright
//=======================================================================================
//Microsoft Windows Server AppFabric Customer Advisory Team (CAT)  
//
// This sample is supplemental to the technical guidance published on the community
// blog at http://blogs.msdn.com/paolos. 
// 
// Author: Paolo Salvatori
//=======================================================================================
// Copyright © 2011 Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT.
//=======================================================================================
#endregion

#region Using Directives
using System;
using System.Configuration;
using System.ServiceModel.Configuration;
#endregion

namespace Microsoft.WindowsAzure.CAT.Samples.ServiceBusForWindowsServer.Security
{
    public class TokenProviderBehaviorExtensionElement : BehaviorExtensionElement
    {
        #region Private Constants
        //***************************
        // Constants
        //***************************

        private const string UserNamePropertyName = "userName";
        private const string PasswordPropertyName = "password";
        private const string DomainPropertyName = "domain";
        private const string StsEndpointPropertyName = "stsEndpoint";
        private const string TokenProviderTypePropertyName = "tokenProviderType";
        private const string IsTrackingEnabledPropertyName = "isTrackingEnabled";
        private const string UserNamePropertyDescription = "Gets or sets the user name associated with the credentials.";
        private const string PasswordPropertyDescription = "Gets or sets the password for the user name associated with the credentials.";
        private const string DomainPropertyDescription = "Gets or sets the domain associated with these credentials.";
        private const string StsEndpointPropertyDescription = "Gets or sets the uri of the STS endpoint.";
        private const string TokenProviderTypePropertyDescription = "Gets or sets the token provider type.";
        private const string IsTrackingEnabledPropertyDescription = "Gets or sets a value indicating whether tracking is enabled.";
        #endregion

        #region BehaviorExtensionElement Members
        //***************************
        // Protected Methods
        //***************************

        /// <summary>
        /// Creates a behavior extension based on the current configuration settings.
        /// </summary>
        /// <returns>The behavior extension.</returns>
        protected override object CreateBehavior()
        {
            return new TokenProviderEndpointBehavior(UserName, Password, Domain, StsEndpoint, TokenProviderType, IsTrackingEnabled);
        }

        /// <summary>
        /// Gets the type of behavior.
        /// </summary>
        public override Type BehaviorType
        {
            get
            {
                return typeof(TokenProviderEndpointBehavior);
            }
        }      
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets the user name associated with the credentials.
        /// </summary>
        [ConfigurationProperty(UserNamePropertyName, IsRequired = false)]
        [SettingsDescription(UserNamePropertyDescription)]
        public string UserName
        {
            get
            {
                return (string)base[UserNamePropertyName];
            }
            set
            {
                base[UserNamePropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the password for the user name associated with the credentials.
        /// </summary>
        [ConfigurationProperty(PasswordPropertyName, IsRequired = false)]
        [SettingsDescription(PasswordPropertyDescription)]
        public string Password
        {
            get
            {
                return (string)base[PasswordPropertyName];
            }
            set
            {
                base[PasswordPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the domain associated with these credentials.
        /// </summary>
        [ConfigurationProperty(DomainPropertyName, IsRequired = false)]
        [SettingsDescription(DomainPropertyDescription)]
        public string Domain
        {
            get
            {
                return (string)base[DomainPropertyName];
            }
            set
            {
                base[DomainPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the uri of the STS endpoint.
        /// </summary>
        [ConfigurationProperty(StsEndpointPropertyName, IsRequired = true)]
        [SettingsDescription(StsEndpointPropertyDescription)]
        public string StsEndpoint
        {
            get
            {
                return (string)base[StsEndpointPropertyName];
            }
            set
            {
                base[StsEndpointPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the STS port.
        /// </summary>
        [ConfigurationProperty(TokenProviderTypePropertyName, DefaultValue = TokenProviderType.WindowsTokenProvider, IsRequired = true)]
        [SettingsDescription(TokenProviderTypePropertyDescription)]
        public TokenProviderType TokenProviderType
        {
            get
            {
                return (TokenProviderType)base[TokenProviderTypePropertyName];
            }
            set
            {
                base[TokenProviderTypePropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether tracking is enabled.
        /// </summary>
        [ConfigurationProperty(IsTrackingEnabledPropertyName, DefaultValue = true, IsRequired = false)]
        [SettingsDescription(IsTrackingEnabledPropertyDescription)]
        public bool IsTrackingEnabled
        {
            get
            {
                return (bool)base[IsTrackingEnabledPropertyName];
            }
            set
            {
                base[IsTrackingEnabledPropertyName] = value;
            }
        }
        #endregion
    }
}