Calling External Assemblies From Maps in BizTalk

Introduction

In this article, I will cover how to call external assemblies from maps in BizTalk through a simple example of an external assembly which implements the logic of string concatenation. This is a common scenario when the business logic is contained in an assembly and we want to reuse it not having to write the code twice.

Getting started with the solution

First of all, open Visual Studio .NET and create an empty solution. Then add an Empty Biztalk Server project (see Figure 1) and a Class Library project (see Figure 2) to the solution.

figure1.gif

Figure 1

figure2.gif

Figure 2

Then add the concatenation class to the Class Library project and implement the underlying business logic (see Listing 1).

using
System;
using System.Collections.Generic;
using System.Text;

namespace ExternalAssembly

{

    public class Concatenation

    {

        public string Concat(string strParam1, string strParam2)

        {

            return strParam1 + strParam2;

        }

    }
}

Listing 1

Add a strong name file to the project, then compile the assembly and add it to the Global Assembly Cache (GAC) using gacutil tool in order to be correctly referenced by BizTalk maps.

Now let's create two schemas which are the basis of the transformation. The first one represents the input parameters (see Figure 3) and the other one represents the output parameter (see Figure 4).

figure3.gif

Figure 3

figure4.gif

Figure 4

Now let's move to the BizTalk project and add a reference to the previously created assembly (see Figure 5).

figure5.gif

Figure 5

Now let's add a map representing the concatenation transformation. Set the source and destination schemas. Click on the Toolbox window, and then click on the Advanced Functoids tab, and drag and drop the Scripting functoid onto the map surface. This functoid's input and output values are dependent of the logic contained within the Scripting functoid. Connect the left side of Scripting functoid to the appropriate source data items as well as the right side to the destination data items (see Figure 6).

figure6.gif
 
Figure 6

Now let's configure the Scripting functoid by right-click over it and selecting Configure Functoid Script option (see Figure 7).

figure7.gif
 
Figure 7

When the Configure Functoid Script dialog is displayed, select External Assembly for Script Type. Set the ExternalAssembly assembly for the Script assembly, ExternalAssembly.Concatenation for the Scrip class and Concat for the Script method (see Figure 8).

figure8.gif
 
Figure 8

Conclusion

In this article, I covered how to call external assemblies from maps in BizTalk. Now you can apply this solution to your business scenario.


Similar Articles