使用Drools Workbench&的HelloWorld KIE服务器 [英] HelloWorld using Drools Workbench & KIE Server

查看:856
本文介绍了使用Drools Workbench&的HelloWorld KIE服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JBoss 7 Application Server本地实例中安装了KIE Drools Workbench 6.2.0 Final,在本地Tomcat 7实例中安装了Kie Server 6.2.0 Final.

Have KIE Drools Workbench 6.2.0 Final installed inside a JBoss 7 Application Server local instance and Kie Server 6.2.0 Final inside a local Tomcat 7 instance.

严格基于Web的KIE Workbench进行评估(将其用于代码生成基于Java的Maven项目,并且未使用诸如Eclipse或IntelliJ IDEA之类的特定IDE):

Using the web based KIE Workbench strictly for evaluation purposes (am using it to code generate Java based Maven projects and am not using a particular IDE such as Eclipse or IntelliJ IDEA):

  1. 创建了一个名为testRepo的新存储库

  1. Created a new repository called testRepo

创建了一个名为HelloWorld的新项目

Created a new project called HelloWorld

使用名为message的String属性创建了一个名为HelloWorld的新数据对象:

Created a new Data Object called HelloWorld with a String property called message:

package demo;

/**
 * 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:

  • Created a new DRL containing the following contents:

    package demo;
    
    import demo.HelloWorld;
    
    rule "hello"
    
    when 
        HelloWorld(message == "Joe");
    then
        System.out.println("Hello Joe!");
    end
    

  • 当我通过以下URL将其部署到我的Kie Server时:

  • When I deploy it to my Kie Server under this URL:

    http://localhost :8080/kie-server-6.2.0.Final-webc/services/rest/server/containers/helloworld

    当我将上述URL复制并粘贴到Google Chrome中时,我得到以下响应:

    I get the following response when I copy and paste the above URL in Google Chrome:

    <response type="SUCCESS" msg="Info for container hello">
    <kie-container container-id="hello" status="STARTED">
        <release-id>
            <artifact-id>Hello</artifact-id>
            <group-id>demo</group-id>
            <version>1.0</version>
        </release-id>
        <resolved-release-id>
            <artifact-id>Hello</artifact-id>
            <group-id>demo</group-id>
            <version>1.0</version>
        </resolved-release-id>
        <scanner status="DISPOSED"/>
    </kie-container>
    </response>
    

    1. 当我尝试使用以下负载(使用Postman或SoapUI)进行POST时:

    1. When I try to do a POST using the following payload (using Postman or SoapUI):

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

    收到以下信息:

    HTTP状态415-无法使用内容类型 类型状态报告 消息无法使用内容类型

    HTTP Status 415 - Cannot consume content type type Status report message Cannot consume content type

    说明服务器拒绝了此请求,因为请求实体的格式不受请求的方法所请求的资源支持.

    description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.

    我可能做错了什么?我去了Deploy-> Rule Deployments,并注册了我的kie-server并创建了一个名为helloworld的容器,正如从步骤5中可以看到的那样,它可以正常工作.也许我没有正确部署它?

    What am I possibly doing wrong? I went to Deploy -> Rule Deployments and registered my kie-server along with creating a container called helloworld and as one can see from Step # 5, it worked. Perhaps I am not deploying it correctly?

    顺便说一句,我使用以下堆栈溢出 post 作为基础(在问这个问题之前)...

    Btw, I used the following Stack Overflow post as a basis (prior to asking this question)...

    大多数来自Google的搜索结果仅说明了如何通过设置基于Maven的项目来以编程方式创建Drools项目.我正在评估KIE Drools工作台,以查看非技术人员使用KIE Drools工作台生成基于Drools的规则并执行它们的难易程度.

    Most of the search results from Google just explain how to programmatically create Drools projects by setting up Maven based projects. Am evaluating KIE Drools Workbench to see how easily a non-technical person can use KIE Drools Workbench to generate Drools based rules and execute them.

    我错过了一步吗?在Tomcat 7下,它仅在apache-tomcat-7.0.64/webapps/kie-server-6.2.0.Final-webc下包含以下目录:

    Am I missing a step? Under Tomcat 7, it only contains the following directories under apache-tomcat-7.0.64/webapps/kie-server-6.2.0.Final-webc:

    META-INF

    WEB-INF

    感谢您抽出宝贵的时间阅读本...

    Thanks for taking the time to read this...

    推荐答案

    我通过使用Postman(Chrome应用程序/插件)并将授权"标签选择为无身份验证"来使用它.真的很酷!

    I got it working with using Postman (Chrome app / plugin) with the Authorization tab selected to No Auth. Really cool response!

    <response type="SUCCESS" msg="Container helloworld successfully called.">
         <results>
             <![CDATA[<execution-results>
               <result identifier="message">
                    <demo.HelloWorld>
                        <message>Joe</message>
                    </demo.HelloWorld>
               </result>
               <fact-handle identifier="message" external-form="0:4:1864164041:1864164041:4:DEFAULT:NON_TRAIT"/>
    </execution-results>]]>
               </results>
    </response>
    

    这篇关于使用Drools Workbench&amp;的HelloWorld KIE服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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