基本的cxfrs RESTful JAX-RS服务

时间:2014-04-28 20:26:12

标签: rest apache-camel

我正在尝试使用基本的CXF RS JAX-RS示例。不幸的是,对于我想要返回HTML的资源的GET似乎根本不会调用该资源。

以下是spring bean的摘录:

<cxf:rsServer id="rsServer" address="http://localhost:9099/route"
              serviceClass="com.example.HelloResource"/>

<bean id="HelloResource" class="com.example.HelloResource"/>

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="cxfrs:bean:rsServer"/>
        <to uri="log:AFTER?showAll=true"/>
    </route>
</camelContext>

以下是相应JAX-RS资源的摘录:

@Path("/")
public class HelloResource {
   private final Log log = LogFactory.getLog(HelloResource.class);

   public HelloResource() {
       log.info("Creating HelloResource ...");
   }

   @GET
   @Path("/hello")
   @Produces("text/html")
   public String hello() {
       log.info("***** Hello? ******");
       return "<p>Hello World!</p>";
   }
}

以下命令不返回任何输出:

curl localhost:9099/route/hello

从下面的日志提取中可以看出,构造了spring bean,它调用的方法似乎是正确的,但实际上似乎没有调用该方法:

14:55:27,614 | INFO  | qtp137557963-131 | HelloResource              | 180 - hello.jar - 0.0.0 | Creating HelloResource ...
14:55:27,616 | INFO  | qtp137557963-131 | AFTER                      | 96 - org.apache.camel.camel-core - 2.10.4 | Exchange[Id:ASDF63648-1398714852208-0-3, ExchangePattern:InOut, Properties:{CamelToEndpoint=log://AFTER?showAll=true, CamelCreatedTimestamp=Mon Apr 28 14:55:27 CDT 2014}, Headers:{CamelHttpUri=/route/hello,CamelCxfMessage=org.apache.cxf.message.XMLMessage@76159b6f, CamelHttpPath=/hello, breadcrumbId=ASDFAS3987148522080-4,CamelCxfRsResponseGenericType=class java.lang.String, User-Agent=curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3,operationName=hello, Accept=*/*, Content-Type=null, CamelHttpMethod=GET, CamelCxfRsOperationResourceInfoStack=[org.apache.cxf.jaxrs.model.MethodInvocationInfo@354563cc], Host=localhost:9099, CamelAcceptContentType=*/*, CamelCxfRsResponseClass=class java.lang.String},BodyType:org.apache.cxf.message.MessageContentsList, Body:[], Out: null]

我确定我做的事情很简单。我很感激有人提供任何帮助......

谢谢!

0 个答案:

没有答案
相关问题