简体   繁体   English

BizTalk业务规则,用于检查.csv,xml等中包含的值列表

[英]BizTalk Business Rule for checking against list of values contained in .csv, xml, etc

I'm new to BRE and fairly new to BizTalk as a whole, so this may be quite simple and just evading me... 我是BRE的新手,并且是BizTalk的新手,所以这可能很简单,只是在逃避我...

What I'd like to do is this: create a business rule in BRE that takes as an input the incoming message and checks to see if a value contained in message matches any of the values within a specified set of values. 我想做的是:在BRE中创建业务规则,将传入消息作为输入,并检查消息中包含的值是否与指定值集中的任何值匹配。 A sample message is as follows. 示例消息如下。 The <isFound> field would then be updated accordingly. 然后, <isFound>字段将相应地更新。

<n1:DocumentTemplate xmlns:n1="mynamespace">
    <rootOid>2.16.840.1.113883.3.51.60.2.5</rootOid>
    <isFound>false</isFound>
</n1:DocumentTemplate>

Basically I'd like to match the <rootOid> node against a list of values. 基本上,我想将<rootOid>节点与值列表进行匹配。 I've already created a business that will match the <rootOid> against a hardcoded value in the Conditions of the business rule...just as a proof of concept to learn the basics of how to use the BRE and call a rule in an orchestration. 我已经创建了一个业务,该业务将<rootOid>与业务规则条件中的硬编码值相匹配...只是作为概念验证,以了解如何使用BRE并在规则中调用规则编排。

I'm failing to find a way to match against a list of values beyond doing a giant list of hard-coded ORs in the "Conditions" of the Business Rule. 除了在业务规则的“条件”中编写大量的硬编码OR之外,我无法找到一种与值列表匹配的方法。 The list of accepted values is large enough that doing a bunch of ORs is not going to work. 可接受值的列表足够大,以至于无法执行一堆“或”操作。

Ideally, I'd like to have a maintainable XML file full of acceptable <rootOid> values to check against from within the business rule. 理想情况下,我希望有一个可维护的XML文件,其中包含可接受的<rootOid>值,可以从业务规则中进行检查。

I also realize that there is a way to call a database and read the values from a table/column for matching, but I'd rather keep SQL out of the equation so that this can be a little more self-contained. 我还意识到,有一种方法可以调用数据库并从表/列中读取值以进行匹配,但是我宁愿将SQL排除在等式之外,这样可以使它更加独立。

One "Equal" expression is enough. 一个“等于”表达式就足够了。 Your RHS fact should be another vocabulary item. 您的RHS事实应该是另一个词汇。 In case of XML type a proper path will pull all values one by one and cause multiple evaluations and respectively firing an action if there's a match. 如果是XML类型,则正确的路径将一一拉出所有值,并导致多个求值,如果存在匹配项,则分别触发操作。 The key to remember: BRE is a pattern matching engine. 要记住的关键:BRE是模式匹配引擎。

The vocabulary is just a convenient alias for the fact definition. 词汇表只是事实定义的方便别名。 Let's say you create an XML file with the following structure: 假设您使用以下结构创建XML文件:

<options>
  <value>A</value>
  <value>B</value>
  <value>C</value>
</options>

Define a vocabulary for this fact as Name: PossibleValues XPath Selector: /options/value XPath Field: . 为此事实定义一个词汇表,其名称为:PossibleValues XPath选择器:/ options / value XPath字段:。

Then defining a rule as IF currentValue == PossibleValues will cause three condition evaluations as the RHS yields three facts into the working memory. 然后将规则定义为IF currentValue ==可能性值将导致三个条件评估,因为RHS将三个事实产生到工作存储器中。 Consequently, only those that were true will fire a rule (Action). 因此,只有符合条件的人才能触发规则(操作)。 Compare this to the default definition BRE creates when you pick a node from the XML schema which will only assert one (first) fact: 将此与BRE从XML模式中选择一个仅断言一个(第一个)事实的节点时BRE创建的默认定义进行比较:

XPath Selector: /options/ XPath Field: value XPath选择器:/ options / XPath字段:值

(namespaces omitted for brevity) (为简便起见,省略了命名空间)

At runtime pass this XML document as an argument to the BRE (whether in the orchestration or in .Net component depending on BRE invocation context). 在运行时,将此XML文档作为参数传递给BRE(无论是在业务流程中还是在.Net组件中,具体取决于BRE调用上下文)。 At design time for testing you have to implement Fact Creator component (implements IFactCreator) to provide an instance of required arguments. 在设计测试时,您必须实现Fact Creator组件(实现IFactCreator)以提供必需参数的实例。

Long-term facts (like the one in the question) are better managed using custom fact retrievers. 使用自定义事实检索器可以更好地管理长期事实(如问题中的事实)。 Fact retriever is a .Net component that implements IFactRetriever. 事实检索器是实现IFactRetriever的.Net组件。 See the documentation for details. 有关详细信息,请参见文档 Inside fact retriever implementation load XML (from disk) and assert it into the working memory as TypedXmlDocument. 内部事实检索器实现内部(从磁盘)加载XML,并将其断言为TypedXmlDocument到工作内存中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft BizTalk业务规则语言规范 - Microsoft BizTalk Business Rule Language Specification 与编写我自己的规则检查器相比,业务规则引擎(Biztalk)有什么优势? - What are the advantages of Business Rule Engine (Biztalk) over writing my own rule checker? 在 Biztalk 中将 XML Schema 转换为 JSON 数组列表 - Conversion of XML Schema to JSON array list in Biztalk 为什么 BizTalk 管理控制台错误“无法访问规则存储提供程序。验证是否已安装和配置业务规则引擎功能” - Why is BizTalk Admin Console erroring about "Unable to access Rule Store Provider. Verify is Business Rule Engine Feature is installed and configured" BizTalk业务活动监视器 - BizTalk Business Activity Monitor 谁能告诉我有一个基于Web的Biztalk业务规则引擎编写器? - Can anyone tell me of there is a web based Biztalk business rule engine composer? BizTalk部署和业务规则 - BizTalk Deployment and Business Rules 合并多个xml并在Biztalk中输出csv - Merge more than one xml and output csv in Biztalk 将BizTalk CSV转换为XML时跳过标题(生成架构后) - Skip Header when converting BizTalk CSV to XML (After Generating Schema) 将2个输入XML模式合并到一个CSV文件中-Biztalk 2009 - Merge 2 input XML schemas into one CSV file - biztalk 2009
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM