【问题标题】:ServiceResponse Result is always null (JAXB, KIE Workbench & KIE Server 6.5.0)ServiceResponse 结果始终为空(JAXB、KIE Workbench 和 KIE Server 6.5.0)
【发布时间】:2017-08-04 10:17:39
【问题描述】:

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

这是我发送的 JAXB 请求:

<?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 控制台中,我看到打印的行没有任何附加信息(如错误的堆栈跟踪),所以我认为一切正常:

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

但我总是得到相同的响应:它表明“进程”已正确终止(所以乍一看),因此我期待 Result 有一些东西(一个空的 xml 响应,一个带有一些数据的 xml 响应在里面,...):

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 调用客户端:

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()); 

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

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

这个问题也在: Drools User group

【问题讨论】:

标签: jaxb kie drools-kie-server


【解决方案1】:

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

任何有兴趣通过通用客户端项目与 KIE Server 6.5.0 建立连接的人都可以查阅 my GitHub 上的代码。

【讨论】:

    猜你喜欢
    • 2018-02-22
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 1970-01-01
    相关资源
    最近更新 更多