Mule Restlet 应用程序无法运行

发布于 2024-12-20 09:48:18 字数 1777 浏览 1 评论 0原文

这是嵌入在 Mule 中的 RESTful 接口,它接受用户名并输出“hello, $name”

以下是 mule-config.xml

       <model name="greetingModel">
          <service name="greetingService">
              <inbound>
                  <inbound-endpoint address="http://localhost:9004"/>
              </inbound>
              <outbound>
                  <filtering-router>
                      <outbound-endpoint address="vm://greeting"/>
                      <restlet:uri-template-filter pattern="/hello/{set-payload.name}" verbs="GET"/>
                  </filtering-router>
              </outbound>
          </service>
          <service name="greeting">
              <inbound>
                  <inbound-endpoint address="vm://greeting" exchange-pattern="request-response"></inbound-endpoint>
              </inbound>
              <component class="com.ggd543.mulerestletdemo.GreetingComponent"></component>
          </service>
    </model>

和组件类

package com.ggd543.mulerestletdemo

import org.mule.api.lifecycle.Callable
import org.mule.api.MuleEventContext

class GreetingComponent  extends Callable {

  def onCall(eventContext: MuleEventContext) = {
      val name = eventContext.getMessage.getPayload.asInstanceOf[String]
      sayHello(name)
  }

  def sayHello(name: String) = {
    val msg = "hello, "+name
    println(msg)
    msg
  }
}

中的部分内容成功部署应用程序后,我尝试访问 http://localhost:9004/hello/archer 在我的浏览器中,但是什么也没发生。

有什么问题吗mule-config.xml ?

PS:我的 mule 版本是 3.1.2,我使用的是 mule-transport-restlet-1.1.3.jar

This is a RESTful interface embedding in Mule, which accepts a username and output "hello, $name"

The following is part of content in mule-config.xml

       <model name="greetingModel">
          <service name="greetingService">
              <inbound>
                  <inbound-endpoint address="http://localhost:9004"/>
              </inbound>
              <outbound>
                  <filtering-router>
                      <outbound-endpoint address="vm://greeting"/>
                      <restlet:uri-template-filter pattern="/hello/{set-payload.name}" verbs="GET"/>
                  </filtering-router>
              </outbound>
          </service>
          <service name="greeting">
              <inbound>
                  <inbound-endpoint address="vm://greeting" exchange-pattern="request-response"></inbound-endpoint>
              </inbound>
              <component class="com.ggd543.mulerestletdemo.GreetingComponent"></component>
          </service>
    </model>

and the component class

package com.ggd543.mulerestletdemo

import org.mule.api.lifecycle.Callable
import org.mule.api.MuleEventContext

class GreetingComponent  extends Callable {

  def onCall(eventContext: MuleEventContext) = {
      val name = eventContext.getMessage.getPayload.asInstanceOf[String]
      sayHello(name)
  }

  def sayHello(name: String) = {
    val msg = "hello, "+name
    println(msg)
    msg
  }
}

After deploying the app successfully, I tried to visit http://localhost:9004/hello/archer in my browser, but nothing happened.

Is there anything wrong in the mule-config.xml ?

PS: My mule version is 3.1.2 and I am using mule-transport-restlet-1.1.3.jar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情痴 2024-12-27 09:48:18

该问题是由于虚拟机端点上的交换模式不一致造成的。尝试:

   <model name="greetingModel">
      <service name="greetingService">
          <inbound>
              <inbound-endpoint address="http://localhost:9004"/>
          </inbound>
          <outbound>
              <filtering-router>
                  <outbound-endpoint address="vm://greeting" exchange-pattern="request-response"/>
                  <restlet:uri-template-filter pattern="/hello/{set-payload.name}" verbs="GET"/>
              </filtering-router>
          </outbound>
      </service>
      <service name="greeting">
          <inbound>
              <inbound-endpoint address="vm://greeting" exchange-pattern="request-response"/>
          </inbound>
          <component class="com.ggd543.mulerestletdemo.GreetingComponent" />
      </service>
</model>

The problem is due to inconsistent exchange-patterns on the VM endpoint. Try:

   <model name="greetingModel">
      <service name="greetingService">
          <inbound>
              <inbound-endpoint address="http://localhost:9004"/>
          </inbound>
          <outbound>
              <filtering-router>
                  <outbound-endpoint address="vm://greeting" exchange-pattern="request-response"/>
                  <restlet:uri-template-filter pattern="/hello/{set-payload.name}" verbs="GET"/>
              </filtering-router>
          </outbound>
      </service>
      <service name="greeting">
          <inbound>
              <inbound-endpoint address="vm://greeting" exchange-pattern="request-response"/>
          </inbound>
          <component class="com.ggd543.mulerestletdemo.GreetingComponent" />
      </service>
</model>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文