ServiceResponse结果始终为空(JAXB,KIE Workbench& KIE Server 6.5.0) [英] ServiceResponse Result is always null (JAXB, KIE Workbench & KIE Server 6.5.0)

查看:160
本文介绍了ServiceResponse结果始终为空(JAXB,KIE Workbench& KIE Server 6.5.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在KIE Workbench,6.5.0版本和KIE执行服务器6.5.0上运行了一个项目,所有这些都在同一个本地Wildfly 10上运行。它工作正常。
我有一个简单的规则,正在无状态的KieSession中执行,没有任何进程或任何进程。我希望该规则可以验证基本信息并将有关已触发的验证的信息添加到全局变量中。在我测试的示例中,我只是修改一个全局变量以查看它是否有效,但由于某种原因,我从来没有从服务中得到结果,我希望至少有一些结果。

I have a project setup in KIE Workbench, version 6.5.0 and a KIE execution server 6.5.0 running, all on the same local Wildfly 10. It is working fine. I have a simple rule that is being executed in a stateless KieSession, no process or whatsoever. I expect the rule to validate basic information and to add information about the fired validations to a global variable. In the example I am testing I just modify a global variable to see if it works, but for some reason I never get a result from the service, which I expect to have at least something.

这是我发送的JAXB请求:

This is the JAXB request I send:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<batch-execution lookup="kieSessionStateless">
    <insert disconnected="false" entry-point="DEFAULT" return-object="false" out-identifier="myorganization.myproject.bom.MyObject">
        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="myObject">
            <myDescription>description</myDescription>
            <myID>0</myID>
        </object>
    </insert>
    <set-global out-identifier="globalList" identifier="globalList">
        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
            <type>LIST</type>
        </object>
    </set-global>
    <get-objects out-identifier="globalList"/>
    <fire-all-rules max="-1"/>
</batch-execution>

执行的规则非常简单:

rule "MY FIRST RULE"

    when
        myorganization.myproject.bom.MyObject( myID == 0 )
    then
        myorganization.myproject.bom.GlobalResponses globalResponses = new myorganization.myproject.bom.GlobalResponses();
        globalResponses.setRuleName("MY FIRST RULE");
        globalResponses.setRuleResponse("MY ID IS 0");
        globalList.add(globalResponses);
        System.out.println("MY ID IS 0");

end

在Wildfly控制台中,我看到没有任何打印的行附加信息(如错误的堆栈跟踪),所以我总结一切正常:

And in the Wildfly console I see the line printed without any additional information (like a stacktrace of an error), so I conclude all is working well:

13:04:36,315 INFO  [stdout] (default task-39) MY ID IS 0

但我总是得到相同的答案:它表示进程已正确终止(所以它似乎乍一看),因此我期待Result有一些东西(空的xml响应,包含一些数据的xml响应,......):

But I always get the same response: it indicates that the "process" has terminated correctly (so it seems at first sight) and therefore I am expecting that Result has something (an empty xml response, an xml response with some data in it, ...):

System.out.println("Message: "+response.getMsg());
System.out.println("Result: "+response.getResult());
System.out.println("Type: "+response.getType());

Message: Container KieContainer successfully called.
Result: null
Type: SUCCESS
Response: ServiceResponse[SUCCESS, msg='Container KieContainer successfully called.']

使用KieServicesClient调用客户端:

The client is called with KieServicesClient:

KieServicesConfiguration config =  KieServicesFactory.
                newRestConfiguration(urlKieServer,
                    name,
                    password);
config.setMarshallingFormat(MarshallingFormat.JAXB); 
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);  

JAXBContext jaxbContext = DroolsJaxbHelperProviderImpl.createDroolsJaxbContext(classNames, null);
Marshaller marshaller = jaxbContext.createMarshaller(); 
StringWriter xml = new StringWriter(); 
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

marshaller.marshal(command, System.out);
marshaller.marshal(command, xml);

ServiceResponse<String> response = client.executeCommands("instances/"+containerName, xml.toString()); 

我遗失了一些东西,但我真的不知道是什么。

I am missing something but I really do not know what.

所有相关项目均在 GitHub 上。由于我不能发布两个以上的链接,我会在评论中添加直接链接。

All the related projects are on GitHub. Since I cannot post more than two links, I will add the direct links in a comment.

这个问题也在:
Drools用户组

推荐答案

我能够完成生命周期并发送有效请求并获得有效答案。我的部分问题是用于构造XML的代码。构造有效JAXB请求的最佳方法是使用KIE提供的API,可以找到一个例子
此处

I was able to complete the life cycle and send a valid request and obtain a valid answer. Part of my problem was the code used to construct the XML. The best way to construct a valid JAXB request is by using the API provided by KIE, an example can be found here.

无论如何,有兴趣建立与通用客户端项目的KIE Server 6.5.0的连接,可以参考 my GitHub

Anyway interested in establishing connection to a KIE Server 6.5.0 with a generic client project can consult the code on my GitHub.

这篇关于ServiceResponse结果始终为空(JAXB,KIE Workbench&amp; KIE Server 6.5.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆