2
votes

May be this question has been asked number of times but I could not figure out the actual solution by going through them. I have a decision table in KIEWorkbench which takes the input from one fact and sets it into another fact. I am trying to call the rules by invoking the endpoint: http://localhost:8085/kie-server-6.4.0.Final-ee7/services/rest/server/containers/instances/pocResult

In the header, I have set the Content-Type as 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>

My Decision table is as below:

    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

How can I get the Result object as the response? Here is my response:

    <?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>

I want the result object with the dates set.

2

2 Answers

0
votes

What is the response you get?

I would firstly try to place fire-all-rules tag after your return object. Otherwise, I would try:

   <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
votes

I am using JBPM 7.0.0-SNAPSHOT and got the same result as yours. When I used the same rules in 6.2.0.Final, I had result back.
EDIT:

The key problem is the header: Authorization:Basic YWRtaW46YWRtaW4= Content-Type:application/xml , Then I added another header:

"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>

I've got the result back:

<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>