Wednesday, January 17, 2007

Passing an Array of Facts into the Rules Engine

Passing an Array of Facts into the Rules Engine (BizTalk 2004)

The last piece of the puzzle for me in working with generic messages to do away with a TON of duplication is to dynamically call a rules policy to validate outbound EDI messages.

This is some sample code I found on the blog mentioned above:

//System.Collections.ArrayList List;
sCon = "Initial Catalog=Northwind;Data Source=(local);Integrated Security=SSPI;";
con = new System.Data.SqlClient.SqlConnection(sCon);
dcNorthwind = new Microsoft.RuleEngine.DataConnection("Northwind", "ShipperCountry", con);

xmlDocument = msgShippingRequest;
typedXmlDocument = new Microsoft.RuleEngine.TypedXmlDocument("RoleLinkSample.ShippingRequest",xmlDocument);
policy = new Microsoft.RuleEngine.Policy("ShippingPolicy");

msgOutgoingShippingRequest = typedXmlDocument.Document;
typedXmlDocument = null;
dcNorthwind = null;

This sample is based on Biztalk 2004, but should not differ in this instance for Biztalk 2006.

No comments: