Kie Workbench执行规则

时间:2016-09-07 14:18:16

标签: drools kie-workbench

可能这个问题已被问过多次,但我无法通过它们找出实际的解决方案。我在KIEWorkbench中有一个决策表,它从一个事实中获取输入并将其设置为另一个事实。我试图通过调用端点来调用规则:https://askubuntu.com/a/568596/159234

在标题中,我将Content-Type设置为application / xml。

    <batch-execution lookup="ksession">
    <insert out-identifier="Subject">
       <demo.pocFindResult.Subject>
         <bCode> ABC</bCode>
         <bGCode>XY</bGCode>
         <pCode>L0001</pcode>
         <subjectType>CA</subjectType>
       </demo.pocFindResult.Subject>
     </insert>
     <fire-all-rules />
    <get-objects out-identifier="Result">
       <demo.pocFindResult.result/>
    </get-objects>

我的决定表如下:

    package demo.pocFindResult;

    //from row number: 1
    rule "Row 1 findrules"
        ruleflow-group "fire-rules"
        dialect "java"
        lock-on-active true
        no-loop true
        when
            sub : Subject( bCode == "ABC" , bGCode == "XY" , subjectType == "CA" , pCode == "L0001" )
        then
            Result rs = new Result();
            rs.setResultStartDate( "*TODAY" );
            rs.setResultEndDate( "*YEAREND" );
            rs.setResultContentStartDate( "*TODAY" );
            rs.setResultContentEndDate( "*YEAREND" );
            insert( rs );
    end

如何将Result对象作为响应?以下是我的回复:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response type="SUCCESS" msg="Container pocResult successfully called.">
        <execution-results>
            <results>
                <item key="Subject">
                    <value xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <type>LIST</type>
                    </value>
                </item>
            </results>
            <facts>
                <item key="Subject"/>
            </facts>
        </execution-results>
    </response>

我希望结果对象设置日期。

2 个答案:

答案 0 :(得分:0)

你得到的回应是什么?

我首先尝试在返回对象后放置fire-all-rules标记。否则,我会尝试:

   <batch-execution lookup="ksession">
<insert out-identifier="Subject">
   <demo.pocFindResult.Subject>
     <bCode> ABC</bCode>
     <bGCode>XY</bGCode>
     <pCode>L0001</pcode>
     <subjectType>CA</subjectType>
   </demo.pocFindResult.Subject>
 </insert>
<insert out-identifier="Result" return-object="true" entry-point="DEFAULT">
   <demo.pocFindResult.result/>
</insert> 
<fire-all-rules/>
</batch-execution>

答案 1 :(得分:-1)

我正在使用JBPM 7.0.0-SNAPSHOT并获得与您相同的结果。当我在6.2.0.Final中使用相同的规则时,我得到了结果 编辑:

关键问题是标题: 授权:基本YWRtaW46YWRtaW4 = 内容类型:application / xml, 然后我添加了另一个标题:

&#34; X-KIE-ContentType:XSTREAM&#34;

<batch-execution lookup="defaultKieSession">
<insert return-object="true">
    <com.bp.PageContext>
        <ID>AID</ID>
    </com.bp.PageContext>
</insert>
<insert out-identifier="Group" return-object="true">
    <com.bp.GroupData>
    </com.bp.GroupData>
</insert>
<insert out-identifier="ERR" return-object="true">
    <com.bp.ErrorMessage/>
</insert>
<fire-all-rules/>
<get-objects/>
</batch-execution>

我得到了结果:

<org.kie.server.api.model.ServiceResponse>
<type>SUCCESS</type>
<msg>Container bpcontainr successfully called.</msg>
<result class="execution-results">
    <result identifier="Group">
        <com.bp,GroupData>
            <Code>TEST,QA</Code>
        </com.bp.GroupData>
    </result>
    <result identifier="ERR">
        <com.bp.ErrorMessage/>
    </result>
    <fact-handle identifier="Group" external-form="0:8:567620710:567620710:8:DEFAULT:NON_TRAIT:com.bp.GroupData"/>
    <fact-handle identifier="ERR" external-form="0:9:1581854082:1581854082:9:DEFAULT:NON_TRAIT:com.bp.ErrorMessage"/>
</result>
</org.kie.server.api.model.ServiceResponse>