2

可能这个问题已经被问过很多次了,但我无法通过它们找出实际的解决方案。我在 KIEWorkbench 中有一个决策表,它从一个事实中获取输入并将其设置为另一个事实。我试图通过调用端点来调用规则:http://localhost:8085/kie-server-6.4.0.Final-ee7/services/rest/server/containers/instances/pocResult

在标题中,我将 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>

我想要设置日期的结果对象。

4

2 回答 2

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>
于 2016-09-07T21:09:25.643 回答
-1

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

关键问题是标题: Authorization:Basic YWRtaW46YWRtaW4= Content-Type:application/xml ,然后我添加了另一个标题:

“X-KIE-ContentType:XSTREAM”

<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>
于 2016-11-15T03:03:05.973 回答