Tenalinaga's Blog

I am frog in a well. Every time I jump out of the well; I relialize I am in bigger well and eventually get bored which motivates me to get to next level.

Category Archives: ESB

Create a Custom Itinerary Service for Calling BRE Rules (To get sensitive data from SSO for instance)

Custom Itinerary Class

I came accross a question at msdnWCF Custom Binding Credentials required BRE but have to be stored in SSO ? forums how to call Business Rules Engine (Microsoft offcourse!!) from Itineraries, which seemed straight.

It become intersting when questioner wanted to pass the object reference or database reference. Itineraries would let you use the Message (by setting useMsg, recoginze format to true) but not have option to pass parametrs.

Changing regsitry setting (including D-Word of StaticSupport = 1 or 2) and ESB extensions are the proposed solutions which might work. I tried the first and I am not sucessful.

So I came accross this Custom Itinerary feature some time back, and decided to use it. This class would help you solve similar problems or places where you need to write (C#) some code.

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

using Microsoft.BizTalk.Message.Interop;
using Microsoft.BizTalk.Component.Interop;

namespace CustomItineraryServicePipelineComponent
class CustomPipelineItineraryService:Microsoft.Practices.ESB.Itinerary.IMessagingService

public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext context, Microsoft.BizTalk.Message.Interop.IBaseMessage msg, string resolverString, Microsoft.Practices.ESB.Itinerary.IItineraryStep step)

System.Diagnostics.Debug.WriteLine(“\nInside Execute Method\n”);

if (context == null)
throw new ArgumentNullException(“context”);
if (msg == null)
throw new ArgumentNullException(“msg”);
if (string.IsNullOrEmpty(resolverString))
throw new ArgumentException(“Properties.Resources.ArgumentStringRequired”, “resolverString”);

System.Diagnostics.Debug.WriteLine(“Parametrs Received Corretly”);

// Try Starts here
Microsoft.Practices.ESB.Resolver.ResolverInfo _info = Microsoft.Practices.ESB.Resolver.ResolverMgr.GetResolverInfo(Microsoft.Practices.ESB.Resolver.ResolutionType.Endpoint, resolverString);
if (!_info.Success)
throw new ArgumentException(“Properties.Resources.Failed to aquire ResolverInfo”, “resolverString”);

// System.Diagnostics.Debug.WriteLine(“Got Resolver into and about to get Resolver Dicitinary”);

//Microsoft.Practices.ESB.Resolver.ResolverDictionary _Dictionary = new Microsoft.Practices.ESB.Resolver.ResolverDictionary _Dictionary();
Dictionary _Dictionary = Microsoft.Practices.ESB.Resolver.ResolverMgr.Resolve(_info, msg, context);

// System.Diagnostics.Debug.WriteLine(_Dictionary.Count().ToString());

// List _list = new List (_Dictionary.Keys);

// foreach (string _k in _list)
// {
// System.Diagnostics.Debug.WriteLine(_k, _Dictionary[_k]);
// }

Microsoft.Practices.ESB.Adapter.AdapterMgr.SetEndpoint(_Dictionary, msg.Context);
System.Diagnostics.Debug.WriteLine(“Endpoints Set”);

string _TransportLocation = “”;
string _UserName = “”;
string _Password = “”;

System.Diagnostics.Debug.WriteLine(“Get SSO Information”);

_TransportLocation = Microsoft.SSO.Utility.SSOConfigHelper.Read(“Naga”, “OracleTransportLocation”);
_UserName = Microsoft.SSO.Utility.SSOConfigHelper.Read(“Naga”, “OracleWCFUserName”);
_Password = Microsoft.SSO.Utility.SSOConfigHelper.Read(“Naga”, “OracleWCFPassword”);

System.Diagnostics.Debug.WriteLine(“itinerary TransportLocation” + _TransportLocation);
System.Diagnostics.Debug.WriteLine(“itinerary UserName” + _UserName);
System.Diagnostics.Debug.WriteLine(“itinerary Password” + _Password);
System.Diagnostics.Debug.WriteLine(“Error fetching SSO information”);
throw new System.ApplicationException(“Error”);

System.Diagnostics.Debug.WriteLine(“Promote Properties”);
msg.Context.Promote(“OutboundTransportLocation”, “http://schemas.microsoft.com/BizTalk/2003/system-properties”, _TransportLocation);
msg.Context.Promote(“UserName”, “http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties”, _UserName);
msg.Context.Promote(“Password”, “http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties”, _Password);
return msg;

public string Name
get { return “CustomPipelineItineraryService”; }

public bool ShouldAdvanceStep(Microsoft.Practices.ESB.Itinerary.IItineraryStep step, IBaseMessage msg)
return true;

public bool SupportsDisassemble
get { return true; }

Resolver I used is BRE for getting endpoints. Which would look like.

Import things to notice are Transport Location, UserName & Password (these are part of set “Set End Point Config to” in BRE) are set to “GetFromSSO” which is a string, that gets overwritten by content obtained from SSO in the class.


Check the link to development of Custom Itinerary Messaging Service for better documentation.

Set End Point Config to BindingType=oracleDBBinding&BindingConfiguration=&EndpointBehaviorConfiguration=

Multi-record Insertion into Oracle DB using ESB Messaging Scenario

Multi-Record Insertation into any table within Oracle DB using ESB Messaging Scenario based on Message Type

Idea of this sample seems to pretty be intersting when I first thought about it. we are originally thinking more in lines of having seprate WCF service to inert into each table and Main Orchestration having to call sepecific WCF service dynamically. These services need individual orchestration to published as WCF service.

But here Idea is to develop one single service which can be consumed by generic orchestration which accepts XMLDocument type. Input XMLDocuments would be one among set of defiend schemas that hold data that should be inserted to corresponding tables. We achive this WCF service with out orchestration (just messaging senario) using Itineraries.

Step1: Creation of 2 test Oracle Tables

For Demonstration I created 2 tables in HR database.  I want to insert into any of the 2 tables based on the incoming schema.

Oracle Test Tables


 Step2: Creation of Schemas and Maps

using Consume Adapter Service -> OracleDBBinding I have generated  Request schemas for table insert operation. Generated schema structure for “TABTESTPRODCUTS” and “TABTESTSTORES” table is shown side by side.

Oracle Insert Schemas

I want service response to be in "standard normalized manner". Standard response schema to notify sucess/failure is below

Normalized Response

So I developed schema and maps for Oracle Insert response form oracleDB to normalized schema. 2 map are below.

Oracle Insert Schemas

I also created 2 schemas (Original Data Schemas) which has data that should be inserted into oracleDB. (In a genralized sense these can be defined set of defined schemas that hold data for corresponding tables in OracleDB)

Native Data Schemas

Then I created maps to map Original Data Schemas to oracle request schemas.

Maps To Request Schema

Step3: Creation of WCF Service Receive Port and Dynamic soilict-response Port

We proceed to cretate a WCF service using WCF schema publishing Wizard and create a receive location. Input Schema is of type “Microsoft.XLANGs.BaseTypes.Any” and Output response schema is standard normalized response. Configure Receive Location is shown below

WCF Service Receive Port

ItinerarySelectReceiveXML has itinerary selector component that can select the itinerary. we use Resolver.Itinerary" to fetch itinerary from Database. Itinerary we are about to develop in next steps is named "GenricOracleInsert". We also create a Dynamic Solicit Response port and provide configuation as shown below

Dynamic Solicit Respone Port

Step4: Creating BRE Polcies

We will need to create 3 BRE policies.

1) First one to Select the Map based on the incoming message type for the input schema.

 BRE Request Map

2) Second Policy To Set the OutBound Transport End Points

BRE Request Map

3) Thrid Policy to set the Map to normalize response to Standard Reponse.

 BRE Request Map

Step5: Itinerary Design

Now we have all the required artifact. we need deploy them in BT application. Then we can proceed with Itinerary Design

Itinerary is like routing slip and steps associated are shown below.

based on messagetypes BRE policy provide information to perform dynamic routing and transofrmations.


 Itinerary Design

Step6: Generic InBound Test Orchestration

Generic Inbound Test Orchestration

We now create a test orchestration to test the WCF service we create. This genric orchestration accepts valid XMLDocuments as input.

Typically incoming XMLDocuments are validated by the receive XMLdisassembler pipeline component and subscribed by the orchestration.

Then we route defined Orginal Data schemas to the WCF service (remember WCF service input schema is also generic which accepts any valid XMLDocuments).

Then baed on BRE policies it gets transformed, and Outbound transport context properties are set and subscribed by dynamic solicit response port.
On the response from solicit-response port we choose a map based on policy in BRE to get normalized response.

Generic Test Orchestration for the WCF service would look like.

Itinerary Design

ESB Static and Dynamic Resoultion and Itineraries

Itineraries” when I first heard this term it made no sense to my BizTalk brain. With in Short time I had to come Face to Face with ESB (Enterprise Service Bus) for one of my clients who want to implement SOA (Service Oriented Architecture) and also Error Handling using ESB Portal. There is lot of learning curve and it looked scary. I tried to propose alternatives to solve the problem due to short development time before us but pros clearly outweighed cons. That is when, I determined to make some progress with ESB and started to take a look at it and learn features of ESB.

This post explains the Messaging scenarios using
A) Dynamic Resolution for one way WCF service call
B) With Itineraries (UDDI Resolver) Dynamic Resolution for one way WCF service call
C) With Itineraries (BRE and Static Resolver) Dynamic Resolution for Two way WCF service call and Subsequent forwarding

Part 1: Creating WCF Services
Before entering into doing ESB features we first need to have some services up to route message to them. So I developed Orchestration A and Orchestration B.
Orch A has One Way receive Port has shown in fig below. Output is published to message box and there is a send port in the application that subscribes to this message type from Message box then routes it to output destination folder.


Orch B has Request response Port has show in fig below. This orchestration receives message and send response back.


I published two orchestrations as WCF services (OrchA is a one way receive port and OrchB is Two-way req-resp receive port) and allowed WCF service to create Receive ports in my BizTalk application named SNR.Mamata.CommonArtifacts. Associated orchestration bindings to these receive ports.
So Here we have created 2 WCF Services one is one way other is req-resp. So we will use these services to develop Messaging scenarios using ESB core features.

Part-2 : ESB Implementation

A) Dynamic Resolution for one way WCF service call
I have created a new BizTalk Application SNR.Mamata.DynamicResoultion. Here I am trying to implement a messaging scenario to call one way WCF service. I want to pick up a .xml file from Receive Location in File System.

Custom Pipeline has just one ESB pipeline component “ESBDispatcher”. This component figures out the end point configuration using BRE, Static, UDDI …

Here I used BRE to configure endpoint information by calling a policy.

BRE policy is shown below. condition 1 equals 1 always evaluates to true so end point transport type, target namespace, WCF action, outbound transport location is set. you could also have BRE by evaluating any context properties.

Now I created a create a Dynamic send port that subscribes to this message by receive port name (BTS.ReceivePortName). For now do not worry about other Filter expressions(Not related to this scenarioA). Those are used later and will be explained in the below part.

What did we Just do:
When message is received from Receive port Custom Pipeline with ESB dispatcher calls BRE and gets the outbound end point configuration details. The send port subscribes to these messages and send this message to the transport location using protocol specified.
This need not always be BRE, it can be UDDI or Even Static
Static resolver looks like

B) With Itineraries (UDDI Resolver) Dynamic Resolution for one way WCF service call
Here we will do the same with help of Itinerary. In the Dynamic send port add the remaining filter expressions (Hold on I Shall explain what they are below)
We also create a new receive port and location to pick up .xml message from File location. We now use ESB Itinerary selector pipeline component which is available in “Itineraryselectreceivexml pipeline” or your own custom pipeline.

Itinerary Key fact Resolver.Itinerary indicates thats Itinerary is avilable from SQL server Database with name UDDIItinerary.

To develop UDDIItinerary first create a C# class library then create a new itinerary. Drag on Ramp and off ramps. and two Itinerary services. There should be off-ramp extender before OffRamp.

OnRamp: select the Extender and BizTalk application and Receive Port Name.

ItineraryService1: select the container and Itinerary service name (Routing/Transformation) Routing in our case.
Resolver: Add new Resolver and select UDDI resolver component.
Within the First Itinerary service we have add new resolver and select UDDI in resolver implementation. It be any one of the available. Binding key can be used to resolve the end point information.

Off Ramp: Select the dynamic send port that promotes your filter expression values to the message context properties so your dynamic send port can subscribe the message.

c) With Itineraries (BRE and Static Resolver) Dynamic Resolution for Two way WCF service call and Subsequent forwarding
In this example we extend the same above Itinerary. We create pick up the .xml from the file location and call the request-response web service then route the message to other dynamic send port that drop the message to the file location.

I have used BRE for path resolution. Choosing BRE resolver implementation would let you select the BRE policy and version.

Below is the ploicy created using BRE.

We also used static resolver to route the response from WCF service to the file location.

We need to create two dynamic ports. one is Req-Resp port to make a call to 2-way WCF Service. It uses ItinerarysendPassThrough Pipeline which has ESB Itinerary Cache and preserves the state of the itinerary. Upon the response from WCF service Itinerary again starts getting executed from that point.
with filter expersions as below
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceName == DynamicReqResp And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceState == Pending And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceType == Messaging And
Microsoft.Practices.ESB.Itinerary.Schemas.IsRequestResponse == True

Upon receiving response ItineraryFrowarderSendReceive Pipeline Component evaluates static resolver and contiunethe itinerary. It has filter expersion as below
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceName == DynamicCacheSendService And Microsoft.Practices.ESB.Itinerary.Schemas.ServiceState == Pending And
Microsoft.Practices.ESB.Itinerary.Schemas.ServiceType == Messaging And
Microsoft.Practices.ESB.Itinerary.Schemas.IsRequestResponse == False

ESB Dynamic Gudiance inside orchestration is avilable in the lnk



BizTalk 2010 ESB 2.1 Installation

1) Install InfoPath 2003/2007 used to render exceptions details.
2) Install enterprise library 4.1 used by ESB Management portal
3) Make sure default web site is running in ASP.NET 2.0
4) Install Dundas Chart for ASP.NET Enterprise (*)
5) Install BizTalk ESB Toolkit 2.1-x64
6) Install Itinerary Designer from ALL Programs -> ESB Itinerary Designer.
7) Configure ESB Configure Tool (Have to configure step after step)
Above step creates the Databases and web services ..
In BizTalk Administrative console create an application with Microsoft.BizTalk.ESB and import the MSI file that suites your Platform and also install it.
9) Run the UDDI Publisher Tool available at %ESB Install Folder%\Bin\Microsoft.Practices.ESB.UDDIPublisher.exe this will add the t-models and services.
(Make sure that Microsoft UDDI Services does not require Secure Sockets Layer (SSL) for publication to the UDDI Services site)
10) Depoly BAM Tracking
>>Bm.exe deploy-all -DefinitionFile:”C:\Program Files\Microsoft BizTalk ESB Toolkit 2.1\Bam\Microsoft.BizTalk.ESB.BAM.Itinerary.xml”
>>Bm.exe deploy-all -DefinitionFile:”C:\Program Files\Microsoft BizTalk ESB Toolkit 2.1\Bam\Microsoft.BizTalk.ESB.BAM.Exceptions.xml”
11) Add switch to system.diagnostics to enable Biztalk ESB tool kit trace switch.
12) Create a c -> Project -> Microsoft.Practices.ESB folder and unzip the ESB source into 1st folder
13) Remove Read only from the properties of the folder.
14) Run the following command in the powershell to have unrestricted access
set-executionpolicy unrestricted (Host Machine)
Set-ExecutionPolicy -scope process Unrestricted (VM Machine gives ability to execute scripts for current process)
15) Check to see if the services are up and running in IIS.
16) Created a Microsoft.Practices.ESB.Key in the C:\projects\Microsoft.Practices.ESB\ESBSource\Keys floder
17) Changed one line to reflect correct path in Management_Install.ps1 $env:VS=”${env:ProgramFiles} (x86) \Microsoft Visual Studio 10.0\Common7\IDE”
18) Install the Mangment_Install.ps1 script (This will create the ESB.Portal Web Application)
19) Set connection strings database in web.config file and check if the .asmx and .svc services are up in running
20) This is third time I having problem with GetApplications() in PortalHelper.cs class with BizTalk Operations Service. I modified the code to below.
21) Restart IIS , I have my portal up in running (with Biztalk Operations service not working)
Error 1:
Management_Install.ps1 cannot be loaded because the execution of the scripts is disabled on this system. Please see the “get-help about_signing” for more details
At line:1 char:25
‘ .\Management_Install.ps1 << run this before installing portal (Management_Install.cmd) Make sure WCF scriptmaps are registered by executing the command
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>ServiceModelReg.exe -r -y
=> aspnet_regiis –irv registers the version of .NET to be used for IIS.



Missing Pipeline Components

ESB Installation in Better organsized manner