Thursday, August 26, 2021

Splitting BizTalk Server from the same group

 BizTalk Server Split from the same group

1: Open the BizTalk Configuration wizard run as admin as shown below screenshot

Now it will open Configuration window of BizTalk as shown in below screenshot, click on Un-Configure Features

 

2: Re-Configure the BizTalk

1- Copy the all PowerShell script files and BizTalk Configuration XML into “C:\Temp” folder as shown in below screenshot,

 

 

2- To Run PowerShell Script file find the below screenshot.

Open PowerShell Command Prompt Run as Administrator either from taskbar or windows search.

 

Taskbar

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OR

 

 

 

 

 

 

 

 

 

 

 

Windows Search


3- Syntax to execute PowerShell script

 

PowerShell <PowerShell script file path>   Hit Enter Button

 

Example: Here I am using 3-BiztalkSilentInstall-Configuration.ps1 script file to show how to execute PowerShell script. 

 

PowerShell C:\Temp\ 3-BiztalkSilentInstall-Configuration.ps1 Hit enter button

 

 

Step 3: BizTalk Server 2016 Configuration (New Group)    

 

BizTalk Server 2016 Configuration Prerequisites (New Group)

Note*: Refer to table for naming convention for domain groups and service account based on environment

a)       Create a domain user. In this guide "SVC_BizTalk_Dev" user account has been used.

b)      Add following domain groups:-

·         SSO Administrators Dev

·         SSO Affiliate Administrators Dev

·         BizTalk Server Administrators Dev

·         BizTalk Server Operators Dev

·         BizTalk Server B2B Operators Dev

·         BizTalk Application Users Dev

·         BizTalk Isolated Host Users Dev

 

c)        Add the domain user "SVC_BizTalk_Dev" in all the above domain groups.

d)      Configure "DTC Properties" on BizTalk Server 2016 machine and SQL Server machine. Refer the steps and screen shot given below.

 

 

To configure BizTalk Open the 3-BiztalkSilentInstallConfigurationXml.xml in notepad.

 

Search for biztalkssopwd and replace all the instances with the actual password

 

Search for biztalkserviceaccountpwd and replace all the instances with the actual password

 

Below are the changes require into Configuration file

Note: Please make change in yellow marked places, According to your environment

<Configuration>

  <Feature Name="SSOServer,Engine" DisplayName="Enterprise Single Sign-On" Version="1.0" Description="Enterprise Single Sign-On configuration" ConfigByDefault="true">

    <Question ID="IsSecretServer" Text="&amp;Create a new SSO system;&amp;Join an existing SSO system" Answers="Create,Join" Default="Create">

      <Answer Value="Create" GUID="{FB7268BE-82D4-4cad-8CFF-6930303DA7E2}" Selected="Yes">

        <NTCredential ID="SSOAdminGroup" DisplayName="SSO Administrator(s)" Description="This is the Administrator of the Enterprise Single Sign-On (SSO) system.">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147516422">DOMAIN\SSO Administrators UAT</NTAccount>

        </NTCredential>

        <NTCredential ID="SSO

AffiliateAdminGroup" DisplayName="SSO Affiliate Administrator(s)" Description="The SSO Affiliate Administrator must be able to create Affiliate Applications.">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147516422"> DOMAIN \SSO Affiliate Administrators UAT</NTAccount>

        </NTCredential>

        <FILE ID="SSO_ID_BACKUP_SECRET_FILE" DisplayName="&amp;Backup file location:" Filter="Backup files (*.bak)|*.bak|All files (*.*)|*.*" DefaultExtension="bak" Title="" Description="Location where the master secret will be backed up" OpenFile="true">

          <Value>C:\Program Files\Common Files\Enterprise Single Sign-On\ssoBT2016.bak</Value>

        </FILE>

        <Name ID="SSO_ID_BACKUP_SECRET_PASSWORD" DisplayName="&amp;Secret backup password:" Description="Enter a password used to protect the secret backup file" Hidden="true">

         <Value>password1234</Value>

        </Name>

        <Name ID="SSO_ID_BACKUP_SECRET_PASSWORD_CONFIRM" DisplayName="&amp;Confirm password:" Description="Confirm the secret backup password" Hidden="true">

          <Value>password1234</Value>

        </Name>

        <Name ID="SSO_ID_BACKUP_SECRET_REMINDER" DisplayName="Password &amp;reminder:" Description="Enter a phrase to help you remember the secret backup file password" Hidden="false">

          <Value>password1234</Value>

        </Name>

      </Answer>

      <Answer Value="Join" GUID="{B9432756-1620-4bec-8CD9-E6D0B7805AA5}" />

    </Question>

    <NTService ID="ENTSSO" DisplayName="Enterprise Single Sign-On Service" Description="Specify the name of the account under which the Single Sign-On (SSO) service should run. This account must be a member of the SSO Administrator(s) group.">

      <UserName>TypeServiceAccountNameHere</UserName>

      <Domain>TRAFGLOBAL</Domain>

      <Password><![CDATA[TypePasswordHere]]></Password>

    </NTService>

    <SQL ID="SSO_DB_ID" DisplayName="SSO Database" Description="Specify the name of the SQL Server and Database that will be used as the credential store.">

      <Server> SQLServerName/Instance </Server>

      <Database>SSODB</Database>

      <WindowsSecurity Editable="no">yes</WindowsSecurity>

      <UserName />

      <Password />

    </SQL>

  </Feature>

  <Feature Name="WMI" DisplayName="BizTalk Server Group" Version="1.0" Description="The Microsoft Windows Management Instrumentation (WMI) layer encapsulates all administrative functions and management capabilities for BizTalk Server." ConfigByDefault="true">

    <SQL ID="{D757DBF9-5D71-4995-9F20-A552B7DFE7F1}" DisplayName="BizTalk Management Database" Description="This database is the central meta-information store for all BizTalk Servers.">

      <Server>SQLServerName/Instance</Server>

      <Database>BizTalkMgmtDb</Database>

      <WindowsSecurity Editable="no">yes</WindowsSecurity>

      <UserName />

      <Password />

    </SQL>

    <Question ID="CREATEORJOIN" Text="Create a &amp;new BizTalk Group;&amp;Join an existing BizTalk Group" Answers="Create,Join" Default="Create">

      <Answer Value="Create" GUID="{C4DEF4B8-163E-4a8d-AB01-6C43917248B1}" Selected="Yes">

        <SQL ID="{84ADD76E-EBEB-4bb8-B9EB-64F87E483C39}" DisplayName="BizTalk MessageBox Database" Description="This database stores subscriptions predicates. It is a host platform, where the queues and state tables for each BizTalk Server host are kept. The MessageBox database also stores the messages and message properties.">

          <Server> SQLServerName/Instance </Server>

          <Database>BizTalkMsgBoxDb</Database>

          <WindowsSecurity Editable="no">yes</WindowsSecurity>

          <UserName />

          <Password />

        </SQL>

        <SQL ID="{1033195A-3C23-4750-BBD0-06BC12A175D4}" DisplayName="BizTalk Tracking Database" Description="This database stores business and health monitoring data tracked by the BizTalk Server tracking engine.">

          <Server> SQLServerName/Instance </Server>

          <Database>BizTalkDTADb</Database>

          <WindowsSecurity Editable="no">yes</WindowsSecurity>

          <UserName />

          <Password />

        </SQL>

        <NTCredential ID="BTS_ADMIN_GROUP" DisplayName="BizTalk Administrators Group" Description="The BizTalk Server Administrators Group has the least privileges necessary to perform administrative tasks included in the Configuration Framework Wizard and to administer the BizTalk Server environment after installation.">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654"> DOMAIN \BizTalk Server Administrators UAT</NTAccount>

        </NTCredential>

        <NTCredential ID="BTS_OPERATOR_GROUP" DisplayName="BizTalk Operators Group" Description="The BizTalk Server Operators Group has the least privileges necessary to perform tasks required for operating the BizTalk Server environment after installation.">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654"> DOMAIN \BizTalk Server Operators UAT</NTAccount>

        </NTCredential>

        <NTCredential ID="BTS_B2B_OPERATOR_GROUP" DisplayName="BizTalk B2B Operators Group" Description="The BizTalk Server B2B Operators Group has the least privileges necessary to perform tasks required for operating the BizTalk Server B2B environment after installation.">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654"> DOMAIN \BizTalk Server B2B Operators UAT</NTAccount>

        </NTCredential>

      </Answer>

      <Answer Value="Join" GUID="{4D12E6A3-552E-4936-9DD3-59E1190FA324}" />

    </Question>

  </Feature>

  <Feature Name="Engine,BTSCfg" DisplayName="BizTalk Server runtime components" Version="1.0" Description="These settings determine the manner in which the BizTalk hosts and host instances are created." ConfigByDefault="true">

    <Question ID="HOST" Text="&amp;Create In-Process Host and Instance" Answers="Yes,No" Default="Yes">

      <Answer Value="Yes" GUID="{8E714C78-05B8-45d1-9B50-D737EF7AD682}" Selected="Yes">

        <Question ID="TRUSTEDHOST" Text="&amp;Trusted" Answers="Yes,No" Default="No">

          <Answer Value="Yes" GUID="{D460CE6D-CCF1-4ebf-BDC9-3149021B91ED}" />

          <Answer Value="No" GUID="{F507BD3D-2205-47bc-A7EF-0E45603BB6C4}" Selected="Yes" />

        </Question>

        <Question ID="GENERICHOST" Text="32-bit on&amp;ly" Answers="Yes,No" Default="No">

          <Answer Value="Yes" GUID="{5D3B2217-D744-4D50-B931-FED9E259628D}" />

          <Answer Value="No" GUID="{CBF077AE-2771-473E-9E0C-D955D5EB5692}" Selected="Yes" />

        </Question>

        <NTCredential ID="BTS_HOST_GROUP" DisplayName="BizTalk Host Users Group" Description="Windows group for accounts with access to the In-Process BizTalk  hosts (hosts processes in the BizTalk Server).">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654">TRAFGLOBAL\BizTalk Application Users UAT</NTAccount>

        </NTCredential>

        <Name ID="BTS_HOST_NAME" DisplayName="Ho&amp;st name:" Description="Name of the In-Process BizTalk  host (eg, BizTalkServerApplication)" Hidden="false">

          <Value>BizTalkServerApplication</Value>

        </Name>

        <NTService ID="{B64F63FA-E24E-4991-86F0-ED9F65B68A98}" DisplayName="BizTalk Host Instance Account" Description="Windows account with access to a specific In-Process BizTalk host instance. This account will be given Log on as Service rights.">

          <UserName>ServiceAccountName</UserName>

          <Domain>TRAFGLOBAL</Domain>

          <Password><![CDATA[TypeServiceAccountPasswordHere]]></Password>

        </NTService>

      </Answer>

      <Answer Value="No" GUID="{D9164C48-8179-4a40-912D-1BF4C3EFE70B}" />

    </Question>

    <Question ID="ISOHOST" Text="Cr&amp;eate Isolated Host and Instance" Answers="Yes,No" Default="Yes">

      <Answer Value="Yes" GUID="{5638D8B2-58C9-4b2a-B5B1-3771ADECC327}" Selected="Yes">

        <Question ID="TRUSTEDIHOST" Text="Truste&amp;d" Answers="Yes,No" Default="No">

          <Answer Value="Yes" GUID="{D460CE6D-CCF1-4ebf-BDC9-3149021B91ED}" />

          <Answer Value="No" GUID="{F507BD3D-2205-47bc-A7EF-0E45603BB6C4}" Selected="Yes" />

        </Question>

        <Question ID="GENERICIHOST" Text="32-bit onl&amp;y" Answers="Yes,No" Default="Yes">

          <Answer Value="Yes" GUID="{5D3B2217-D744-4D50-B931-FED9E259628D}" Selected="Yes" />

          <Answer Value="No" GUID="{CBF077AE-2771-473E-9E0C-D955D5EB5692}" />

        </Question>

        <NTCredential ID="BTS_IHOST_GROUP" DisplayName="BizTalk Isolated Host Users Group" Description="Windows group for accounts with access to the Isolated BizTalk hosts (hosts processes not running on BizTalk Server, such as HTTP and SOAP)">

          <NTAccount ScopeType="105" UpLevelFlags="672" DownLevelFlags="2147483654"> DOMAIN \BizTalk Isolated Host Users UAT</NTAccount>

        </NTCredential>

        <Name ID="BTS_IHOST_NAME" DisplayName="Is&amp;olated Host name:" Description="Name of the Isolated BizTalk host (eg BizTalkServerIsolatedHost)" Hidden="false">

          <Value>BizTalkServerIsolatedHost</Value>

        </Name>

        <NTService ID="{D0A37CEE-F24E-4193-A19F-47B05D7EDA21}" DisplayName="BizTalk Isolated Host Instance Account" Description="Windows account with access to a specific Isolated BizTalk  host instance. This account will be given Log on as Service rights.">

          <UserName>ServiceAccountName</UserName>

          <Domain>TRAFGLOBAL</Domain>

          <Password><![CDATA[TypeHereServiceAccountPassword]]></Password>

        </NTService>

      </Answer>

      <Answer Value="No" GUID="{5782A1A5-8578-4942-9CBB-E443A15A0B99}" />

    </Question>

  </Feature>

  <Feature Name="MOT" DisplayName="BAM runtime" Version="1.0" Description="Tracking data decoding service used to move tracked data and persist it for query use." />

  <InstalledFeature>MsEDIAS2</InstalledFeature>

  <InstalledFeature>MsEDIAS2StatusReporting</InstalledFeature>

  <InstalledFeature>WCFAdapter</InstalledFeature>

  <InstalledFeature>InfoWorkerApps</InstalledFeature>

  <InstalledFeature>BAMPortal</InstalledFeature>

  <InstalledFeature>WcfAdapterAdminTools</InstalledFeature>

  <InstalledFeature>PAM</InstalledFeature>

  <InstalledFeature>Development</InstalledFeature>

  <InstalledFeature>MsEDISchemaExtension</InstalledFeature>

  <InstalledFeature>MsEDISDK</InstalledFeature>

  <InstalledFeature>MsEDIMigration</InstalledFeature>

  <InstalledFeature>Documentation</InstalledFeature>

  <InstalledFeature>SDK</InstalledFeature>

  <InstalledFeature>WMI</InstalledFeature>

  <InstalledFeature>BizTalk</InstalledFeature>

  <InstalledFeature>MOT</InstalledFeature>

  <InstalledFeature>Engine</InstalledFeature>

  <InstalledFeature>MSMQ</InstalledFeature>

  <InstalledFeature>Runtime</InstalledFeature>

  <InstalledFeature>RfidEventForwarderMessageTransform</InstalledFeature>

  <InstalledFeature>AdminAndMonitoring</InstalledFeature>

  <InstalledFeature>MonitoringAndTracking</InstalledFeature>

  <InstalledFeature>AdminTools</InstalledFeature>

  <InstalledFeature>BizTalkAdminSnapIn</InstalledFeature>

  <InstalledFeature>HealthActivityClient</InstalledFeature>

  <InstalledFeature>BAMTools</InstalledFeature>

  <InstalledFeature>Migration</InstalledFeature>

  <InstalledFeature>BizTalkExplorer</InstalledFeature>

  <InstalledFeature>BizTalkExtensions</InstalledFeature>

  <InstalledFeature>OrchestrationDesigner</InstalledFeature>

  <InstalledFeature>Designer</InstalledFeature>

  <InstalledFeature>PipelineDesigner</InstalledFeature>

  <InstalledFeature>XMLTools</InstalledFeature>

  <InstalledFeature>AdapterImportWizard</InstalledFeature>

  <InstalledFeature>VSTools</InstalledFeature>

  <InstalledFeature>WCFDevTools</InstalledFeature>

  <InstalledFeature>DeploymentWizard</InstalledFeature>

  <InstalledFeature>TrackingProfileEditor</InstalledFeature>

  <InstalledFeature>SSOAdmin</InstalledFeature>

  <InstalledFeature>AdditionalApps</InstalledFeature>

  <InstalledFeature>SSOServer</InstalledFeature>

  <InstalledFeature>RulesEngine</InstalledFeature>

  <InstalledFeature>OLAPNS</InstalledFeature>

  <InstalledFeature>FBAMCLIENT</InstalledFeature>

  <InstalledFeature>BAMEVENTAPI</InstalledFeature>

  <InstalledFeature>ProjectBuildComponent</InstalledFeature>

</Configuration>

 

Type the following command to run the PowerShell command prompt under service account which has the admin rights on SQL to configure BizTalk

 

Start-Process PowerShell -Credential DOMAIN \SVC_BizTalk_Dev

 

 

Here new PowerShell window will be open and then type the following command and press enter button

 

PowerShell C:\Temp\ 3-BiztalkSilentInstall-Configuration.ps1

 

 

Note: You must be a member of the local Administrators group to install and configure BizTalk Server.

User account used for installing BizTalk need to have Database Administrator rights on SQL server

 

 

upload files to sftp using PowerShell

 Hi Here I have written code for upload files from local to sftp location using PowerShell 

Please follow the below 2 steps only 

Step1:  Install the Posh-SSH module for sftp connection, it is the open-source PowerShell module 

use the below line to install Posh-SSH Module and please check the latest version as of now 2.1 is available 

Install-Module -Name Posh-SSH -RequiredVersion 2.1

Step2: use the below PowerShell script for uploading files to sftp.

Please replace the username, password,sftp server, and file paths wherever require

# Set the credentials
$username= "YourSFTPUserName"
$Password = ConvertTo-SecureString 'YourSFTPPassword' -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $username , $Password
 
# Set local file path, SFTP path, and the backup location path which I assume is an SMB path
$FilePath = "C:\Temp"
$SftpPath = '/PSTest'
$SmbPath = "C:\Temp\backup"
 
# Set the IP of the SFTP server
$SftpIp = 'Your SFTP Server Name or IP'
 
# Load the Posh-SSH module before importing need to install please refer to step 1
Import-Module Posh-SSH
 
# Establish the SFTP connection
$ThisSession = New-SFTPSession -ComputerName $SftpIp -Credential $Credential -AcceptKey -ConnectionTimeout 220

foreach($file in Get-ChildItem $FilePath -Filter *.txt)
{
# Do something
# Upload the file to the SFTP path
Set-SFTPFile -SessionId $ThisSession.SessionId -LocalFile $file.FullName -RemotePath $SftpPath -Overwrite
$file.FullName
}
 
#Disconnect all SFTP Sessions
Get-SFTPSession | % { Remove-SFTPSession -SessionId ($_.SessionId) }
 
# Copy the file to the SMB location
Copy-Item -Filter *.txt -Path "C:\Temp\*" -Destination $SmbPath -Force

# Delete the files from source once backup done
Remove-Item -Filter *.txt  -Path "C:\Temp\backup\*.txt" -Force
 

Dynamically calling WCF service over HTTP and HTTPS with Certificate and without Certificate In C#.net

Here I am trying to call the WCF Service through C#.net code for testing purpose.

My scenario is, I want to call WCF Service from BizTalk over HTTPS protocol with Certificate
so first I was written the C# code to test it as below.

Step 1: Create a console application and add the service reference and create one class as I written,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.IO;
using System.Net;
using System.Configuration;
using System.Xml.Serialization;
using System.Xml.Linq;
using System.ServiceModel;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace WCFClientApp
{
    class CallWcfServiceWithCertificate
    {

        private static string failureStatus = "Failure";
        private static bool logRequired = false;
        private static bool hasError = false;

        private static void LogXMLMsg(string msgXml)
        {
            if (logRequired || hasError)
            {
                try
                {

                    string logFolderPath = Path.GetTempPath();
                    StreamWriter log;
                    if (!File.Exists(logFolderPath + "TypeLogFileNameHere.txt"))
                        log = new StreamWriter(logFolderPath + "TypeLogFileNameHere.txt");
                    else
                        log = File.AppendText(logFolderPath + "TypeLogFileNameHere.txt");

                    log.WriteLine("==================================================================================================");
                    log.WriteLine("Date Time:" + DateTime.Now);
                    log.WriteLine("Msg XML:" + msgXml);
                    log.Close();
                }
                catch (Exception ex)
                {
                    //Code should not reach here.
                    //EventLog m_EventLog = new EventLog("");
                    //m_EventLog.Source = "MDM Event Log";
                    //m_EventLog.WriteEntry(ex.Message, EventLogEntryType.FailureAudit);

                }
            }
        }
        private static string UpdateErrorInformation(string xmlString, string exceptionMessage, string errorCode)
        {
// Here I have created one xml file with my schema to store the error info and send over the mail 
// You can use your xml format or schema for recording error info
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlString);
            string errorDescXpath = "MSG/HeaderCommon/ErrorDescription";
            string errorCodeXpath = "MSG/HeaderCommon/ErrorCode";
            string transportStatusXpath = "MSG/HeaderCommon/TransportStatus";
            xmlDoc.SelectNodes(errorDescXpath).Item(0).InnerXml = exceptionMessage;
            xmlDoc.SelectNodes(errorCodeXpath).Item(0).InnerXml = errorCode;
            xmlDoc.SelectNodes(transportStatusXpath).Item(0).InnerXml = failureStatus;
            return xmlDoc.InnerXml;
        }
        private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
        {
            bool result = false;
            if (cert.Subject.ToUpper().Contains("Fully Qualified Domain Name e.g Xyz.Abc.com"))
            {
                result = true;
            }

            return result;
        }
        private static string Serialize(object dataToSerialize)
        {
            if (dataToSerialize == null) return null;

            using (StringWriter stringWriter = new StringWriter())
            {
                var serializer = new XmlSerializer(dataToSerialize.GetType());
                serializer.Serialize(stringWriter, dataToSerialize);
                return stringWriter.ToString();
            }
        }


        /// <summary>
        /// Get client certificate from windows key store for current application
        /// </summary>
        /// <returns></returns>
        public static X509Certificate2 GetCertificate()
        {
            X509Certificate2 cert = null;
            X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindByThumbprint, "ProvideYourClientCertificateThumbprint", false);
            if (certs.Count == 0)
            {
                throw new Exception("Client Certificate not found in current application's personal key store");
            }
            cert = certs[0];
            return cert;
        }


        //Call biztalk method
// Note: certPath means Your certificate ThumbPrint
        public static string SendXmlMessagetoBiztalkAsync(string msgXml, bool enableCertificate, string certPath)
        {
            LogXMLMsg("Msg Received by DLL : " + msgXml);
         

            try
            {

                // var serializer = new XmlSerializer(typeof(FDIService.MSG));
                // XDocument xmlDoc = XDocument.Parse(msgXml);

                // var message = from xml in xmlDoc.Descendants("MSG")
                //   select serializer.Deserialize(xml.CreateReader()) as FDIService.MSG;
                string messageCommon = msgXml;

                string WcfURLProtocol = "https";

                if (!WcfURLProtocol.Contains("https"))
                {
                    WSHttpBinding binding = new WSHttpBinding(SecurityMode.None);
                    binding.MaxReceivedMessageSize = 2147483647;
                    binding.SendTimeout = TimeSpan.FromMinutes(5);
                    Uri serviceUri = new Uri("https://dtraflon2k112.global.trafigura.com/FDI_Service/FDIService.svc");
                    EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity("Fully Qualified Domain Name e.g Xyz.Abc.com");
                    EndpointAddress address = new EndpointAddress(serviceUri);

                    FDIService.FDIServiceClient client = new FDIService.FDIServiceClient(binding, address);
                    //client.SendRequest(ref messageCommon);
                    client.GetRegionbyCompany("cco");
                    hasError = false;
                    return Serialize(messageCommon);
                }
                else
                {
                    WSHttpBinding binding = new WSHttpBinding(SecurityMode.Transport);
                    if (enableCertificate == true)
                    {
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
                    }
                    else
                    {
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
                        binding.Security.Message.NegotiateServiceCredential = true;
                    }
                    binding.MaxReceivedMessageSize = 2147483647;
                    binding.UseDefaultWebProxy = false;
                    binding.SendTimeout = TimeSpan.FromMinutes(5);
                    Uri serviceUri = new Uri("https://dtraflon2k112.global.trafigura.com/FDI_Service/FDIService.svc");
                    EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity("Fully Qualified Domain Name e.g Xyz.Abc.com");
                    EndpointAddress address = new EndpointAddress(serviceUri);


                    FDIService.FDIServiceClient client = new FDIService.FDIServiceClient(binding, address);

                    if (enableCertificate)
                    {
                        ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                        if (!Path.IsPathRooted(certPath)) // If you want to determine if a string contains a relative or absolute folder / file path, you can use the System.IO.Path.IsPathRooted function:
                        {
                            X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
                            store.Open(OpenFlags.ReadOnly);
                            X509Certificate2Collection objcertificates = store.Certificates.Find(X509FindType.FindByThumbprint, certPath, false);
                            store.Close();
                            if (objcertificates.Count == 0)
                            {
                                hasError = true;
                                LogXMLMsg("Exception Async : " + "SSL Certificate not found in local machine / personal key store using thumbprint : " + certPath);
                                return UpdateErrorInformation(msgXml, "SSL Certificate not found in local machine / personal key store using thumbprint : " + certPath, "SSL Certificate not found in local machine / personal key store. Please contact administrator.");
                            }
                            X509Certificate2 cert1 = new X509Certificate2();
                            cert1 = objcertificates[0];
                            //var cert = objcertificates[0];
                            client.ClientCredentials.ClientCertificate.Certificate = cert1;
                            //client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, "TypeHereYourCertificateThumbprint");
                        }
                        else
                        {
                            X509Certificate2 cert = new X509Certificate2(certPath);

                            if (cert == null)
                            {
                                hasError = true;
                                LogXMLMsg("Exception Async : " + "SSL certificate file: " + certPath + " not exist or invalid.");
                                return UpdateErrorInformation(msgXml, "SSL certificate file: " + certPath + " not exist or invalid.", "SSL Certificate is not found. Please contact administrator.");
                            }
                            client.ClientCredentials.ClientCertificate.Certificate = cert;
                        }
                    }
                    //  System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;                                   
                    // client.SendRequest(ref messageCommon);
                    FDIService.RegionByCompanyDC rbcdc = null;

                    rbcdc=client.GetRegionbyCompany("PEG");
                    Console.WriteLine("Company : " + rbcdc.Company);
                    Console.WriteLine("Description : " + rbcdc.Description);
                    Console.WriteLine("ExtensionData : " + rbcdc.ExtensionData);
                    Console.WriteLine("Region : " + rbcdc.Region);
                    Console.WriteLine("Result : " + rbcdc.Result);
                    hasError = false;
                    return Serialize(messageCommon);
                }

            }
            catch (System.Xml.XmlException xmlException)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + xmlException.Message);
                return UpdateErrorInformation(msgXml, xmlException.Message, "Input XML message is not in correct format.");
            }
            catch (System.Net.WebException webException)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + webException.Message);
                return UpdateErrorInformation(msgXml, webException.Message, "An error occurred while calling BizTalk service. Please contact administrator.");
            }
            catch (System.ServiceModel.ServiceActivationException serviceActivationException)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + serviceActivationException.Message);
                return UpdateErrorInformation(msgXml, serviceActivationException.Message, "BizTalk service is not running. Please contact administrator.");
            }

            catch (TimeoutException timeProblem)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + timeProblem.Message);
                return UpdateErrorInformation(msgXml, timeProblem.Message, "BizTalk service operation timed out.");
            }
            catch (FaultException faultEx)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + faultEx.Message);
                return UpdateErrorInformation(msgXml, faultEx.Message, "An unknown SOAP fault exception was received from BizTalk service.");
            }
            // Standard communication fault handler.
            catch (CommunicationException commProblem)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + commProblem.Message);
                return UpdateErrorInformation(msgXml, commProblem.Message, "There was a communication problem occurred while accessing BizTalk service.");

            }
            catch (Exception exception)
            {
                hasError = true;
                LogXMLMsg("Exception Async : " + exception.Message);
                return UpdateErrorInformation(msgXml, exception.Message, "Error occurred while processing the current Transaction on Biztalk Integration library layer.");
            }

        }
    }
}


Step 2: To Consume this class we need the entry point of the project i.e. Main method
Here I have created the Program class to consume it.

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

namespace WCFClientApp
{
    class Program
    {
        static void Main(string[] args)
        {
// Method prototype is 1st Param is XmlMsg format to store error info
//2nd Param Boolean value for IsCertificate mean do you want to provide certificate
//3rd Param is Certificate ThumbPrint
            string outmsg = CallWcfServiceWithCertificate.SendXmlMessagetoBiztalkAsync("xmlmsg", true, "TypeHereYourCertificateThumbprint");
            Console.WriteLine(outmsg);

            Console.ReadKey();
        }
    }
}


Step 3: Important for installing the Client certificate into window store
Goto Windows Search and type for Run and then type into Run window as MMC 
it will open mmc window then follow the procedure

Steps: procedure 1
Step 1 Run the MMC with different user account and provide the below details
Eg. User Name : svc_biztalk_dev password :
Step 2 Goto File menu and select
1


3 select certificate and click on add  --- ok 



4 select my user account  and click finish



Step 5  Import the certificate into Personal, TrustedPeople


Step 6 click next


Step 7 Click on Browse and select certificate which you want to import and next



Step 8 it will ask password for certificate and click next and finish.




Steps: procedure 2
Step 1 Run the MMC as administrator 
Step 2 Goto File menu and select



3 select certificate and click on add  --- ok 



4 select Computer account  and click finish




Step 5 Import certificate into Personal, TrustedPeople and Other People


Step 6  click next


Step 7 Click on Browse and select certificate which you want to import and next



Step 8 it will ask password for certificate and click next and finish.


Note : How to get thumbprint 
Goto MMC and