Click here to Skip to main content
15,884,298 members
Articles / Productivity Apps and Services / Biztalk

BizTalk ESB Exception Handling – Consuming WCF Services – Part I

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
3 Nov 2012CPOL10 min read 28.1K   197   9  
Managing exceptions when consuming WCF services via the BizTalk ESB Toolkit
using System;
using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;

using ESB.ExceptionHandling.ServiceModel.Channels;

namespace ESB.ExceptionHandling.ServiceModel.Configuration
{
    public class ServiceBindingExtensionElement : BindingElementExtensionElement
    {
        #region Private Constants
        private const string MAX_BUFFER_SIZE_PROPERTY = "MaxBufferSize";
        private const string MESSAGE_VERSION_PROPERTY = "MessageVersion";
        #endregion

        #region Private Fields
        private ServiceBindingElement _serviceBindingElement;
        #endregion

        #region Public Constructors
        public ServiceBindingExtensionElement()
        {
        }
        #endregion

        #region Public Properties
        public override Type BindingElementType
        {
            get
            {
                return typeof(ServiceBindingElement);
            }
        }
        #endregion

        #region Public Methods
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            base.ApplyConfiguration(bindingElement);

            _serviceBindingElement = (ServiceBindingElement)bindingElement;
        }
        #endregion

        #region Protected Methods
        protected override BindingElement CreateBindingElement()
        {
            _serviceBindingElement = new ServiceBindingElement();

            _serviceBindingElement.MaxBufferSize = this.MaxBufferSize;
            _serviceBindingElement.MessageVersion = this.MessageVersion;

            this.ApplyConfiguration(_serviceBindingElement);

            return _serviceBindingElement;
        }
        #endregion

        #region Configuration Properties
        [ConfigurationProperty(MAX_BUFFER_SIZE_PROPERTY, DefaultValue = 2097152)]
        [IntegerValidator(MinValue = 0)]
        public int MaxBufferSize
        {
            get
            {
                return (int)base[MAX_BUFFER_SIZE_PROPERTY];
            }
            set
            {
                base[MAX_BUFFER_SIZE_PROPERTY] = value;
            }
        }

        [ConfigurationProperty(MESSAGE_VERSION_PROPERTY, DefaultValue = MessageVersionEnum.Default)]
        public MessageVersionEnum MessageVersion
        {
            get
            {
                return (MessageVersionEnum)base[MESSAGE_VERSION_PROPERTY];
            }
            set
            {
                base[MESSAGE_VERSION_PROPERTY] = value;
            }
        }
        #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 Digging Dog Ltd
New Zealand New Zealand
I have almost 20 years commercial software development using a number of languages from C++ to C#/VB. My main focus has been in the Microsoft space and, since the early 2000's, most of this has been in the web or integration arena. Over the past few years I have been focusing on building business solutions using a variety of products such as BizTalk and Share Point.
In terms of SDLC's, I have experience with various methodologies such as Agile, RUP, Iterative and Waterfall.
Lastly, the roles I have had in the last few years have given me the opportunity to gain a lot of experience as a consultant. Since, over the last 18 years, I have worked with many customers this has further given me the chance to enjoy many and varying challenges that have helped me grow in my career.
Today, I spend a lot of time talking, designing, documenting and mentoring team members. I also spend quite a bit of time authoring software and find the combination a perfect fit for me.

Specialties
Consultancy, Solution architecture, Solution design, Project costing and tracking, Team lead, Software development, C#, VB, ASP.NET, HTML, DHTML, JavaScript, BizTalk, SharePoint

Comments and Discussions