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.MessageInspector
{
    /// <summary>
    /// Defines class defines the extension element which allows 
    /// to specify the EndpointBehavior in the configuration file.
    /// </summary>
    public class ServiceBusMessageInspectorBehaviorExtensionElement : BehaviorExtensionElement
    {
        #region Private Constants
        //***************************
        // Constants
        //***************************

        private const string IsComponentEnabledName = "isComponentEnabled";
        private const string IsTrackingEnabledName = "isTrackingEnabled";
        private const string PropertiesToPromoteName = "propertiesToPromote";
        private const string PropertiesToWriteName = "propertiesToWrite";
        private const string PropertiesToSendName = "propertiesToSend";
        private const string IsComponentEnabledDescription = "Gets or sets a value indicating whether the message inspector is enabled.";
        private const string IsTrackingEnabledDescription = "Gets or sets a value indicating whether tracking is enabled.";
        private const string PropertiesToPromoteDescription = "Gets or sets an object that defines which user defined " + 
                                                              "properties must be extracted from the Properties collection " + 
                                                              "of the BrokeredMessageProperty and promoted to the BizTalk message context.";
        private const string PropertiesToWriteDescription = "Gets or sets an object that defines which user defined " + 
                                                            "properties must be extracted from the Properties collection "+ 
                                                            "of the BrokeredMessageProperty and written to the BizTalk message context.";
        private const string PropertiesToSendDescription = "Gets or sets an object that defines which context properties " + 
                                                            "must be extracted from the Properties collection of the WCF message and " + 
                                                            "added to the Properties collection of the BrokeredMessageProperty.";
        #endregion

        #region Protected Methods
        //***************************
        // 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 ServiceBusMessageInspectorEndpointBehavior(IsComponentEnabled,
                                                                  IsTrackingEnabled,
                                                                  PropertiesToPromote, 
                                                                  PropertiesToWrite,
                                                                  PropertiesToSend);
        }
        #endregion

        #region Public Properties
        //***************************
        // Public Properties
        //***************************

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

        /// <summary>
        /// Gets or sets a value indicating whether the message inspector is enabled.
        /// </summary>
        [ConfigurationProperty(IsComponentEnabledName, DefaultValue = true, IsRequired = false)]
        [SettingsDescription(IsComponentEnabledDescription)]
        public bool IsComponentEnabled
        {
            get
            {
                return (bool)base[IsComponentEnabledName];
            }
            set
            {
                base[IsComponentEnabledName] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the message inspector is enabled.
        /// </summary>
        [ConfigurationProperty(IsTrackingEnabledName, DefaultValue = true, IsRequired = false)]
        [SettingsDescription(IsTrackingEnabledDescription)]
        public bool IsTrackingEnabled
        {
            get
            {
                return (bool)base[IsTrackingEnabledName];
            }
            set
            {
                base[IsTrackingEnabledName] = value;
            }
        }

        /// <summary>
        /// Gets or sets an object that defines which user defined properties must be 
        /// extracted from the Properties collection of the BrokeredMessageProperty 
        /// and promoted to the BizTalk message context.
        /// </summary>
        [ConfigurationProperty(PropertiesToPromoteName, IsRequired = false)]
        [SettingsDescription(PropertiesToPromoteDescription)]
        public PropertiesElement PropertiesToPromote
        {
            get
            {
                return (PropertiesElement)base[PropertiesToPromoteName];
            }
            set
            {
                base[PropertiesToPromoteName] = value;
            }
        }

        /// <summary>
        /// Gets or sets an object that defines which user defined properties must be 
        /// extracted from the Properties collection of the BrokeredMessageProperty 
        /// and promoted to the BizTalk message context.
        /// </summary>
        [ConfigurationProperty(PropertiesToWriteName, IsRequired = false)]
        [SettingsDescription(PropertiesToWriteDescription)]
        public PropertiesElement PropertiesToWrite
        {
            get
            {
                return (PropertiesElement)base[PropertiesToWriteName];
            }
            set
            {
                base[PropertiesToWriteName] = value;
            }
        }

        /// <summary>
        /// Gets or sets an object that defines which context properties 
        /// must be extracted from the Properties collection of the WCF message and 
        /// added to the Properties collection of the BrokeredMessageProperty.
        /// </summary>
        [ConfigurationProperty(PropertiesToSendName, IsRequired = false)]
        [SettingsDescription(PropertiesToSendDescription)]
        public PropertiesElement PropertiesToSend
        {
            get
            {
                return (PropertiesElement)base[PropertiesToSendName];
            }
            set
            {
                base[PropertiesToSendName] = value;
            }
        }
        #endregion
    }
}