2011-12-08 40 views
1

这是一个RESTful接口骡子嵌入,它接受一个用户名和输出“你好,$名”骡子的Restlet应用程序无法正常工作

以下是骡子-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:我的骡子版本3.1.2是和我使用的骡子运输的Restlet-1.1.3.jar

回答

1

的问题是由于对VM端点不一致的交换模式。试试:

<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> 
相关问题