Blogging BizTalk

Lets Discuss BizTalk

Tag Archives: BT Group

Using Envelop Schema In BizTalk : Demo


What is Envelope Schema: It is a special type of schema which will allow you to carry multiple Payload messages wrapped in a single schema.

Where you Can Use it: Debatching, Aggregation.

The purpose of writing this post is to make us understand how it functions by picking up a simpler scenario, you can build on top of it to achieve more complex need.

What This Solution Does: Debatching

For the sake of simplicity I have created one envelope schema and one Payload Schema(Instances of which will be wrapped within envelope schema).

I have created a XML file Rcv Location where we will drop our envelope XML.Further I have created a send port having a subscription to the above Rcv port, hence whatever message arrives on the receive port will be sent to this send file location.

Our project is going to look like this:
Solution

For the sake of simplicity I have created only two schemas
1>SKU.xsd : It is your normal document schema.
2>SKUEnvelope.XSD : it is your envelope schema which will carry multiple SKU message XML within. Please see the picture.SchemaInstance

To create an envelope Schema you need to set the property Envelope to yes at the <Schema> node, and then you need to set the BodyXPath to the xpath of the node having the <any> element. Please see the below picture.

CreateEnvelope

Once you have done that please go ahead and deploy. Create the receive and send port.
Now drop your envelope xml file to the receive location. The one I have used in this example has 4 SKU xml messeges wrapped within envelope schema. Hence when that gets picked up by the XMLReceive pipeline (This is the one which does the debatching) it results in 4 separate trigger of XML transmit pipeline component in turn reflecting on your  send port which will have 4 separate files each representing individual SKU payload XML we had wrapped within the envelope xml.

Execution

Please drop me a comment if you need any clarification. I will get back to you ASAP.

Debugging Orchestration : Writing into Event Log


Sometime if you are using canonical schema or need to know the value of a variable at runtime then you may want to consider taking this approach : write into event log and check the values in event viewer after execution. Use an expression editor and place these lines over there.

varXML = new System.Xml.XmlDocument();

varXML= YourXMLmsgToBeLogged;

System.Diagnostics.EventLog.WriteEntry(“This is my logged XML:”,varXML.OuterXml);

 

 

OR

 

Refer to Microsoft.Practices.EnterpriseLibrary.Logging and place this in expression.

 

Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(“You Information to be logged”);

 

Please leave a comment if you have any questions and I will get back ASAP.

Simple Message Based Routing BizTalk


When a message is passed throught the BT server without being processed or transformed within it falls under the category of message based routing. I am trying to cover a very basic example to understand message based routing here.

1> Create a new BizTalk project and add a new schema complying to the incoming xml.  Set the property ElementFormDefault to qualified.

2>Create a strong name key using following command in VS command prompt window sn -k DemoSNKey.snk  (in place of DemoSNKey you can use your own name) and in the project properties sign the assembly

Deploy the project : The purpose of deploying the schema here is to insure BizTalk recognizes the messagetype.

——————————————————-NOTE——————————

if you have not deployed the schema and you are using XMLRcv and XMLTranmit pipeline component in your ports you will get an error which may appear like this:

There was a failure executing the receive pipeline: “Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “XML disassembler” Receive Port: “ReceiveOrder” URI: “D:\**********************” Reason: Finding the document specification by message type “http://*******************************” failed. Verify the schema deployed properly.

However if you have used PassThruReceive and PassThruTransmit  pipeline component you need not deploy the schema

——————————————————————————————–

3>Go to BizTalk Admin Console into the application container where you have deployed your project. Create a ReceivePort of type file. After this create a send port of type file. The reason we are using a file type port is for testing convenience.

You can set either of these two filter properties on the send port to achieve message based routing here:

  1. BTS.ReceivePortName
  2. BTS.MessageType.

Schema

If you use BTS.ReceivePortName all the messages coming into BT server on this port will be subscribed by the Send port.

If you use  BTS.MessageType then only the messages with a matching message type (namespace # root node)will be subscribed by the send port.

4>Enable the receive location and start the send port now followed by restarting the Handler under Host instances.

Drop your file to receive  location and you shall be able to see a new one created on the send location. This solution should work now to achieve message based routing.

This is a very basic example  and doesn’t have much scope for questions. However if you have any questions please feel free to leave a comment, I will get back as and when possible.

Simple Content Based Routing Using Send Receive Ports in BizTalk


When the routing decision within the BT server are made based on the content of the message it falls under the category of the message based routing

Example:

In this example I am taking a sample incoming order message and based on the “State” node value we may need to route to respective locations, for example SendLocationStateTN and SendLocationStateME. Below is the picture of how our invoice schema will look.

Image

Create a schema for incoming order in you BizTalk project.

2>We need to route the message based on the value of ‘State’ node hence we need to ensure this property is written to the context of message. This can be achieved by promoting the ‘State’ node. It can be achieved by right clicking on the desired node to be promoted and pick promote>>quick promotion, you will see following alert from VS

“Visual Studio will create a property schema that contains all your quick promotions. Do you want to add the property schema to your project?”
Go ahead and say yes to it.

3>Now the state value will be available in the filter properties for us to use. Lets create a receive port of file type and define a receive localion in you machine.

4>Create 2 send location to cater to TN and ME state values per the inital requirement.

Apply following filters there in both ports respectively.

BTS.ReceivePortName == ReceiveOrder  And
SimpleRoutingDemo.PropertySchema.State == TN   Note:SimpleRoutingDemo is the name of my BizTalk project in visual studio.

and

BTS.ReceivePortName == ReceiveOrder  And
SimpleRoutingDemo.PropertySchema.State == ME  

5>It is ready for content based routing . Any xml with state as ME shall go to SendLocationStateME and with  state as TN will go SendLocationStateTN.

This is a very simple example of content based routing using ports only. Please note we can achieve it in multiple ways for example by using orchestrations or ESB. Please let me know if you have any questions

D Goins Insperience

Technological outformation for this day and age

[INACTIVE BLOG] Connected Thoughts - Thiago Almeida

Connected systems and the occasional picture

Uri Katsir's Blog

BizTalk , BizTalk RFID and .NET

prashantbiztalkblogs

My BizTalk Experiences

BizTalk Server Tutorial

BizTalk Server Concepts and Common Errors

Extremely Talented Monkeys

A Technical Blog by Ed Jones: Azure, .NET, BizTalk, WCF, and SQL Server

On All Things Web

Discussing web development without limits

Vikas Bhardwaj's Blog

Articles about BizTalk Server and .NET C#

Cloud develop

a blog about (cloud) development... because I'm a nerd

Hooking Stuffs Together

My learning logs from day to day work experience about Integration platform using Microsoft technologies.

Connected Pawns

Mainly BizTalk & Little Chess

jhelatissimo

a blogger in the process.

MS Innovations Blog

Tips, Tricks, and Workarounds for BizTalk and other Microsoft technologies

srirambiztalks

Katradhu Kaialavu,Kalladhadhu Ulagalavu!

Vijay Microsoft Technical

BizTalk, WCF, ESB ToolKit, Windows Azure

Mind Over Messaging

Musings on BizTalk, Azure, and Enterprise Integration