可能这个问题已经被问过很多次了,但我无法通过它们找出实际的解决方案。我在KIEWorkbench中有一个决策表,它从一个事实中获取输入,并将其设置为另一个事实。我试图通过调用端点来调用规则:http://localhost:8085/kie-server-6.4.0.Final-ee7/services/rest/server/containers/instances/pocResult
在header中,我将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>
我想要带有日期集的结果对象。
您得到的响应是什么?
我首先尝试在返回对象之后放置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>
我使用JBPM 7.0.0-SNAPSHOT并得到与您相同的结果。当我在6.2.0中使用相同的规则时。最后,我得到了结果。
编辑:
关键问题是头:授权:基本YWRtaW46YWRtaW4 =内容类型: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>