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.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
#endregion

namespace Microsoft.WindowsAzure.CAT.Samples.ServiceBusForWindowsServer.MessageInspector
{
    /// <summary>
    /// MessageInspectorEndpointBehavior implements IEndpointBehavior and adds 
    /// a message inspector to the dispatch and/or client runtime. 
    /// </summary>
    public class ServiceBusMessageInspectorEndpointBehavior : IEndpointBehavior
    {
        #region Private Fields
        //***************************
        // Private Fields
        //***************************

        private readonly bool isComponentEnabled;
        private readonly bool isTrackingEnabled;
        private readonly PropertiesElement propertiesToPromote;
        private readonly PropertiesElement propertiesToWrite;
        private readonly PropertiesElement propertiesToSend;
        #endregion

        #region Public Constructors
        //***************************
        // Public Constructors
        //***************************

        /// <summary>
        /// Initializes a new instance of the ServiceBusMessageInspectorEndpointBehavior class.
        /// </summary>
        public ServiceBusMessageInspectorEndpointBehavior()
        {
            isComponentEnabled = true;
            isTrackingEnabled = true;
            propertiesToPromote = null;
            propertiesToWrite = null;
            propertiesToSend = null;
        }

        /// <summary>
        /// Initializes a new instance of the ServiceBusMessageInspectorEndpointBehavior class.
        /// </summary>
        /// <param name="isComponentEnabled">This value indicates whether the message inspector is enabled.</param>
        /// <param name="isTrackingEnabled">This value indicates whether tracking is enabled.</param>
        /// <param name="propertiesToPromote">This object defines the properties to promote.</param>
        /// <param name="propertiesToWrite">This object defines the properties to write.</param>
        /// <param name="propertiesToSend">This object defines the properties to send.</param>
        public ServiceBusMessageInspectorEndpointBehavior(bool isComponentEnabled,
                                                          bool isTrackingEnabled,
                                                          PropertiesElement propertiesToPromote,
                                                          PropertiesElement propertiesToWrite,
                                                          PropertiesElement propertiesToSend)
        {
            this.isComponentEnabled = isComponentEnabled;
            this.isTrackingEnabled = isTrackingEnabled;
            this.propertiesToPromote = propertiesToPromote;
            this.propertiesToWrite = propertiesToWrite;
            this.propertiesToSend = propertiesToSend;
        }
        #endregion

        #region IEndpointBehavior Members
        //***************************
        // IEndpointBehavior Members
        //***************************

        /// <summary>
        /// Implement to pass data at runtime to bindings to support custom behavior.
        /// </summary>
        /// <param name="endpoint">The endpoint to modify.</param>
        /// <param name="bindingParameters">The objects that binding elements require to support the behavior.</param>
        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {
        }

        /// <summary>
        /// Implements a modification or extension of the client across an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint that is to be customized.</param>
        /// <param name="clientRuntime">The client runtime to be customized.</param>
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(new ServiceBusMessageInspector(isComponentEnabled,
                                                                               isTrackingEnabled,
                                                                               propertiesToPromote,
                                                                               propertiesToWrite,
                                                                               propertiesToSend));
        }

        /// <summary>
        /// Implements a modification or extension of the service across an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="endpointDispatcher">The endpoint dispatcher to be modified or extended.</param>
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new ServiceBusMessageInspector(isComponentEnabled,
                                                                                                    isTrackingEnabled,
                                                                                                    propertiesToPromote,
                                                                                                    propertiesToWrite,
                                                                                                    propertiesToSend));
        }

        /// <summary>
        /// Implement to confirm that the endpoint meets some intended criteria.
        /// </summary>
        /// <param name="endpoint">The endpoint to validate.</param>
        public void Validate(ServiceEndpoint endpoint)
        {
        }
        #endregion
    }
}