Rule Engine 的使用 (在biztalk流程里面调用)
有些事情,懂了就很容易,但是不懂,却要花很多时间才能弄明白。
规则的调用问题,可以参考中文文档,但是有一个关键的点却没有一点提示,害我搞了好久。
最后在英文的文档里面找到了,
To use the Call Rules shape, you must configure several areas. This topic describes the configuration issues you need to consider.
Transaction type
The parent scope where the Call Rules shape resides must be an Atomic transaction type.
Orchestration variables and fact types
In the orchestration or the scope where the Call Rules shape resides, you must have variables that match types used in the policy. If you do not have the correct types of variables, you cannot supply the correct parameters to the policy. Suppose that you have a Call Rules shape, CallMyRules, in MyScope scope, and you use CallMyRules to call MyPolicy. If a .NET class, MyClass, is used in MyPolicy, you must create a variable of a MyAssembly.MyClass type in MyScope. Similarly, if MyPolicy has DataConnection bindings, you must create a variable of a Microsoft.RuleEngine.DataConnection type in MyScope.
In addition to creating the variables in the scope that contains the Call Rules shape, you must also create instances for these scope variables. You can do this by adding an Expression shape to your scope. Using the preceding example, you should instantiate a MyAssembly.MyClass instance and a DataConnection instance. To instantiate the DataConnection instance, you do the following:
- Create a SqlConnection instance and assign it to MySqlCon.
- Create a DataConnection instance and assign it to dataConnection (the scope variable of DataConnection type), as shown in the following code fragment:
dataConnection = new Microsoft.RuleEngine.DataConnection("NameOfSqlDatabaseHere", "NameOfYourTableHere", MySqlCon);
Warning If you do not have variables matching the fact types, these types will not appear as parameters in the Specify policy parameters list box in the CallRules policy configuration dialog box.
Message type and document type
You must ensure that the DocumentType property for XML nodes used in your business rule (that you implement in the Business Rule Composer) is the same as the MessageType for those XML nodes defined in the orchestration—it must match the MessageType of the message or message part that will be passed to the rule engine in the Call Rules shape.
For example, if you define a purchase order (PO) XML schema in a BizTalk project, the MessageType defined for this schema is BTSProject.PO (if BTSProject is the namespace or the project name using the default namespace).
In the case of the PO\Amount element, before you drop it into a rule definition, you must change its DocumentType property to BTSProject.PO in the properties window. You can access the properties window when any node in the schema is selected in the XML Schemas tab in the Fact Explorer. This change is applied for all elements in the schema, but is not persisted with the schema. It must be reset when the Business Rule Composer is launched or the schema is reloaded. This is required for vocabulary definitions based either on XML schema or rules built directly from XML schema. If you do not do this, you can still execute the policy, but the Call Rules shape will not work correctly, and message type will not appear in the Specify policy parameters list box in the CallRules policy configuration dialog box.
posted on 2005-03-29 10:14 无为而为-凡事从积极的态度做起 阅读(644) 评论(0) 编辑 收藏 举报