Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2010 Recipes : Orchestrations - Calling External Assemblies

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
4/9/2011 4:51:09 PM

1. Problem

You need to call a method contained in a .NET class library assembly. You want to understand how to reference this assembly within your BizTalk project and how to call it from an Expression shape.

2. Solution

This solution will walk you through referencing an external assembly and calling the assembly from code within an Expression shape. Assume that the assembly is called SampleClass.dll, which contains a class called Helper. The Helper class has a function to set a string of characters to uppercase, as shown in Listing 1.

Example 1. Sample C# Assembly
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SampleClass
{
[Serializable]
public class SampleClass
{
public string strToUpperCase(string input)
{
input = input.ToUpper();
return input;
}
}
}

Once the C# assembly has been built and the DLL is available, use the following steps to reference the assembly.

  1. Open a BizTalk project in Visual Studio.

  2. In the Solution Explorer, right-click References under the project header, and select Add Reference.

  3. In the Add Reference dialog box, click the Browse tab, find the SampleClass.dll assembly, and then click OK.

  4. Now that the assembly is available in the BizTalk project, create a new orchestration variable. With an orchestration open, click the Orchestration View window. Right-click the Variables folder, and select New Variable from the drop-down menu.

  5. In the Properties window of the variable, set the following properties (see Figure 1):

    • Name the variable objSample.

    • Add a description, such as Demonstration Object.

    • Specify the variable's .NET type by clicking the drop-down box for the Type property and selecting <.NET Class>. In the Select Artifact Type dialog box, select the SampleClass class, as shown in Figure 2.

    Figure 1. Variable Properties window
    Figure 2. Selecting the artifact type
  6. Drop an Expression shape in the orchestration, and enter the following code to invoke the external assembly, as shown in Figure 3.

Figure 3. Adding code to the Expression shape

3. How It Works

When creating a .NET class variable in BizTalk, an option exists to Use Default Constructor. This property causes an instance of the object to be constructed when the orchestration instantiates. If this property is set to False, the variable will need to be instantiated in an Expression shape through the new keyword (as in step 6 of the solution).

Another property that should be noted is on the referenced assembly itself: Copy Local. This property indicates whether the assembly referenced should be copied into the local bin directory when a project is built. Several factors will help decide whether the assembly should be copied locally; if a reference is to a dynamic assembly (such as another BizTalk project that is built at the same time as the project in which it is referenced), you probably will not want to copy the assembly locally.

It is important to note that when calling a .NET assembly that is not marked as serializable, it must be called from an atomic scope. When creating an assembly that will be used primarily by BizTalk, it is appropriate to mark all classes as serializable. The following example demonstrates doing this in C#.

[Serializable]
public class Example { }
Other -----------------
- BizTalk 2010 Recipes : Orchestrations - Receiving Multiple Message Formats in a Single Orchestration
- BizTalk 2010 Recipes : Orchestrations - Creating Branching Logic in an Orchestration
- SharePoint 2010 PerformancePoint Services : Examining Show Details Reports
- SharePoint 2010 PerformancePoint Services : Examining Decomposition Tree Reports
- SharePoint 2010 PerformancePoint Services : Reports - Strategy Map
- Windows Server 2008 R2 : Installing DFS (part 2) - Creating a DFS Folder and Replication Group & Configuring DFS Read-Only Replication
- Windows Server 2008 R2 : Installing DFS (part 1) - Creating the DFS Namespace and Root & Adding an Additional Namespace Server to a Domain-Based Namespace
- Windows Server 2008 R2 : File System Management and Fault Tolerance - Planning a DFS Deployment
- Windows Server 2008 R2 : File System Management and Fault Tolerance - The Distributed File System
- Windows Server 2003 : Creating Role-Specific Server Configurations (part 2) - Securing Infrastructure Servers & Securing File and Print Servers
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
programming4us
Natural Miscarriage
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer