Saturday, September 3, 2011

Global Context Field which is independent of a Message

I was thinking of writing about a Context field which is independent of message. Imagine a Scenario where you would like to promote a field only for routing no matter what the incoming file content is, you know one thing for sure that there is a field in the content of the file(FF,XML,EDI) which has the data for routing to destination system. In this case it never makes sense to create a Schema and promote the field as Distinguished or Property field and only for routing you don’t even need to create an Orchestration.Message In….. MessageOut ….simple J
So I thought to show you how simple is it to do with BizTalk.
  1. Create a new BizTalk project and add a new Property Schema which will have our Global PropertySchema field.
  2. Let’s add a field called Property1 to this Property Schema. Set the PropertySchemaBase as MessageContextPropertybase. So by this we say that the field Property1 will not be dependent upon the message content or it won’t be linked to any field in the message. 
  3. This namespace below is important. This is the namespace in which this property field (Property1) will be promoted globally.
  4. Deploy the solution to BizTalk so our global property Schema is in BizTalk.
  5. You can promote this field from any pipeline or Orchestration as shown below. pInMsg.Context.Promote(“Property1”,"https://BizTalk_Server_Project3.PropertySchema1", "Test");
  6. If you want to access it from Orchestration then it’s important to know the .Net Namespace the property belongs to as shown below in the properties.
The Property field (Property1) can easily be accessed from the Orchestration with the .Net namespace. strProp=Msg_XmlDocumentIn(BizTalk_Server_Project3.Property1);
Simple enough…promotions are important as they can save lot of your design time to plan complex Integration's. Promotions can help you route any message from a ReceivePort to SendPort but I limit the use of such uncontrolled scenarios and use Orchestration as it gives me full control over the message for complex scenarios… ;) .

No comments:

Post a Comment