Showing posts with label Custom Pipeline and Pipeline Component. Show all posts
Showing posts with label Custom Pipeline and Pipeline Component. Show all posts

Wednesday, 13 July 2016

Boomerang BizTalk Web Service for Transformation


In this article, I would show how to develop a Transformation Web Service in BizTalk with a simple custom pipeline component. This can be extended to leverage other BizTalk features.

Lets create custom pipeline component as shown below, this a simple component which writes the incoming property back to the RouteDirectTo and EPMRRCorrelationToken context properties, which would help us to achieve the echo back service or boomerang service.
Lets create a BizTalk project, add Source and Destination schema then add maps to do simple direct mapping from SourceA To DestinationA and SourceB To DestinationB. Finally, add receive pipeline and have XML Disassembler and our custom boomerang component as shown.
Lets deploy and configure the Application. Here we would just add a simple Two-way receive port and configure the receive location as shown below and configure the maps at the inbound map in the receive port.
Test and verify the process, refer below for execution. As you post the source message, pipeline at dissemble stage context properties are promoted and when it comes to resolver stage, boomerang component rewrites the context properties in such as way, it is subscribed the receive ports send side. Thus the transformed message are echoed back. Similar to boomerang!!  

Executing BizTalk Pipelines Inside Orchestration


In this walk through, I brief about how to execute the pipelines inside orchestration,
add references of Microsoft.XLANGs.Pipeline.dll and Microsoft.BizTalk.Pipeline.dll assemblies. In my earlier article (Custom Pipeline and Pipeline Component), Wrapper Order Request message was debatched in BizTalk Receive Pipeline using Custom Detacher Component. The same detaching logic is implemented inside orchestration.  Below process debatches the received message using SnippetDebatchRP receive pipeline, make orchestration transaction as atomic in case if we are executing receive pipeline.
Below process aggregates the message based on OrderID using correlation and as we are executing send pipeline inside orchestration and the process is of none transaction.

Encryption and Decryption of Sensitive Information using Pipeline Components in BizTalk

In this article, I will brief on encrypting and decrypting the sensitive information using custom pipeline component in BizTalk.

Lets create a class library project to implement Execute pipeline component as shown below, relevant reference are added to develop custom component.
Now, lets define properties to specify the cryption type (encryption or decryption) on data and data node as shown. Cryption Type is defined as enum type as below.
Here is the implementation of  IPersistPropertyBag interface, for CryptionType and Element Properties.
Implementation of IComponent Interface is shown below, based on the CryptionType property and Element Name specify, the data would be encrypted or decrypted.

Internal Encryption and Decryption implementation,
Lets create encryption receive pipeline and bring in EncryptDecrypt Component to Decode stage and define the properties as below.
Similarly, Send Pipeline to Decrypt the information
Deploy the solution and define a receive port and location then associate the EncryptData Receive Pipeline as shown below.
Similarly, define two send ports to subscribe the message received on the receive, 1 send port will have DecryptData Send Pipeline and other would be a simple pass through pipeline.
Pass through Send Pipeline, subscribes the encrypted message.
Process messages and verify the result. 
This mechanism allow us to transfer sensitive information in a is a secured manner and thus 3rd party system would be able to access the information.

Custom Pipelines and Pipeline Components | BizTalk


In this article, I would brief about BizTalk Pipeline and Pipeline Component. 

All messages that flow through BizTalk Server flow through receive and send pipelines. Pipelines have different stages, and each stage can include pipeline components. Pipeline components and pipelines are two completely different entities. You build pipeline components and place them within a BizTalk pipeline. 

By default, Microsoft provides Receive and Send Pipelines 

Receive Pipeline
XMLReceive - Can receive well define XML messages and promotes properties for subscription. 
PassThruReceive - Can receive any type of messages and will not promote any BizTalk Properties 
Send Pipeline
XMLTransmit - Transmit well define XML message to destination. 
PassThruTransmit - Can send any type of message. 

Receive Pipeline has Four Stages 
  • Decode 
  • Disassemble 
  • Validate 
  • Resolve party 
Send Pipeline has Three Stages 
  • Pre-assemble 
  • Assemble 
  • Encode 
To develop a custom component for pipeline we must implement the following interfaces 
  • IBaseComponent 
  • IComponentUI 
  • IComponent 
  • IPersistPropertyBag 
  • IDisassemblerComponent 
IBaseComponent: This describes the Pipeline Component Description Property, used to specify small description about pipeline component. Description is visible on pipeline properties page at design time 

Name 
Property, used to specify name of pipeline component. Name is visible on pipeline properties page at design time. 

Version 
Property used to specify version (example 1.0.0.0) of pipeline component. Visible on pipeline properties page at design time 

IComponentUI: This helps sets the Icon for component 
Icon 
Property used to provide icon associated with pipeline component. 

Validate 
Method, this is called by pipeline designer before pipeline compilation to verify that all configuration properties are correctly set. 

IComponent: Used for specific processing/massaging of messages.

Execute(IPipelineContext pContext, IBaseMessage pInMsg) Method, this does specific processing/massaging in inbound message and produces output message to be forwarded to next stages of pipeline or message box. 

IDisassemblerComponent: Used to split or break incoming message document. 

Disassemble(IPipelineContext pContext, IBaseMessage pInMsg) 
Used to split or break incoming message document. 

GetNext(IPipelineContext pContext) 
Returns messages resulting from the disassemble method execution. 

IPersistPropertyBag: This is used to set pipeline’s design time properties 

GetClassID 
Method, retrieves the component's globally unique identifying value. 

InitNew 
Method,initializes any objects needed by the component to use the persisted properties. 

Load(IPropertyBag propertyBag, int errorLog) 
Method, used to load property from property bag. 

Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) 
Method,used to save property to property bag. 

Let’s start, we assume order request contains multiple orders in a wrapper and our business process can handle 1 order at a time, hence would require to-split them as individual order request. This can be achieved by just developing a de-batch pipeline component and start receiving the order request with this pipeline component in the receive side. 

To create custom component we use class library, add reference of Microsoft.BizTalk.Pipeline.dll from the directory “C:\Program Files (x86)\Microsoft BizTalk Server 2013\Pipeline Components”. Here we would create a XML Dissembler Component for debatching the message. Implement the required interfaces (IBaseComponent,IComponentUI, IDisassembler)



Actual logical of debatching happens in the IDisassembler interface, as shown below. 
On code complete, compile and the place the dll under the directory “C:\Program Files (x86)\Microsoft BizTalk Server 2013\Pipeline Components". Thus we have created our pipeline component. Create a custom receive pipeline; then choose and load the custom debatch message from Pipeline component directory to Toolbox.
Use the component at the Disassembler Stage of the Receive Pipeline, deploy the application then configure this receive pipeline at the receive location to debatch the message at the receive side in the Admin Console.
Configure the receive location with the custom receive pipeline, start the application and test the solution by copying an XML document with structure defined by the schema inside the input folder and wait the response of the process in the output folders. 


Conclusion:
In this article, I covered the pipeline architecture in BizTalk Server. Now you can customize your own pipeline to apply for your own business scenarios. 

The video demonstration is available on the Youtube, here is the embedded video.