Handle Array/List Json messages in BizTalk Receive Pipeline

This blog is to explain how to handle below requirements in BizTalk Receive Pipeline.

  1. Handle Non-List/Array json messages
  2. Handle List/Array json messages
  3. Remove special characters before Json Decoder pipeline stage

Let’s discuss these points.

  1. Handle Non-List/Array json messages

By default, BizTalk Receive Pipeline Json Decoder can convert the Json message to Xml message.

Example:

{

    “ForeignTax”: 12.5,

    “AdditionalPremium”: 20

}

2. Handle List/Array json messages

By default, BizTalk receive pipeline Json Decoder cannot convert Array/List Json messages to Xml format.

Example:

[

    {

        “Id”: 94,

        “LineOfBuinsinesses”: [

            {

                “Id”: 1,

                “Description”: “abc”,

                “Type”: 1

            },

            {

                “Id”: 2,

                “Description”: “def”,

                “Type”: 2

            },

            {

                “Id”: 3,

                “Description”: “ghi”,

                “Type”: 2

            }

        ]

    }

]

In order to handle this kind of json messages, we need to add one Root element to the message and this can be done using custom pipeline. You can download the custom pipeline code from below link.

DownLoad

We need to add this pipeline to Receive pipeline decode stage and deploy the application.

You need to supply the RootName parameters from Pipeline properties in BizTalk admin console.

1.png

 

In the above screenshot, you need to provide RootNode under Decode Stage.

After executing this receive pipeline Enhance JSON Stage, your json message looks like something below and this message can be handled by JSON Decoder.

 

{“Details”: [

    {

        “Id”: 94,

        “LineOfBuinsinesses”: [

            {

                “Id”: 1,

                “Description”: “abc”,

                “Type”: 1

            },

            {

                “Id”: 2,

                “Description”: “def”,

                “Type”: 2

            },

            {

                “Id”: 3,

                “Description”: “ghi”,

                “Type”: 2

            }

        ]

    }

]}

 

Also, you can use the same pipeline for both List and Non-List messages, only thing you have to do for Non-list message is that you no need to supply any Root parameter.

3. Remove special characters before Json Decoder pipeline stage

If you want to remove some special characters in the Json message, you can use some regular expression in the custom Pipeline code.

Example:

string invalidCodeRegEx = @”[\\][u][0-9]{4}|\\b”;

                text = System.Text.RegularExpressions.Regex.Replace(text, invalidCodeRegEx, “”);

 

Advertisements

BizTalk Custom Pipeline to Convert Excel file to Flat file

This blog explains how to convert .xlsx to Flat file in BizTalk using Custom Pipeline.

Below pipeline component is generic one which can be applied to any excel files for FlatFile conversion.

Sample Input (Excel File):

Input.png

Sample Output (Flat File):

Output.png

 

Please follow below steps.

  1. Take a class library project and keep code which is present in below Download link.

Download

2) Provide strong name key, build and deploy to GAC.

3) Take a BizTalk receive pipeline and add the pipeline component (ExcelToFlatFile) to Toolbox

3.png

4) Drag and Drop the Pipeline component from toolbox to Decode stage of Receive pipeline.

4.png

5) Build BizTalk project and deploy.

6) In Admin Console, take one-way receive port and receive location.

7) In Receive pipeline, browse the pipeline “ExcelToFlatFile”

8) Provide the below information in pipeline properties.

8.png

//ConnectionString: Provide the same connection string as in the screenshot above

//SqlStatement: [Sheet1] is the sheet name in the excel sheet.

//TargetFolderLocation: Path of the output flatfile

//TempDropFolderLocation: This is temporary path you need to provide to perform some internal operations by the pipeline code.

9) Take a send port to send the result file (Success/Failure) to file locations and provide below properties. Result file will be having Success message in case of Flat file conversion is successful, otherwise it will be having exception message.

9.png

Note: Actual flat file will be stored in the path which you have provided in Receive pipeline properties.

10) Start the BizTalk application and restart host instances.

11) Drop an Excel file in Input location and you can see the Flat file in Output location

BizTalk Custom Pipeline to Convert Excel file to Xml file

This blog explains how to convert .xls to Xml file in BizTalk using Custom Pipeline.

Below pipeline component is generic one, which can be applied to any excel files for xml conversion.

Sample Input (Excel File):

SampleInput.png

Sample Output (Xml File):

SampleOutput.png

Please follow below steps.

  1. Take a class library project and keep the code mentioned in Download link below.

Download

2) Provide strong name key, build and deploy to GAC.

3) Take a BizTalk receive pipeline and add the pipeline component (ExcelToXmlFileConversion) to Toolbox

 

3.png

 

4) Drag and Drop the Pipeline component from toolbox to Decode stage of Receive pipeline.

4.png

5) Build BizTalk project and deploy.

6) In Admin Console, take one-way receive port and receive location.

7) In Receive pipeline, browse the pipeline “ExcelToXmlFile”

8) Provide the below information in pipeline properties.

8.png

//ConnectionString: Provide the same connection string as in the screenshot above

//DataNodeName: Root name of the repeating node

//NameSpace: BizTalk message namespace.

//SqlStatement: [Sheet1] is the sheet name in the excel sheet.

//TempDropFolderLocation: This is temporary path you need to provide to perform some internal operations by the pipeline code.

9) Take a send port and provide below properties.

 

9.1.png

9.2.png

 

10) Start the BizTalk application and restart host instances.

11) Drop an Excel file in Input location and you can see the Xml file in Output location

Custom Pipeline to Add DocType in Message

Sometimes we require to add some element, tag, DocType in incoming or outgoing message from BizTalk. We can achieve this by using custom pipeline. But we should use this pipeline component in Decode or encode stage of Pipeline.

In this sample custom pipeline, we convert the message in string. So you can take this code and change according your business requirement.

Below link is defined for Custom Pipeline setup details

https://vkbiztalk.com/2017/08/04/custom-pipeline/

Here in this sample code I have added DocType on header of message when sending the message to send port. DocType will defined at design time when consume this pipeline component on encode stage on send pipeline.

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;

using System.IO;

using System.Xml;

 

namespace BizTalk.Custom.PipelineComponents

{

[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]

[ComponentCategory(CategoryTypes.CATID_Any)]

[System.Runtime.InteropServices.Guid(“CB814714-BC81-4BDA-B361-69CA270997E8”)]

public class AddDocFileName : IBaseComponent, IComponentUI, Microsoft.BizTalk.Component.Interop.IComponent, IPersistPropertyBag

{

#region Configuration Properties

private string _DocTypeName;

public string DocTypeName

{

get

{

return _DocTypeName;

}

set

{

_DocTypeName = value;

}

}

#endregion

public string Description

{

get

{

return “Pipeline component To Add DocType in Outgoing XML”;

}

}

public string Name

{

get

{

return “AddDocNameinXML”;

}

}

public string Version

{

get

{

return “1.0.0.0”;

}

}

public IntPtr Icon

{

get

{

return new System.IntPtr();

}

}

public System.Collections.IEnumerator Validate(object projectSystem)

{

return null;

}

public void GetClassID(out Guid classID)

{

classID = new Guid(“CB814714-BC81-4BDA-B361-69CA270997E8”);

}

public void InitNew()

{

}

public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)

{

object val = null;

val = this.ReadPropertyBag(pb, “DocTypeName”);

if ((val != null))

{

this._DocTypeName = ((string)(val));

}

}

public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)

{

this.WritePropertyBag(pb, “DocTypeName”, this.DocTypeName);

}

#region utility functionality

/// <summary>

/// Reads property value from property bag

/// </summary>

/// <param name=”pb”>Property bag</param>

/// <param name=”propName”>Name of property</param>

/// <returns>Value of the property</returns>

private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)

{

object val = null;

try

{

pb.Read(propName, out val, 0);

}

catch (System.ArgumentException)

{

return val;

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

return val;

}

/// <summary>

/// Writes property values into a property bag.

/// </summary>

/// <param name=”pb”>Property bag.</param>

/// <param name=”propName”>Name of property.</param>

/// <param name=”val”>Value of property.</param>

private void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val)

{

try

{

pb.Write(propName, ref val);

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

}

#endregion

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)

{

IBaseMessagePart bodyPart = pInMsg.BodyPart;

XmlDocument xDoc = new XmlDocument();

if (bodyPart != null)

{

Stream originalStream = bodyPart.GetOriginalDataStream();

string originalDataString;

try

{

//fetch original message

Stream originalMessageStream = bodyPart.GetOriginalDataStream();

byte[] bufferOriginalMessage = new byte[originalMessageStream.Length];

originalMessageStream.Read(bufferOriginalMessage, 0, Convert.ToInt32(originalMessageStream.Length));

originalDataString = System.Text.ASCIIEncoding.ASCII.GetString(bufferOriginalMessage);

}

catch (Exception ex)

{

ex.Source = “AddDocTypePipelineComponent”;

throw ex;

}

XmlDocument originalMessageXml = new XmlDocument();

if (originalStream != null)

{

originalDataString = originalDataString.Remove(0, 41);

originalDataString = @”<?xml version=’1.0′ encoding=’UTF-8′?>” + DocTypeName + originalDataString;

byte[] outBytes = System.Text.Encoding.ASCII.GetBytes(originalDataString);

MemoryStream memStream = new MemoryStream();

memStream.Write(outBytes, 0, outBytes.Length);

memStream.Position = 0;

bodyPart.Data = memStream;

pContext.ResourceTracker.AddResource(memStream);

 

}

}

return pInMsg;

}

}

}

 

Sample Input File:

<?xml version=”1.0″ encoding=”UTF-8″?>

<Test xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“><Name> </Name></Test>

Sample Output File:

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE Test SYSTEM “http://localhost/Test/DTD/TestDocType.dtd”&gt;

<Test xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“><Name> </Name></Test>

 

 

 

BAM Activity in Custom Pipeline

Sometimes requirement cannot be fulfil by using tracking profile editor for BAM logging. Here in this code I am explaining about how to use BAM in custom pipeline. And also I am using EnableContinuation method so that we can get all the details in single row in BAM table while using different stage of BAM tracking in BizTalk application. When a solution needs BAM, and you what to link the receivedTime and sendTime together you have to use continuation.

Code for BAM Activity in Custom Pipeline:

Begin BAM Activity

This custom pipeline component can be put after xml or flat dissembler pipeline component in Receive Pipeline, because we are consuming MessageType context property to log into BAM.

For creating BAM Definition Activity please click here

https://vkbiztalk.com/2017/06/14/implementation-of-bam-activity-definition-file/

 

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;

using System.IO;

using System.Xml;

using Microsoft.BizTalk.Bam.EventObservation;

namespace BeginBAMPipeline

{

[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]

[ComponentCategory(CategoryTypes.CATID_Any)]

[System.Runtime.InteropServices.Guid(“3BB6433B-CF8D-456B-AA78-70D6788C8574”)]

public class BeginBAMPipelineComponent : IBaseComponent, IComponentUI, Microsoft.BizTalk.Component.Interop.IComponent, IPersistPropertyBag

{

#region Configuration Properties

private string _BAMActivityName;

private bool _IsTrackingRequire;

public string BAMActivityName

{

get

{

return _BAMActivityName;

}

set

{

_BAMActivityName = value;

}

}

 

public bool IsTrackingRequire

{

get

{

return _IsTrackingRequire;

}

set

{

_IsTrackingRequire = value;

}

}

 

#endregion

public string Description

{

get

{

return “Pipeline component For Begin BAM Activity”;

}

}

 

public string Name

{

get

{

return “BeginBAMPipelineComponent”;

}

}

public string Version

{

get

{

return “1.0.0.0”;

}

}

public IntPtr Icon

{

get

{

return new System.IntPtr();

}

}

public System.Collections.IEnumerator Validate(object projectSystem)

{

return null;

}

public void GetClassID(out Guid classID)

{

classID = new Guid(“3BB6433B-CF8D-456B-AA78-70D6788C8574”);

}

public void InitNew()

{

}

public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)

{

object val = null;

val = this.ReadPropertyBag(pb, “BAMActivityName”);

if ((val != null))

{

this._BAMActivityName = ((string)(val));

}

val = this.ReadPropertyBag(pb, “IsTrackingRequire”);

if ((val != null))

{

this._IsTrackingRequire = ((bool)(val));

}

}

public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)

{

this.WritePropertyBag(pb, “BAMActivityName”, this.BAMActivityName);

this.WritePropertyBag(pb, “IsTrackingRequire”, this.IsTrackingRequire);

}

#region utility functionality

/// <summary>

/// Reads property value from property bag

/// </summary>

/// <param name=”pb”>Property bag</param>

/// <param name=”propName”>Name of property</param>

/// <returns>Value of the property</returns>

private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)

{

object val = null;

try

{

pb.Read(propName, out val, 0);

}

catch (System.ArgumentException)

{

return val;

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

return val;

}

 

/// <summary>

/// Writes property values into a property bag.

/// </summary>

/// <param name=”pb”>Property bag.</param>

/// <param name=”propName”>Name of property.</param>

/// <param name=”val”>Value of property.</param>

private void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val)

{

try

{

pb.Write(propName, ref val);

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

}

#endregion

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)

{

IBaseMessagePart bodyPart = pInMsg.BodyPart;

StringBuilder outputMessageText = null;

XmlDocument xDoc = new XmlDocument();

 

string systemPropertiesNamespace = @”http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;;

//string messageType = “”;

if (bodyPart != null)

{

if (IsTrackingRequire)

{

Stream originalStream = bodyPart.GetOriginalDataStream();

 

if (originalStream != null)

{

string ActivityName = BAMActivityName;

string messageType = Convert.ToString(pInMsg.Context.Read(“MessageType”, systemPropertiesNamespace));

 

EventStream BAMes;

 

BAMes = pContext.GetEventStream();

 

string ActivityID = Guid.NewGuid().ToString();

string corelationToken = (string)pInMsg.Context.Read(“InterchangeID”, “http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;);

 

System.Diagnostics.EventLog.WriteEntry(“InterchangeIDStart”, corelationToken);

BAMes.BeginActivity(ActivityName, ActivityID);

BAMes.UpdateActivity(ActivityName, ActivityID, “MessageType”, messageType);

BAMes.UpdateActivity(ActivityName, ActivityID, “StartTime”, DateTime.Now);

 

BAMes.UpdateActivity(ActivityName, ActivityID, “Status”, “START”);

 

BAMes.EnableContinuation(ActivityName, ActivityID, corelationToken);

 

BAMes.EndActivity(ActivityName, ActivityID);

 

BAMes.Flush();

}

}

}

return pInMsg;

}

}

}

END Bam Activity:

This custom pipeline component can be used in any stage at in send pipeline.

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;

using System.IO;

using System.Xml;

using Microsoft.BizTalk.Bam.EventObservation;

 

 

namespace EndBAMPipeline

{

[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]

 

[ComponentCategory(CategoryTypes.CATID_Any)]

 

[System.Runtime.InteropServices.Guid(“3AC1B310-C4DF-4732-8AA9-2808349CEFFA”)]

public class EndBAMComponent : IBaseComponent, IComponentUI, Microsoft.BizTalk.Component.Interop.IComponent, IPersistPropertyBag

{

#region Configuration Properties

private string _BAMActivityName;

private bool _IsTrackingRequire;

 

public string BAMActivityName

{

get

{

return _BAMActivityName;

}

set

{

_BAMActivityName = value;

}

}

 

public bool IsTrackingRequire

{

get

{

return _IsTrackingRequire;

}

set

{

_IsTrackingRequire = value;

}

}

#endregion

 

#region IBaseComponent members

public string Description

{

get

{

return “Pipeline component For End BAM Activity”;

}

}

 

public string Name

{

get

{

return “EndBAMPipelineComponent”;

}

}

public string Version

{

get

{

return “1.0.0.0”;

 

}

 

}

#endregion

 

public IntPtr Icon

{

get

{

return new System.IntPtr();

 

}

}

public System.Collections.IEnumerator Validate(object projectSystem)

{

return null;

}

 

#region IPersistPropertyBag members

public void GetClassID(out Guid classID)

{

classID = new Guid(“3AC1B310-C4DF-4732-8AA9-2808349CEFFA”);

}

public void InitNew()

{

}

public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)

{

object val = null;

val = this.ReadPropertyBag(pb, “BAMActivityName”);

if ((val != null))

{

this._BAMActivityName = ((string)(val));

}

val = this.ReadPropertyBag(pb, “IsTrackingRequire”);

if ((val != null))

{

this._IsTrackingRequire = ((bool)(val));

}

}

public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)

{

this.WritePropertyBag(pb, “BAMActivityName”, this.BAMActivityName);

this.WritePropertyBag(pb, “IsTrackingRequire”, this.IsTrackingRequire);

 

}

#endregion

 

#region utility functionality

/// <summary>

/// Reads property value from property bag

/// </summary>

/// <param name=”pb”>Property bag</param>

/// <param name=”propName”>Name of property</param>

/// <returns>Value of the property</returns>

private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)

{

object val = null;

try

{

pb.Read(propName, out val, 0);

}

catch (System.ArgumentException)

{

return val;

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

return val;

}

 

/// <summary>

/// Writes property values into a property bag.

/// </summary>

/// <param name=”pb”>Property bag.</param>

/// <param name=”propName”>Name of property.</param>

/// <param name=”val”>Value of property.</param>

private void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val)

{

try

{

pb.Write(propName, ref val);

}

catch (System.Exception e)

{

throw new System.ApplicationException(e.Message);

}

}

#endregion

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)

{

IBaseMessagePart bodyPart = pInMsg.BodyPart;

StringBuilder outputMessageText = null;

string systemPropertiesNamespace = @”http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;;

if (bodyPart != null)

{

if (IsTrackingRequire)

{

Stream originalStream = bodyPart.GetOriginalDataStream();

if (originalStream != null)

{

string ActivityName = BAMActivityName;

string messageType = Convert.ToString(pInMsg.Context.Read(“MessageType”, systemPropertiesNamespace));

EventStream BAMes;

BAMes = pContext.GetEventStream();

string ActivityID = “seq_” + Guid.NewGuid().ToString();

string corelationToken = (string)pInMsg.Context.Read(“InterchangeID”, “http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;);

System.Diagnostics.EventLog.WriteEntry(“InterchangeIDEND”, corelationToken);

BAMes.UpdateActivity(ActivityName, corelationToken, “EndTime”, DateTime.Now);

BAMes.UpdateActivity(ActivityName, corelationToken, “Status”, “SUCCESS”);

BAMes.EndActivity(ActivityName, corelationToken);

BAMes.Flush();

}

}

}

return pInMsg;

}

}

}

 

You can see the BAM table or BAM Portal in one row start time and end time of message in BizTalk along with status and messagetype.

Custom Pipeline

Microsoft provides lots of feature in BizTalk Pipeline with having inbuild pipeline components. E.g. JSON Encoder, Decoder, MIME/SMIME Decoder etc.

But sometimes we need add something in context of message then we need to do customization in pipeline, BizTalk provides the facilities to customise with help of Custom pipeline. C# and VB.Net languages are basically used to write code for this.

Below are few scenarios where you need to apply Custom Pipeline

  • Conversion from another format to XML vice-versa:

As we know BizTalk has the facilities to receive file in XML, Text, csv and json (from BizTalk 2013). But if you have any other format e.g. Excel or PDF, then you need to change the format from Excel to xml because BizTalk always plays in xml format. So here in custom pipeline you can write code in C# or VB.Net form.

  • Add namespace (this facility is existed in BizTalk pipeline, when use ESB pipelines)
  • Promote message context property on custom data
  • Set dynamic send port
  • Message archiving
  • Handling large message

Click on below link for coding of  sample of custom pipeline.

https://vkbiztalk.com/category/pipeline/

Requirement To create a Custom Pipeline:

Dlls:

  • BizTalk.ExplorerOM.dll (C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\Developer Tools\Microsoft.BizTalk.ExplorerOM.dll)
  • BizTalk.Pipeline.dll (C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\Microsoft.BizTalk.Pipeline.dll)
  • BizTalk.Streaming.dll (C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\Microsoft.BizTalk.Streaming.dll)

Pipeline Interfaces:

  • IBaseComponent
  • IComponent
  • IComponentUI
  • IPersistPropertyBag
  • IAssemblerComponent
  • IDisassemblerComponent
  • IProbeMessage

IBaseComponent Interface:

Defines properties that provide basic information about the component. Below are methods used in this component.

  • Description: Describe pipeline component description.
  • Name: Define the component name.
  • Version: Define the component version.

    public interface IBaseComponent

    {

        string Description { get; }

        string Name { get; }

        string Version { get; }

    }

IComponent Interface (COM)

Defines the methods used by all pipeline components except assemblers and disassemblers.

  • Execute: Executes a pipeline component to process the input message and get the resulting message.

   public interface IComponent

    {

        IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg);

    }

IComponentUI Interface (COM)

Defines methods that enable pipeline components to be used within the Pipeline Designer environment.

  • Icon: Provides the icon that is associated with this component.
  • Validate: Verifies that all of the configuration properties are set correctly.

     public interface IComponentUI

    {

        IntPtr Icon { get; }

        IEnumerator Validate(object projectSystem);

    }

IDisassemblerComponent:

A disassembling component is a pipeline component that receives one message on input and produces zero or more messages on output. Below are two methods used in this component.

  • Disassemble: Performs the disassembling of the incoming document message.
  • GetNext: Gets the next message from the message set that resulted from disassembler execution. Returns NULL if there are no more messages.

    public interface IDisassemblerComponent

    {

        void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg);

        IBaseMessage GetNext(IPipelineContext pContext);

    }

IAssemblerComponent

An assembling component is a pipeline component that receives several messages on input and produces one message on output. Assembling components are used to collect individual documents into the message interchange batch.

  • AddDocument: Adds the document message to the list of messages that will be included in the interchange.
  • Assemble: Builds the interchange from the messages that were added by the previous method. Returns a pointer to the assembled message.

     public interface IAssemblerComponent

    {

        void AddDocument(IPipelineContext pContext, IBaseMessage pInMsg);

        IBaseMessage Assemble(IPipelineContext pContext);

    }

IProb Message:

Defines the methods and properties for components that need probing functionality. Any pipeline component (general, assembling, or disassembling) can implement the IProbeMessage interface if it must support message probing functionality. A probing component is used in the pipeline stages that have FirstMatch execution mode. The IProbeMessage interface exposes a single method, Probe, which enables the component to check the beginning part of the message. The return value determines whether this component is run.

    public interface IProbeMessage

    {

        bool Probe(IPipelineContext pContext, IBaseMessage pInMsg);

    }

IPersistPropertiesBag Component:

Defines the methods to prepare for, load, and save the properties of pipeline components during design time.

This is responsible for getting the design time properties. If you need to have some properties be set during design time or during the deployment stage, you must add the loading and saving functionalities for those properties.

    public interface IPersistPropertyBag

    {

        void GetClassID(out Guid classID);

        void InitNew();

        void Load(IPropertyBag propertyBag, int errorLog);

        void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties);

    }

Custom pipeline Components:

You can create three types of pipeline components:

  • General: This component can be fit at any stage of Receive and Send pipeline,
  • Assembling: This component can only fit at assemble stage of Send Pipeline
  • Disassembling; This component can only fit at Disassemble stage of Receive Pipeline

Developing a General Pipeline Component

A general pipeline component is a .NET or COM component that implements the following interfaces:

 Developing an Assembling Pipeline Component

An assembling component must implement the following interfaces:

  • IBaseComponent
  • IAssemblerComponent
  • IComponentUI
  • IPersistPropertyBag

Developing a Disassembling Pipeline Component

 A disassembling pipeline component receives one message on input and produces zero or more messages on output. Disassembling components are used to split interchanges of messages into individual documents. Disassembler components must implement the following interfaces:

  • IBaseComponent
  • IDisassemblerComponent
  • IComponentUI
  • IPersistPropertyBag

 

For more Details please refer below post:

https://vkbiztalk.com/category/pipeline/