Kie Workbench和Kie Server版本6.3.0上的helloworld [英] helloworld on Kie Workbench and Kie Server version 6.3.0

查看:131
本文介绍了Kie Workbench和Kie Server版本6.3.0上的helloworld的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用Blog中提供的信息在Wildfly 8.1.0.Final上设置KIE Execution Server(6.3.0.Final)和Workbench(6.3.0.Final). http://mswiderski.blogspot.in/2015/10/installing-kie-server-and-workbench-on.html 服务器和Workbench都可以正常工作,并且服务器在服务器管理浏览器"选项卡下的Workbench中可见.

I could setup KIE Execution Server (6.3.0.Final) and Workbench (6.3.0.Final) on Wildfly 8.1.0.Final using information available in blog: http://mswiderski.blogspot.in/2015/10/installing-kie-server-and-workbench-on.html Both server and Workbench are working fine and Server is visible in Workbench under "Server Management Browser" tab.

我的下一步是在服务器上部署一个简单的容器并测试REST GET和POST调用,因此我遵循了问题中提到的步骤:

My next step is to deploy a simple container on server and test REST GET and POST calls, hence I followed steps mentioned in Question: HelloWorld using Drools Workbench & KIE Server

Java和DRL代码的唯一变化是相对于软件包.下面是我的Java代码:

The only change in Java and DRL code is with respect to package. Below is my Java code:

package test.myproject;

/**
 * This class was automatically generated by the data modeler tool.
 */

public class HelloWorld implements java.io.Serializable
{

   static final long serialVersionUID = 1L;

   private java.lang.String message;

   public HelloWorld()
   {
   }

   public java.lang.String getMessage()
   {
      return this.message;
   }

   public void setMessage(java.lang.String message)
   {
      this.message = message;
   }

   public HelloWorld(java.lang.String message)
   {
      this.message = message;
   }

}

DRL文件代码:

package test.myproject;

import test.myproject.HelloWorld;

rule "hello"

when 
    HelloWorld(message == "Joe");
then
    System.out.println("Hello Joe!");
end

代码已成功构建,并已作为容器部署在服务器上.使用RESTClient/PostMan/Advanced REST Client的GET查询会给出正确的响应.

The code is built successfully and deployed as container on the server. A GET Query using RESTClient/PostMan/Advanced REST Client gives proper response.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Info for container myproject">
    <kie-container container-id="myproject" status="STARTED">
        <release-id>
            <artifact-id>MyProject</artifact-id>
            <group-id>test</group-id>
            <version>1.0</version>
        </release-id>
        <resolved-release-id>
            <artifact-id>MyProject</artifact-id>
            <group-id>test</group-id>
            <version>1.0</version>
        </resolved-release-id>
        <scanner status="DISPOSED"/>
    </kie-container>
</response>

但是,当我发布到具有以下内容的容器时:

However When I POST to container with below content:

<batch-execution lookup="defaultKieSession">
<insert out-identifier="message" return-object="true" entrypoint="DEFAULT">
    <test.myproject.HelloWorld>
        <message>Joe</message>
    </test.myproject.HelloWorld>
</insert>

请注意,我确实根据代码更改对XML进行了更改.我确实尝试过使用诸如etc之类的其他选项,但得到的响应为:

Note that I did make changes to XML as per change in code. I did try with different options like etc, but I get response as :

Status Code: 405 Method Not Allowed
Allow: HEAD, DELETE, GET, OPTIONS, PUT
Cache-Control: no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Length: 0
Date: Thu, 10 Dec 2015 05:29:09 GMT
Expires: 0
Pragma: no-cache
Server: WildFly/8
X-Powered-By: Undertow/1

不允许使用类似POST的选项,因此尝试了PUT,但得到的响应为:

Looks like POST option is not allowed, Hence tried PUT but got response as:

Status Code: 415 Unsupported Media Type
Cache-Control: no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Length: 0
Date: Thu, 10 Dec 2015 05:32:17 GMT
Expires: 0
Pragma: no-cache
Server: WildFly/8
X-Powered-By: Undertow/1

谁能告诉我我要去哪里错了.我还检查了日志文件,并在调用POST时看到以下错误:

Can anyone tell me where I am going wrong. I also checked log file and see below error when POST is called:

2015-12-10 10:59:09,208警告[org.jboss.resteasy.core.ExceptionHandler](默认任务48)无法执行:javax.ws.rs.NotAllowedException:找不到用于POST的资源方法,返回405,带有Allow标头 在org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:375)上[resteasy-jaxrs-3.0.8.Final.jar:] 在org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)上[resteasy-jaxrs-3.0.8.Final.jar:]

2015-12-10 10:59:09,208 WARN [org.jboss.resteasy.core.ExceptionHandler] (default task-48) failed to execute: javax.ws.rs.NotAllowedException: No resource method found for POST, return 405 with Allow header at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:375) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114) [resteasy-jaxrs-3.0.8.Final.jar:]

和调用PUT时出错:

2015-12-10 11:02:17,127警告[org.jboss.resteasy.core.ExceptionHandler](默认任务50)执行失败:javax.ws.rs.NotSupportedException:无法使用内容类型 在org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:380)上[resteasy-jaxrs-3.0.8.Final.jar:] 在org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)上[resteasy-jaxrs-3.0.8.Final.jar:]

2015-12-10 11:02:17,127 WARN [org.jboss.resteasy.core.ExceptionHandler] (default task-50) failed to execute: javax.ws.rs.NotSupportedException: Cannot consume content type at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:380) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114) [resteasy-jaxrs-3.0.8.Final.jar:]

推荐答案

它现在正在工作.所需的更改如下:

It is working now. Changes needed are as follows:

在POST期间要调用的URL是: http://localhost :8080/kie-server/services/rest/server/containers/instances/myproject

URL to call during POST is : http://localhost:8080/kie-server/services/rest/server/containers/instances/myproject

从6.3.0开始需要使用实例(请注意:))

From 6.3.0 onward instances needs to be used (Make note of it :))

6.3.0中的KIE服务器支持JAXB,JSON和Xstream.由于默认值为JAXB,因此您需要提供JAXB有效内容.或者,您可以设置HTTP标头以通知KIE Server使用Xstream作为编组器: 标题名称:X-KIE-ContentType 标头值XSTREAM

KIE Server in 6.3.0 supports JAXB, JSON and Xstream. Since default is JAXB you would need to provide JAXB valid content. Alternatively you could set HTTP header to inform KIE Server to use Xstream as marshaller: Header name: X-KIE-ContentType Header Value XSTREAM

因此设置适当的标题

最后,XML的格式应为:

Finally XML should be in the form:

<batch-execution lookup="defaultKieSession">
  <insert out-identifier="test">
    <test.myproject.HelloWorld>
      <message>"Joe"</message>
    </test.myproject.HelloWorld>
  </insert>
  <fire-all-rules/>
  <get-objects out-identifier="test"/>
</batch-execution>

注意输出"Hello Joe!".在命令提示符下.

Watch out the output "Hello Joe!" in command prompt.

感谢 Maciej Swiderski 提供的所有支持

这篇关于Kie Workbench和Kie Server版本6.3.0上的helloworld的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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