我可以使用kie-workbench规则引擎,我创建了许多规则。一切都很好。但我无法成功返回多个资产。在哪里" LoanApplication"在回应?
我的规则:
package mortgages.mortgages;
import java.lang.Boolean;
import java.lang.Number;
import java.lang.String;
import java.util.Date;
import java.lang.Integer;
//from row number: 1
rule "Row 1 Gdt2"
dialect "mvel"
when
f2 : Applicant( age > 18 )
then
f2.setAge( 18 );
f2.setApproved( true );
Applicant f10 = new Applicant();
f10.setAge( 18 );
insert( f10 );
LoanApplication f12 = new LoanApplication();
f12.setAmount( 20000 );
insert( f12 );
end
如果我通过SOAP UI restful调用上述规则:http://localhost:8080/kie-server/services/rest/server/containers/instances/mortgages_1.0.0-SNAPSHOT
{
"commands": [
{
"insert": {
"object": {
"Applicant": {
"age": 20
}
},
"out-identifier": "t1",
"return-object": true
}
}, {
"insert": {
"object": {
"Applicant": {
"age": 22
}
},
"out-identifier": "t2",
"return-object": true
}
},
{
"fire-all-rules": {}
}
]
}
{
"type": "SUCCESS",
"msg": "Container mortgages_1.0.0-SNAPSHOT successfully called.",
"result": {"execution-results": {
"results": [
{
"value": {"mortgages.mortgages.Applicant": {
"age": 18,
"applicationDate": null,
"approved": true,
"creditRating": null,
"name": null
}},
"key": "t1"
},
{
"value": {"mortgages.mortgages.Applicant": {
"age": 18,
"applicationDate": null,
"approved": true,
"creditRating": null,
"name": null
}},
"key": "t2"
}
],
"facts": [
{
"value": {"org.drools.core.common.DefaultFactHandle": {"external-form": "0:73:1097496811:1097496811:73:DEFAULT:NON_TRAIT:mortgages.mortgages.Applicant"}},
"key": "t1"
},
{
"value": {"org.drools.core.common.DefaultFactHandle": {"external-form": "0:74:1887265498:1887265498:74:DEFAULT:NON_TRAIT:mortgages.mortgages.Applicant"}},
"key": "t2"
}
]
}}
}
如果你看一下:
LoanApplication f12 = new LoanApplication();
f12.setAmount( 20000 );
insert( f12 );
此规则阻止了代码。我不能在RESPONSE中看到这样的价值。我怎么能这样做?
"value": {"mortgages.mortgages.LoanApplication": {
"Amount": 20000...
......
.....
}},
......
答案 0 :(得分:0)
要获取LoanApplication对象作为响应,您必须在请求有效负载中使用getobject方法,例如
{ "commands": [
{
"insert": {
"object": {
"Applicant": {
"age": 20
}
},
"out-identifier": "t1",
"return-object": true
}
}, {
"insert": {
"object": {
"Applicant": {
"age": 22
}
},
"out-identifier": "t2",
"return-object": true
}
},
{
"fire-all-rules": {}
},{
"get-objects":{ "identifier":"f12",
"out-identifier":"result"
}
}]}