While exposing a REST service from BizTalk I wanted to quickly change some distinguished properties to promoted properties . Rather than rolling my own pipeline component I used the BRE Pipeline Component Framework . The author of this Johann Cooper, wrote has own walkthrough. I record my experience of using this framework here.
The Problem
If you expose a REST service from BizTalk , the URL parameters only appear as distinguished properties on inbound message. For example consider the following HTTP methods on a WCF-WebHTTP receive location;
The URL mapping required for the GET methods is;
The Rcv_AnimalData contains a custom pipeline component that adds a XML message body part if the body part is blank. It also has a XML dissembler. A GET request does not have a payload.
Now after issuing a GET request like http://localhost/AnimalDataTransfer/Service1.svc/Animals/eid/982%20000000123456 a message arrives in the message box with the following context.
I want to promote the URL request parameters that are in red circles.
Using the BRE Pipeline Framework
I downloaded the v1.3.1 installer from Codeplex and ran the installer. It did not install the BREPipelineFrameworkComponent.dll into C:\Program Files (x86)\Microsoft BizTalk Server 2013\Pipeline Components as promised but did deploy these assemblies to the GAC_MSIL; BREPipelineFramework.dll, BREPipelineFramework.Helpers and BREPipelineFramework.SampleInstructions.dll.
After searching for awhile I discovered the BREPipelineFrameworkComponent.dll in the Microsoft BizTalk Server 2010\Pipeline Components folder and copied it over.
Next I imported all the vocabularies in the C:\Program Files (x86)\BRE Pipeline Framework\Vocabularies folder using the Business Rules Engine Deployment Wizard. Opening the Business Rules composer I saw all the new vocabularies below.
The first configuration step was to create a BRE policy called InstructionLoaderAnimalData. I created two rules for this policy that load the default instruction loader for the SampleInstructions vocabularies, GetAllAnimals and GetAnAnimal.
To create the GetAllAnimals rule I chose the GetBTSContextProperty vocabularies as argument1 of a equals predicate condition, set the Operation from the dropdown menu and choose DefaultType of empty string if BTS.Operation does not exist on the message. I set the value of argument2 to “GetAllAnimals”. The BTS.Operation value is set in the HTTP method on the receive location. The action set by dragging the AddMetaInstruction to the Actions, filling out the default classname and assembly name for the SampleInstructions as shown below.
To create the GetAnAnimal rule I copied the GetAllAnimals rule to create a new rule. I then changed the value of argument 2 in the predicate condition to “GetAnAnimal”.
The second configuration step was to create a BRE policy called ExecutionAnimalData, I created two rules, GetAllAnimals and GetAnAnimal, for this policy that promote the context properties that are set in the variable mappings on the WCF-WebHttp receive location.
To create the GetAnAnimal rule I used the same condition that i used Instruction loader policy rules above. The action was set by dragging the SetCustomContext Property vocabulary to the Action pane,
dragging the GetBTSContextProperty to the first empty string value,
choose Promote from the first drop down, choose Operation from the second dropdown, choose DefaultType of empty string if BTS.Operation does not exist on the message, choose string for the context property type, choose the name of the property and the property namespace. The final rule looked like
To create the GetAllAnimals rule copy the GetAnAnimal rule to create a new rule. Next ,
change the value of argument 2 in the predicate condition to “GetAllAnim als”.
The final rules configuration step was to deploy all the policy rules.
I now added and configured the BREPipelineComponent in the existing Rcv_AnimalData pipeline by opening my existing BizTalk Visual studio project. After choosing the BREPipelineFrameworkComponent from the Toolbox choose, I dragged it to the decode stage of the pipeline. I filled the ApplicationContext with the name of the pipeline. I am not sure what i would use the Pipeline Component property for because I can get at all the context properties for a receive or send location. I added the ExecutionAnimalData policy to the ExecutionPolicy property and the InstructionLoaderAnimalData to the ExecutionPolicy property.
I compiled and redeployed the pipeline and restarted IIS and the in-process hosts.
Now if I issue a GET request like http://localhost/AnimalDataTransfer/Service1.svc/Animals/eid/982%20000000123456 again a message arrives in the message box and the context for the URL parameters are now all promoted.
Conclusions
The BRE pipeline framework allowed me;
- to quickly modify some context properties by adding the BRE pipeline component to my existing pipeline. It took significantly less time than rolling my own pipeline component to do the same promotions.
- to configure the logic property promotion using pre-configured business rule vocabularies.
The framework seems complex to begin with because it is almost bomb proof but it is well worth your while to persevere because it contains some real gems. I am not sure I would want to add my own meta-instructions to introduce some new functionality but it is nice that that extensibility is available.
The BRE pipeline framework is well worth a look and i think it should be included in every BizTalk developer’s toolkit because it can speed up your time to implementation and removes the need to create many pipelines that manipulate context properties