Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Custom Pipeline Components – part 1: Getting Started

This is the first post in a series on how to develop custom pipelines and incorporate advanced functionality. The final example will allow the reader to incorporate PGP decryption on the receive sid and encryption on the send ports.

A custom pipeline component is just a plain .NET class that implements several BizTalk interfaces. I recommend creating a seperate c# project to contain just your custom pipeline classes.

In this post, I will go through creating a sample pipeline component that archives the incoming message to the file system at the Decode stage

To get started, create a standard C# Class Library project.

    Add references to the following:

  • Microsoft.BizTalk.Messaging (C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.Biztalk.Messaging.dll)
  • Microsoft.BizTalk.Pipeline (C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Pipeline.dll)
  • System
  • System.Data
  • System.Drawing
  • System.XML

Add your namespace and the following namespace directives…

namespace Tallan.BlogBizTalk.PipelineComponent

{

    using System;

    using System.IO;

    using System.Text;

    using System.Drawing;

    using System.Resources;

    using System.Reflection;

    using System.Diagnostics;

    using System.Collections;

    using System.ComponentModel;

    using Microsoft.BizTalk.Message.Interop;

    using Microsoft.BizTalk.Component.Interop;

    using Microsoft.BizTalk.Component;

    using Microsoft.BizTalk.Messaging;

 

Add the class name and the following attributes. Note that you should replace the guid value with a value generated for your class

[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]

[System.Runtime.InteropServices.Guid(“f5f5337f-593f-4618-8e35-dff308dbb6f5″)]

[ComponentCategory(CategoryTypes.CATID_Decoder)]

public class MyArchivePipelineComponent :

  Microsoft.BizTalk.Component.Interop.IComponent,IBaseComponent,

  IPersistPropertyBag,   IComponentUI

    {

 

    Note that the class implements the following interfaces:

  • Microsoft.BizTalk.Component.Interop.IComponent – All pipeline components except assemblers and disassemblers implement this interface to get messages from the BizTalk Server engine for processing and to pass processed messages back to the engine.
    NOTE: this needs to be a fully qualified reference, otherwise it will cause a compiler error: ‘IComponent’ is an ambiguous reference between ‘System.ComponentModel.IComponent’ and ‘Microsoft.BizTalk.Component.Interop.IComponent’
  • IBaseComponent – All pipeline components need to implement this interface to provide basic information about the component.
  • IPersistPropertyBag –  Pipeline components need to implement this interface to receive its configuration information.
  • IComponentUI – Pipeline components must implement this interface to be used within the Pipeline Designer environment.

The archive component has two properties: an archive folder location (set as a string) and a boolean to indicate whether the archive component is turned on.

        private string _path;

        public string path

        {

            getreturn _path;    }

            set {  _path = value;   }

        }

        private bool _IsActive;

        public bool IsActive

        {

            get { return _IsActive;  }

            set { _IsActive = value; }

        }

 

The following properties are required to implement the IBaseComponent interface. Basically, the name, version and description of the component returned as string.

        #region IBaseComponent members

        /// <summary>

        /// Name of the component

        /// </summary>

        [Browsable(false)]

        public string Name

        {

            get { return “MyComponentName”;  }

        }

        /// <summary>

        /// Version of the component

        /// </summary>

        [Browsable(false)]

        public string Version

        {

            get { return “1.0”; }

        }

        /// <summary>

        /// Description of the component

        /// </summary>

        [Browsable(false)]

        public string Description

        {

            getreturn “Sample of a custom pipeline component”;  }

        }

        #endregion

 

Another alternative to hard-coding the strings is to use a resource file (.resx) by adding a new class member…

private System.Resources.ResourceManager resManager =

    new System.Resources.ResourceManager(“Tallan.BlogBizTalk.PipelineComponent.MyArchivePipelineComponent”,

                                                Assembly.GetExecutingAssembly());

And replacing return “string” with

return resManager.GetString(“COMPONENTNAME”,

                                 System.Globalization.CultureInfo.InvariantCulture);

 

Now, we will implement the ComponentUI interface. This consists of an icon property and a method called Validate. Validate is called by the compiler to verify all of the configuration properties are set correctly.  For now, to indicate successful property validation, the method should return an empty enumerator.

        #region IComponentUI members

        /// <summary>

        /// Component icon to use in BizTalk Editor

        /// </summary>

        [Browsable(false)]

        public IntPtr Icon

        {

            get

            {

                return ((System.Drawing.Bitmap)(this.res.GetObject(“COMPONENTICON”, System.Globalization.CultureInfo.InvariantCulture))).GetHicon();

            }

        }

        /// <summary>

        /// The Validate method is called by the BizTalk Editor during the build

        /// of a BizTalk project.

        /// </summary>

        /// <param name=”obj”>An Object containing the configuration properties</param>

        /// <returns>The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator.</returns>

        public System.Collections.IEnumerator Validate(object obj)

        {

            // example implementation:

            // ArrayList errorList = new ArrayList();

            // errorList.Add(“This is a compiler error”);

            // return errorList.GetEnumerator();

            return null;

        }

        #endregion

This ends the first part of the Custom Pipeline Components posts. This is continued in part two.

Tags: BizTalk,

5 Comments. Leave new

[…] This post continues the series on creating custom pipeline components. The previous posts in the series can be found here:  post 1,  post 2. […]

[…] the previous post we started creating the c# class that implements the interfaces needed to develop a […]

Hi can you please send me the link for Archive componenet part 3. Because i try to access the above link its throwing an error as below
“Description: Unable to locate the server named “www.blogbiztalk.com” — the server does not have a DNS entry. Perhaps there is a misspelling in the server name, or the server no longer exists. Double-check the name and try again.”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

\\\