Sunday, 28 December 2014

Enable logging in ESB toolkit

 Add switches in your machine.config file. and use debug view for custom logging
          <add name="BizTalkESBToolkit2.2" value="4"/>

Friday, 26 December 2014

String to XLangMessage in BizTalk

Create an XLangMessage from a string. Do keep in mind, that you have to pass in valid XML message text.

public static XLANGMessage CreateXLANGMessageFromString(string xmlMessage, string messagePart1Name, string messagePart2Name, string messagePart3Name)
    // Create a VirtualStream for memory optimization
    int bufferSize = 640;
    int thresholdSize = 1048576; // 1MB
    var stream = new VirtualStream(bufferSize, thresholdSize);
    // Make sure booleans are in lowercase
    xmlMessage = xmlMessage.Replace("False", "false").Replace("True", "true");
    // The name of the root node
    var rootNodeName = String.Empty;
    // Create a reader which will be used to read through the message
    using (var reader = new XmlTextReader(new StringReader(xmlMessage)))
        // Create a writer used to write the outgoing message
        using (var writer = XmlWriter.Create(stream, new XmlWriterSettings { ConformanceLevel = ConformanceLevel.Auto, Encoding = Encoding.UTF8 }))
            // Boolean indicating if the root node name has been set
            var rootNodeNameSet = false;

            // Read through the message
            while (reader.Read())
                // Check if we need to set the root node name here
                if (!rootNodeNameSet && reader.NodeType == XmlNodeType.Element)
                    // Set the root node name
                    rootNodeName = reader.LocalName;
                    rootNodeNameSet = true;

                // Write the current element
                ProcessMessage.WriteShallowNode(reader, writer);

    // Reset the stream
    stream.Seek(0, SeekOrigin.Begin);

    // Create a CustomBTXMessage, which will be used to create our XLANGMessage
    var customBTXMessage = new CustomBTXMessage(rootNodeName, Service.RootService.XlangStore.OwningContext);

    // Add message part
    customBTXMessage.AddPart(String.Empty, messagePart1Name);

    // Load the message we just created

    // Add extra message parts if needed
    if (!String.IsNullOrWhiteSpace(messagePart2Name))
        // Add message part
        customBTXMessage.AddPart(String.Empty, messagePart2Name);

    // Add extra message parts if needed
    if (!String.IsNullOrWhiteSpace(messagePart3Name))
        // Add message part
        customBTXMessage.AddPart(String.Empty, messagePart3Name);

    // Return the XLANGMessage
    return customBTXMessage.GetMessageWrapperForUserCode();

make sure you have the following using statements in your class:

using Microsoft.BizTalk.Streaming;
using Microsoft.XLANGs.BaseTypes;
using Microsoft.XLANGs.Core;

Custom BTX class

using Microsoft.BizTalk.XLANGs.BTXEngine;
using System;
using Microsoft.XLANGs.Core;

namespace DynaLean.CoreHelpers
    public sealed class CustomBTXMessage : BTXMessage
        public CustomBTXMessage(string messageName, Context context)
            : base(messageName, context)

Validating Email Address inside Orchestration

 Simple Expression can validate your email address inside orchestration
boolIsmail  = System.Text.RegularExpressions.Regex.IsMatch(strmail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z",System.Text.RegularExpressions.RegexOptions.IgnoreCase );

Wednesday, 24 December 2014

Send Port and Host instance Mapping in BizTalk

Here below code will give list of send ports available  with BizTalk without mapping details . best way to query against the Management DB tables to find out the mapping between send Port and the host instance

select sndport.nvcName as 'HostInstaceSendPort',
hostInstace.Name as 'HostInstanceName' ,hostInstace.LastUsedLogon as 'loginUser' ,
hostInstace.DateModified as 'DateofCreation'from
dbo.bts_SendPort sndport inner join
dbo.bts_sendport_transport SndPorttransport
on ((sndport.nID = SndPorttransport.nSendPortID) and (SndPorttransport.nSendHandlerID is not null))
inner join
dbo.adm_SendHandler SndHandler
on SndPorttransport.nSendHandlerID = SndHandler.Id
inner join
dbo.adm_Host hostInstace
on SndHandler.HostId = hostInstace.Id

Install Exception Management Portal for BizTalk 2013 ESB Toolkit

Here are the steps to install the Management Portal for ESB Toolkit 2.2 that ships with BizTalk 2013.
 After the ESB Toolkit has been installed and configured:

  • Unzip C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit\ file into the C:\Projects\Microsoft.Practices.ESB folder
  •     Remove Read-only attribute from all files in C:\Projects\Microsoft.Practices.ESB folder.
  •     Download and install Enterprise Library 5.0 from
  •     Download and install Microsoft Report Viewer Redistributable 2008  from
  •     In Visual Studio 2012, open ESB.Portal.sln found in C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\ESB.Portal
  •     When Visual Studio 2012 starts converting the solution to the current format, a dialog pops up that warns you about ESB.Portal.Setup.vdproj file not being supported in Visual Studio 2012. Click OK. Wait until the solution opens.
  •     In the Solution Explorer add Microsoft.Practices.ServiceLocation.dll as a reference to the ESB.BAM.Service.Implementation project. This assembly is found in C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin
  •     Open web.config file found in ESB.Portal project and remove (or comment out) "scripting" sectionGroup declaration that starts at line 12 and ends at line 20.
  •     Save all files in the solution.
  •     Rebuild ESB.Portal solution.
  •     Close Visual Studio.
  •     Run Management_Install.cmd file found in C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management Portal\Install\Scripts
Thats all  :)

Biztalk Adapter Pack Eval license uninstall, install licensed version check

 check Machine.config file to validate all binding information are correctly populated.(found at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config)

<add name="sqlBinding" type="Microsoft.Adapters.Sql.SqlAdapterBindingCollectionElement, Microsoft.Adapters.Sql, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="sapBinding" type="Microsoft.Adapters.SAP.SAPAdapterBindingSection, Microsoft.Adapters.SAP, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="oracleDBBinding" type="Microsoft.Adapters.OracleDB.OracleDBAdapterBindingSection, Microsoft.Adapters.OracleDB, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="siebelBinding" type="Microsoft.Adapters.Siebel.SiebelAdapterBindingSection, Microsoft.Adapters.Siebel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="oracleEBSBinding" type="Microsoft.Adapters.OracleEBS.OracleEBSBindingCollectionElement, Microsoft.Adapters.OracleEBS, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<endpoint binding="sqlBinding" contract="IMetadataExchange" name="mssql" />
<endpoint binding="sapBinding" contract="IMetadataExchange" name="sap" />
<endpoint binding="oracleDBBinding" contract="IMetadataExchange" name="oracledb" />
<endpoint binding="siebelBinding" contract="IMetadataExchange" name="siebel" />
<endpoint binding="oracleEBSBinding" contract="IMetadataExchange" name="oracleebs" />