Postman의 REST 호출이 예상 된 결과를 반환하지만 RuleServiceClient
을 사용하여 Java 응용 프로그램에서 호출 할 때 Drools 실행 서버에서 성공적이지만 EMPTY 결과를받습니다.KIE RuleServicesClient가 빈 응답을 반환합니다.
내 질문 : 내 Java 코드가 올바르지 않습니다.
아래에서 자세한 내용을 찾아보십시오.
나는 (필드 Message.MyField == 1
다음 400
이 필드를 설정 한 경우) 샘플 규칙을 만들고 나는 우체부 사용 KIE 실행 서버에 발사 할 수 있었다 :
POST 요청 http://SERVER:8080/kie-server-webc/services/rest/server/containers/instances/kie-container
에 :
{
"lookup": "defaultStatelessKieSession",
"commands": [{
"insert": {
"object": {
"Message": {
"myField": 1
}
},
"disconnected": false,
"out-identifier": "Message",
"return-object": true,
"entry-point": "DEFAULT"
}
}, {
"fire-all-rules": {
"max": -1,
"out-identifier": null
}
}]
}
응답 (제발 note "myField": 500
) :
{
"type": "SUCCESS",
"msg": "Container kie-container successfully called.",
"result": {
"execution-results": {
"results": [
{
"key": "Message",
"value": {
"bnym.test1.Message": {
"myField": 500
}
}
}
],
"facts": [
{
"key": "Message",
"value": {
"org.drools.core.common.DefaultFactHandle": {
"external-form": "0:1:1208207159:1208207159:2:DEFAULT:NON_TRAIT:myProj.test1.Message"
}
}
}
]
}
}
}
내 Java 클라이언트 코드 borrowe d는 다음과 같습니다.
public class Message{
public Integer myField;
}
. .
private static String URL = "http://SERVER:8080/kie-server-webc/services/rest/server";
private static final String USER = "user";
private static final String PASSWORD = "pwd";
. . .
public void transform() throws Exception {
Message m = new Message();
m.myField = 1;
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(URL, USER, PASSWORD);
config.setMarshallingFormat(MarshallingFormat.JSON);
kieServicesClient = KieServicesFactory.newKieServicesClient(config);
RuleServicesClient rulesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
Command<?> insert = commandsFactory.newInsert(m);
Command<?> fireAllRules = commandsFactory.newFireAllRules();
Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays.asList(insert, fireAllRules)); //0
ServiceResponse<String> executeResponse = rulesClient.executeCommands("kie-container", batchCommand);
if(executeResponse.getType() == ResponseType.SUCCESS) {
System.out.println("Commands executed with success! Response: ");
System.out.println(executeResponse.getResult());
}
}
결과 :
Commands executed with success! Response:
{
"results" : [ ],
"facts" : [ ]
}
내 질문 : 결과가 비어 있도록 내 자바 코드에 잘못된 무엇? 클라이언트가 보낸 요청을보고 그것으로 정확하지 무엇을 찾기 위해 다른 사람과 비교하는
는