BizTalk Environment Specific Bindings

      No Comments on BizTalk Environment Specific Bindings

When you start, or already are, using the BizTalk Deployment Framework in your BizTalk Server solutions, you will get to a point where you need some additional skills how to address your specific needs. There is a lot of documentation for specific needs according to the BizTalk Deployment Framework written by the community out there. How to use the different settings, how to prepare your deployments and a lot of other tips and tricks. For my scenario I wanted to know how I could configure environment specific bindings so I could deploy the same Send Port to different environments with different Adapters. To share this knowledge, I have created a sample solution with the BizTalk Software Factory. You can read more about creating a BizTalk Solution with the BizTalk Software Factory in this blog post I have written. In this scenario I want to use the File Adapter in the development environment, and the WCF-BasicHttp Adapter in the test, acceptance and production environment. The steps for implementing the scenario can be found in this blogpost. For completing the steps below, I assume you have already gained some experience with creating and deploying BizTalk Server Solutions with the BizTalk Deployment Framework. Off course, if you have any questions, please leave a comment, and I will reply as soon as possible.

Prerequisites

To be able to perform the steps to create your first BizTalk Software Factory Solution, make sure you have installed the prerequisites below.

These versions of the software are the ones I have used because I am working with the latest version (2013 R2) of BizTalk Server. You can find other versions to use from BizTalk Server 2006 and up here.

Create the Solution Bindings.Per.Environment

Create a new application Binding.Per.Environment using the BizTalk Software Factory

Create two simple incoming and outgoing Schemas


Create a Mapping between those schemas

Build the solution in Visual Studio and deploy with BizTalk Deployment Framework.

Create a Receive Port and Receive Location.

Create a Send Port

Add the Mapping to the Send Port

Add the Filter on the Send Port with the Receive
Port name

Start the application, generate an instance of the incoming schema with Visual Studio to test if out configuration is working.

Copy the generated instance in the IN folder.

Check the result in the OUT folder.

Create the File Adapter binding

Go to the Application in the BizTalk Server Administration Console and Export the bindings

Open the bindings in any notepad editor. Notepad++ in my case

Select and Copy the complete content of Binding.Per.Environment.BindingInfo.xml.

Open the PortBindingMaster.xml in Visual Studio

Select the content of the PortBindingMaster.xml and Delete the default binding information.

Paste the contents of Binding.Per.Environment.BindingInfo.xml into the PortBindingMaster.xml

Don’t forget to undo the Format XML by clicking on it!!

Redeploy and test the application. Make sure everything works as expected.

Create the WCF-BasicHttp Adapter binding

Create a WCF Service with the BizTalk WCF Service Publishing Wizard.

Fill in the fields like below

Click Next twice and select Publish Schema as WCF Service

Click Next and Delete web method and click Yes to delete it.

Right click the web service and choose Add web Method to create a One-way web method.

Change the naming of the components of the service like belowm and select the schema SchemaOutgoing

Click Next

Change the target namespace to http://Binding.Per.Environment/ and click Next

Click Next twice and click Finish

Start the application and browse to http://localhost/BindingWcfService/bindingService.svc

Now create a Send Port that writes the file to disk we receive on the BindingWcfService

Filter on the Receive Port WcfReceivePort_BizTalkWcfService/BindingService

Right click the Schema project and choose Add Generated Items

Click Add and click Next to skip the welcome page

Choose the option Metadata Exchange (MEX) endpoint and click Next

Click Next and fill in the Metadata Address (URL) field http://localhost/BindingWcfService/bindingService.svc?WSDL

Click Next and fill in the namespace

Click Import and Finish

Delete the generated BizTalkServiceInstance.odx from the schema project

Change the namespace of the generated schema because this is the same as the SchemaOutgoing

Add a new mapping with the BizTalk Software Factory to the Mapping project

Select the SchemaIncomming as the source schema
and the generated schema as the destination schema.

Create a simple Mapping

Import the generated bindings BizTalkServiceInstance.BindingInfo.xml into the application Binding.Per.Environment

Open the new Send Port and apply the Filter

Delete port sndPrtSchemaOutgoing and start port WcfSendPort_BizTalkServiceInstance_BasicHttpBinding_ITwoWayAsyncVoid.

Test the application. Make sure everything works as expected. You should get an output file in the WS OUT folder.

Create the Environment Specific Bindings

We have now come to the point where we can create the Environment Specific Bindings!

Go to the Application in the BizTalk Server Administration Console and Export the bindings

Open the file Binding.Per.Environment.Deployment.btdfproj

Add or change the following in the first
PropertyGroup section

Right click the SettingsFileGenerator.xml in the Solution
Explorer and click Open with…

Add the setting Environment and add the correct values

Open the exported binding file Binding.Per.Environment.BindingInfo.WebService.xml in any notepad editor. Notepad++ in my case and copy the complete Send Port section

Paste this under the file send port in the PortMasterBinding.xml.

Don’t forget to undo the Format XML by clicking on it!!

Enclose the File port with the statements below.

 

And the Wcf port with the statements below.

Test the application by deploying the application with the local_setting = DEV in the SettingFileGenerator.xml

When everything is working as expected, then deploy the application with the local_setting = TST in the SettingFileGenerator.xml

Create the Send Port for all environments

Apply the correct filter

Apply the mapping

Export Bindings, Copy the newly created Send Port and enclose with the statements below

Test both settings by changing the local_settings in the SettingFileGenerator.xml to DEV and TST

Now add the OR statement like below, to have the WcfSendPort also deployed to ACC and PRD.

Test these settings by changing the local_settings in the SettingFileGenerator.xml to ACC or PRD.

Open the PortBindingMaster.xml and replace the ReceivePort name Local_rcvPortSchemaIncommin with ${rcvPrtSchemaIncommingName} and enclose the receive port section with the statements below

Right click the SettingsFileGenerator.xml in the Solution
Explorer and click Open with…

Add the setting rcvPrtSchemaIncommingName and add the correct values

Test these settings by changing the local_settings in the SettingFileGenerator.xml to DEV, TST, ACC and PRD.

Create the Server MSI

In Visual Studio go to Tools\Deployment Framework for
BizTalk\Build Server Deploy MSI

When finished successfully you can find the msi Binding.Per.Environment-1.0.0.msi in location ..\BindingPerEnvironment\Binding.Per.Environment.Deployment\bin\Debug

You can now Install the MSI with the Environment Specific Bindings on the different servers.

This completes all the steps needed to create the BizTalk Server Solution with the Environment Specific Bindings with the additional steps for managing different environment settings.

Leave a Reply

Your email address will not be published. Required fields are marked *