BizTalk Orchestration Debugging

We can Debug the BizTalk Orchestrations using Orchestration Debugger or EventLogs.

Orchestration Debugger

  1. Create BizTalk application using Orchestration, Build and Deploy.
  2. Test the BizTalk application using File Drops/ SoapUI/PostMan
  3. Go to BizTalk Admin console and Click on BizTalk Group then Click on Tracked Service Instances
  4. Right click on Orchestration instance and click on Orchestration Debugger.

4.png

5. You can see two panels, left side panel is for Tracked Events and right side panel is for Orchestration.

5.png

 

6. In right side panel, right click on Receive shape and select “Set Breakpoint on Class F9”.

6.png

7. You can see break point is inserted on Receive shape, same way you can keep break points on required orchestration shapes.

7.png

8. Close the Orchestration instance.

9. Now repeat the step 2 above (Test the application)

10. Go to BizTalk Admin console and Click on BizTalk Group and then Click on Tracked Service Instances

11. You can see Orchestration instance with state “Started

11.png

12. Right click on Orchestration instance and click on Orchestration Debugger.

13. Now we need to attach the Orchestration instance to break points, for that we need to hold on Ctrl key and press the letter A (Ctrl+A)

13.png

14. You can see Receive shape of the orchestration with Yellow color highlighted.

15. In order to move the control from one shape to another shape, you need to hold Ctrl button and press the letter ‘G’ (Ctrl+G)

15.png

16. Now you can see Receive shape properties in left panel bottom side, if you click on particular message or variable, you can see the result of that shape in right side below.

In the below screenshot, InputMsg is the message type assigned to Receive shape of the orchestration and result you can see in right side windows PartType and PartValue.

16.png

17. Same way you can see the result of all the orchestration shapes which are having break points.

17.png

Note: Once you are done with orchestration debugging, please remove all break points from Orchestration debugger.

EventLogs:

Using below statement in BizTalk expression shape, we can write the messages or variable values to event viewer.

System.Diagnostics.EventLog.WriteEntry(“EventName”,”Value”);

Using below code in BizTalk expression shape, we can write the orchestration input message to event viewer.

varXmlDoc = InputMsg;

System.Diagnostics.EventLog.WriteEntry(“InputMsgData”,varXmlDoc.OuterXml);

//InputMsg is the message type of the Orchestration Receive shape

//varXmlDoc is the variable of the type System.xml.xmldocument.

Event1.png

 

 

How to open Event Viewer?

Click on Windows StartàClick on Run

Event2.png

 

Event3.png

Double click on InputMsgData to view the message data.

Event4.png

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

Using Dictionary for BizTalk Instances

Sometimes in BizTalk, we may need to use Dictionary for checking various conditions for multiple messages/Records of the same BizTalk Instance. This can be achieved using Dictionary ThreadStaticAttribute.

Requirement: My BizTalk Orchestration accepts envelop message (Multiple records), I need to loop through each record and insert the data in sql table. Here the condition is I should not insert duplicate records in the table as my envelope message might have duplicate records. So, in orchestration before sql insert, I need to check whether the record is already inserted.

This requirement can be achieved using Dictionary ThreadStaticAttribute.

ThreadStatic variable is scoped to the current thread that is being processed.

We need to call a .net component from BizTalk expression shape by sending Key and Value pair as input parameters.

 

Dictionary.png

 

//SampleLookup is variable name which points to the class “LookUpHelper”

//Lookup is the name of the method which is accepting two parameters.

// lookupResult is Boolen variable.

//Key, Value is some unique identification for the record, example PolicyId/BrokerId…

 

Below .net component has a method “Lookup” which accepts two input parameters and return Boolean.

  • If the record exists in Dictionary, method will return “true”.
  • If the record doesn’t exist in Dictionary, method will insert the data into Dictionary and return “false”.
  • In Orchestration, If the method return value is “true”, you can skip sql insertion.
  • If the method return value is “false”, you can proceed for sql insertion.

You need to call the lookup method for each record in loop shape.

//.Net Code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace SampleNamespace

{

    [Serializable]

    public class LookUpHelper

    {

        //Create Dictionary

        [System.ThreadStaticAttribute]

        private static System.Collections.Generic.Dictionary<string, string> _data = new System.Collections.Generic.Dictionary<string, string>();

        public static System.Collections.Generic.Dictionary<string, string> Data

        {

            get

            {

                if (_data == null)

                {

                    _data = new System.Collections.Generic.Dictionary<string, string>();

                }

                return _data;

            }

            set

            {

                _data = value;

            }

        }

            /// <summary>

        /// Method to check if the value is already present and if not, store the value in dictionary against a key

        /// </summary>

        /// <param name=”key”>key</param>

        /// <param name=”value”>value</param>

        public Boolean Lookup(string key, string value)

        {

            if (Data.ContainsKey(key))

            {              

                return true;

            }

            else

            {               

                Data.Add(key, value);

                return false;

            }

        }

    }

}

BizTalk Supporting Tools

There are available several BizTalk supporting tool available which will helpful for developing, Support and performance optimization on BizTalk applications. Below are some important supporting tools and their download locations.

1. BTDF (BizTalk deployment Framework)

BizTalk Deployment Framework is a third-party tool used to automate the BizTalk deployment process. Main advantage of using this tool is to generate the bindings automatically for various environments. We create msi file in local environment by following BTDF steps and deploy the msi in target machine by selecting appropriate binding file in the deployment wizard.

You can download this tool from below reference.

https://marketplace.visualstudio.com/items?itemName=DeployFxForBizTalkTeam.DeploymentFrameworkforBizTalkToolsforVS2015

https://marketplace.visualstudio.com/items?itemName=DeployFxForBizTalkTeam.DeploymentFrameworkforBizTalk

https://github.com/BTDF/DeploymentFramework

Top Reasons to Use the Deployment Framework for BizTalk

  • Deploy a complex solution containing orchestrations, schemas, maps, rules, custom components, pipeline components, pipelines — even ESB itineraries — in minutes, with no human intervention
  • Eliminate manual steps in your BizTalk deployments
  • Consolidate all your environment-specific configuration and runtime settings into one, easy-to-use Excel spreadsheet
  • Maintain a single binding file that works for all deployment environments
  • Make automated deployment a native part of the BizTalk development cycle, then use the same script to deploy to your servers
  • Use your build server to produce ready-to-deploy MSI installer

2. BizTalkHealthMonitor:

BizTalk health monitoring tool is available from BizTalk 2013 R2 and above version. This tool is exist in C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\SDK\Utilities\Support Tools location. When you install the BizTalk Server.

This tool helps you easily monitor the health of your BizTalk environment. BHM is based on the same engine as MBV. This snap-in can be added to the existing BizTalk Administration Console or can be run individually in its own MMC window.

 Following are the major features of BHM:

  • Monitor Multiple BizTalk Environments
  • Generate and View MBV reports
  • Dashboard view for overall health of BizTalk Environments
  • Schedule Report Collection
  • Send Email Notifications
  • Performance Monitor integration with pre-loaded scenario-based Performance counters
  • Report Management

    3. MsgBoxViewer:

BizTalk provides Message Box Viewer (MBV) tool out of box to generate report for BizTalk health and performance monitoring activity. It’s collecting details about BizTalk Server, Configuration, database and performance details.

MBV analyze in details of BizTalk MsgBox Db but also other BizTalk Dbs and generates an HTML file containing different REPORTS including a “WARNINGS REPORT” which report in yellow and red some warnings.

This tool comes along with BizTalk. When we installed BizTalk, this will available at below location:

C:\Program Files (x86)\Microsoft BizTalk Server 2013\SDK\Utilities\Support Tools\MsgBoxViewer

click here to get more details :

https://vkbiztalk.com/2018/02/15/biztalk-health-monitoring-and-message-box-viewer/

4. BizTalk Terminator tool

The BizTalk Terminator tool allows the you to easily address common BizTalk issues via SQL, WMI, and PowerShell based tasks provided by the BizTalk team. with additional functionality including the ability to suspend, resume, and terminate in bulk by date range as well as make performance tuning changes. Integration with mbvcleanupscripts.xml from the MessageBox Viewer Utility allows Terminator to quickly resolve issues identified by MBV.

For more details click here.

you can download this tool from below link:

https://www.microsoft.com/en-in/download/details.aspx?id=2846

5. BizTalk Assembly Checker

After BizTalk applications deployment in single and multiple environment. When we need to check and verify about all the dlls are deployed properly and also save their reference in BizTalK management Database. This tool provide all the details on single click.

Use the BizTalk Assembly Checker and Remote GAC tool (BTSAssemblyChecker.exe) to check the versions of assemblies deployed to the BizTalk Management database and to verify that they are correctly registered in the GAC on all BizTalk Server computers.

C:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\SDK\Utilities\Support Tools\BiztalkAssemblyChecker

6. BizTalk Documenter:

This tool provides all the details of BizTalk applications in documents. This tool is helpful when we need to share the details and creating documents.

BizTalkDocument.jpg

You can download this tool from below website:

https://github.com/mbrimble/biztalkdocumenter

 

 

 

 

Types Of BizTalk Deployment

Using this blog, I just want to throw some light on different ways of BizTalk deployments.

Manual Deployment: This is pretty known style of BizTalk deployment by exporting MSI, Binding files from local environment and import the same in target environment. Here is some of the steps need to be followed.

  • Export MSI from Local Environment
  • Export BindingFile from Local environment
  • Open BidningFile and edit required details like Sendport/Receiveport locations…
  • After edit, just save the Binding file
  • Stop the application in Target Environment
  • Stop Host Instances in Target Environment
  • Import MSI in Target Environment
  • Import Binding file in Target Environment
  • Start Host instances
  • Start BizTalk Application.

Deployment using PowerShell Scripting: This style avoids some of the manual steps mentioned above. Here we write PowerShell commands for all deployment steps and execute the scripts in Target machine.

BTDF Deployment:

BizTalk Deployment Framework is a third-party tool used to automate the BizTalk deployment process. Main advantage of using this tool is to generate the bindings automatically for various environments. We create msi file in local environment by following BTDF steps and deploy the msi in target machine by selecting appropriate binding file in the deployment wizard.

Continuous Integration & Continuous Deployment (Dev Ops):

Continuous Integration approach is most advanced and effective deployment process in BizTalk. We need to use couple of tools (BTDF, TFS, Teamcity, MyGet and Octopus) to setup this process. Here is the sequence of steps we need to follow to setup this process.

  • When ever you do some code changes, you need to check in the code to TFS
  • TeamCity is a tool, which keep monitor for any TFS Checkins.
  • If any TFS checkins found, it will take the latest code from TFS, build it and deploy to Teamcity local environment.
  • If deployment is successful, it will create a Build and place into MyGet Server (This is used to maintain proper versions for Builds).
  • Octopus is a third-party tool using which we deploy the BizTalk artifacts to target environments.
  • In Octopus we need to do couple of configuration to connect MyGet Server, Target Environments.
  • We need to write deployment steps using powershell scripting in Octopus.
  • We create a BizTalk release in Octopus by selecting latest Build from MyGet server.
  • While deploying we need to select the target machine in drop down list and deploy it.
  • Using Powershell scripting steps, BizTalk code will be deployed to Target machine.

Add Http Headers For WCF/Rest Services

Requirement: There is a BizTalk service exposed as a Request and Response Rest service. I need to pass message to that Rest service with some http headers. BizTalk service has to receive those headers and pass it to back end service.

How to send headers to BizTalk Rest Service From third party tools like Postman.

httpheaders1.png

In BizTalk Orchestration message assignment shape, we need to assign incoming message context properties to another message which we are sending to request and response logical port.

Message2(*) = Message1(*) 

In order to populate http headers in the message which is sending to destination system, we need to assign some properties at behaviour section of sendport.

Please follow steps below.

  1. we need to create a class library with below code, build it and Gac it.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Xml;

using System.ServiceModel.Configuration;

using System.ServiceModel.Description;

using System.ServiceModel.Dispatcher;

using System.ServiceModel.Channels;

using System.ServiceModel;

using System.Configuration;

namespace AppName.CustomBehaviors

{

    public class AddHttpHeaderInspector : IDispatchMessageInspector, IClientMessageInspector

    {      

        private const string Source = “AddHttpHeaderContextInspector”;

        private const string contextHttpHeaderNS = @”http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties&#8221;;

        private const string contextHttpHeaderName = “HttpHeaders”;

        private const string httpResponseMessagePropertyName = “httpResponse”;

       private string headerFields;       

        public string HeaderFields    

    {

            get

            {

                return headerFields;

            }

            set

            {

                headerFields = value;

            }

        }

        public AddHttpHeaderInspector(string httpHeaders)

        {

            this.HeaderFields = httpHeaders;

        }

        public AddHttpHeaderInspector()

        {

        }

        public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)

        {

        }

        public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)

        {

            //Adds any headers in the WCF.HttpHeaders context property to the HTTP Headers

            //expects headers in the form “Header1: Value1, Header2: Value2”

            const string httpHeadersKey = “http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName&#8221;;

            if (request.Properties.ContainsKey(httpHeadersKey))

            {

                Dictionary<string, string> httpHeadersContext = GetHttpHeadersContext(Convert.ToString(request.Properties[httpHeadersKey]));

                HttpRequestMessageProperty httpRequestMessage;

                object httpRequestMessageObject;

                if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out httpRequestMessageObject))

                {

                    httpRequestMessage = httpRequestMessageObject as HttpRequestMessageProperty;

                }

                else

                {

                    httpRequestMessage = new HttpRequestMessageProperty();

                    request.Properties.Add(HttpRequestMessageProperty.Name, httpRequestMessage);

                }

                string[] hdrs = HeaderFields.Split(new char[] { ‘,’ }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string hdr in hdrs)

                {

                    String[] fixedHdr = hdr.Split(new char[] { ‘:’ }, StringSplitOptions.RemoveEmptyEntries);

                    if (fixedHdr.Length > 1)

                    {

                        httpRequestMessage.Headers[fixedHdr[0]] = fixedHdr[1];

                    }

                    else

                    {

                        if (httpHeadersContext.ContainsKey(fixedHdr[0]))

                        {

                            httpRequestMessage.Headers[fixedHdr[0]] = httpHeadersContext[fixedHdr[0]];

                        }

                    }

                }

            }

            return null;

        }        

   

        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)

        {

            return null;

        }

        public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)

        {

            try

            {

                object objContextHttpHeaders;

                object objHttpResponse;

                HttpResponseMessageProperty httpResponseMessage;

 

                if (reply.Properties.TryGetValue(string.Format(“{0}#{1}”, contextHttpHeaderNS, contextHttpHeaderName), out objContextHttpHeaders))

                {

                    Dictionary<string, string> httpHeadersContext = GetHttpHeadersContext(Convert.ToString(objContextHttpHeaders));

                      //Dictionary<string, string> subhttpHeadersContext = null;

                    if (reply.Properties.TryGetValue(httpResponseMessagePropertyName, out objHttpResponse))

                    {

                        if (objHttpResponse == null)

                        {

                            httpResponseMessage = new HttpResponseMessageProperty();

                            AddHttpHeaderContextToResponseHeaders(httpHeadersContext, httpResponseMessage);

                            reply.Properties.Add(httpResponseMessagePropertyName, httpResponseMessage);

                        }

                        else

                        {

                            httpResponseMessage = objHttpResponse as HttpResponseMessageProperty;

                            httpResponseMessage.Headers.Clear();

                            string[] hdrs = HeaderFields.Split(new char[] { ‘,’ }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (string hdr in hdrs)

                            {

                                String[] fixedHdr = hdr.Split(new char[] { ‘:’ }, StringSplitOptions.RemoveEmptyEntries);

                                if (fixedHdr.Length > 1)

                                {

                                    httpResponseMessage.Headers[fixedHdr[0]] = fixedHdr[1];

                                }

                                else

                                {

                                    if (httpHeadersContext.ContainsKey(fixedHdr[0]))

                                    {

                                        httpResponseMessage.Headers[fixedHdr[0]] = httpHeadersContext[fixedHdr[0]];

                                    }

                                }

                            }

                        }

                    }

                }

            }

            catch (Exception ex)

            {

               throw;

            }

        }

        private Dictionary<string, string> GetHttpHeadersContext(string rawHttpHeaders)

        {

            Dictionary<string, string> headersDictionary = new Dictionary<string, string>();

            string[] headerlines = rawHttpHeaders.Split(new char[] {‘\n’, ‘\r’}, StringSplitOptions.RemoveEmptyEntries);

            foreach (string headerline in headerlines)

            {

                string[] headerfields = headerline.Split(new char[]{‘:’}, StringSplitOptions.RemoveEmptyEntries);

                if (headerfields.Length > 1)

                {

                    headersDictionary.Add(headerfields[0], headerfields[1]);

                }

            }

            return headersDictionary;

        }

        private void AddHttpHeaderContextToResponseHeaders(Dictionary<string, string> httpHeadersContext, HttpResponseMessageProperty httpResponseMessage)

        {

            foreach (string headerName in httpHeadersContext.Keys)

            {

                httpResponseMessage.Headers.Add(headerName, httpHeadersContext[headerName]);

            }

        }

    } 

 

    public class AddHttpHeaderBehavior : IEndpointBehavior

    {

        private string headerFields;       

        public string HeaderFields

        {

            get

            {

                return headerFields;

            }

            set

            {

                headerFields = value;

            }

        }

        public AddHttpHeaderBehavior(string httpHeaders)

        {

            this.HeaderFields = httpHeaders;

        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)

        {

            AddHttpHeaderInspector inspector = new AddHttpHeaderInspector(HeaderFields);

            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(inspector);

        }

        public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)

        {

            return;

        }

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)

        {

            AddHttpHeaderInspector headerInspector = new AddHttpHeaderInspector(HeaderFields);

            clientRuntime.MessageInspectors.Add(headerInspector);

         }

       

        public void Validate(ServiceEndpoint endpoint)

        {

            return;

        }

    }

 

    public class AddHttpHeaderBehaviorExtensionElement : BehaviorExtensionElement

    {

        [ConfigurationProperty(“HeaderFields”, DefaultValue = “”, IsRequired = false)]

        public string HeaderFields

        {

            get { return (string)base[“HeaderFields”]; }

            set { base[“HeaderFields”] = value; }

        }

 

        protected override object CreateBehavior()

        {

            return new AddHttpHeaderBehavior(HeaderFields);

        }

 

        public override Type BehaviorType

        {

            get { return typeof(AddHttpHeaderBehavior); }

        }

    }

}

2) Mention fully qualified name of the above dll in the Machine.config like below.

We have to include below configuration entry in behaviorExtensions within machine.config file located in below mentioned folders.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\

       <add name=”AddHttpHeader” type=”AppName.CustomBehaviors.AddHttpHeaderBehaviorExtensionElement, AppName.CustomBehaviors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXX”/>

3) In send port, we need to apply EndpointBehaviors under Behavior tab and mention the header field names like below.

 

httpheaders2.png

Now you will be able to send the HttpHeaders along with outgoing message.

BizTalk Dynamic Send Ports For Rest Services

Dynamic send ports are used to send the BizTalk messages dynamically from orchestration to destination systems based on some conditions.

There are two types of dynamic send ports.

  • One-way dynamic Send Port:

Using one-way dynamic send port, we just send the messages to destination systems, but don’t expect the response back.

We need to create a logical send port in orchestration with port direction as Dynamic.

OneWayDynamic1.png

In the expression shape, we need to specify the destination location and Transport Type properties.

OneWayDynamic2.png

OneWayDynamic3.png

In Expression_1, you need to write below code

Port_Dynamic(Microsoft.XLANGs.BaseTypes.Address)=@”file://D:\Test1″;

Port_Dynamic(Microsoft.XLANGs.BaseTypes.TransportType)=”FILE”;

//Port-Dynamic is the Dynamic send port name.

//In Expression_2, you need to write below code

Port_Dynamic(Microsoft.XLANGs.BaseTypes.Address)=@”file://D:\Test2″;

Port_Dynamic(Microsoft.XLANGs.BaseTypes.TransportType)=”FILE”;

  • Two Way Dynamic Send Port

Two-way dynamic sendports are used for request and response messages.

We need to create logical dynamic sendport with port direction as dynamic.

TwoWayDynamic1.png

We need to construct the message with all request and response message properties of Rest endpoint as below

In the message assignment shape we need to construct the message with below properties.

RequestForRouting = Request;

//Request is the input message type of your orchestration receive shape. RequestForRouting is the message which we construct in this message assignment shape.

RequestForRouting(BTS.RouteDirectToTP)=false;

headerhttp = Request(WCF.InboundHttpHeaders);//If you have any http headers

RequestForRouting(FILE.ReceivedFileName) = headerhttp;

RequestForRouting(WCF.HttpMethodAndUrl) = “POST” //For POST Operation

RequestForRouting(WCF.HttpMethodAndUrl)=”<BtsHttpUrlMapping><Operation Name=” Method=’GET’ Url=’/RestServiceURL’ /></BtsHttpUrlMapping>”; // For Get Operation

RequestForRouting(BTS.SendPipelineConfig)=”<Root xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance’><Stages><Stage CategoryId=’9d0e4108-4cce-4536-83fa-4a5040674ad6′><Components><Component Name=’Microsoft.BizTalk.Component.JsonEncoder’><Properties><RemoveOuterEnvelope vt=’11’>-1</RemoveOuterEnvelope></Properties></Component></Components></Stage></Stages></Root>”;

RequestForRouting(BTS.SendPipelineResponseConfig) = “<Root xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance’><Stages><Stage CategoryId=’9d0e4103-4cce-4536-83fa-4a5040674ad6′><Components><Component Name=’Microsoft.BizTalk.Component.JsonDecoder’><Properties><RootNode vt=’8′>” + RootNodeName + “</RootNode><RootNodeNamespace vt=’8′>” + Namespace + “</RootNodeNamespace></Properties></Component><Component Name=’Microsoft.BizTalk.Component.XmlDasmComp’><Properties><AllowUnrecognizedMessage vt=’11’>-1</AllowUnrecognizedMessage></Properties></Component></Components></Stage></Stages></Root>”; 

RequestForRouting(WCF.VariablePropertyMapping)=String.Empty;

//For POST Operation

RequestForRouting(WCF.VariablePropertyMapping)=

“<BtsVariablePropertyMapping xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance&#8217; xmlns:xsd=’http://www.w3.org/2001/XMLSchema’><Variable Name=NameoftheVariable PropertyName=’NameOftheProperty‘ PropertyNamespace=’NameSpace‘/></BtsVariablePropertyMapping>”;

//For Get Operation

RequestForRouting(WCF.SuppressMessageBodyForHttpVerbs)=String.Empty;

//For POST Operation

RequestForRouting(WCF.SuppressMessageBodyForHttpVerbs)=”GET”;

//For Get Operation

RequestForRouting(BTS.RetryCount) = 0;

RequestForRouting(WCF.MaxReceivedMessageSize)=2147483647;

RequestForRouting(WCF.OpenTimeout)=”00:01:00″;

RequestForRouting(WCF.CloseTimeout)=”00:01:00″;

RequestForRouting(WCF.SendTimeout)= “00:01:00”;

RequestForRouting(WCF.EndpointBehaviorConfiguration)=”<behavior name=’EndpointBehavior’><AddHttpHeader HeaderFields=’Field1,Field2,Content-Type: application/json’/></behavior>”;

// If you have http headers

In the expression shape, we need to specify Address and TransportType.

TwoWayDynamic2.png

DynamicCommonSendPort(Microsoft.XLANGs.BaseTypes.Address)=”Rest Endpoint URL Name”;

DynamicCommonSendPort(Microsoft.XLANGs.BaseTypes.TransportType)=”WCF-WebHttp”;

Good Luck…