2016-04-26 5 views
1
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:cxf="http://camel.apache.org/schema/cxf" 
     xmlns:jaxrs="http://cxf.apache.org/jaxrs" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd 
     http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd 
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 
    "> 

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> 

    <!-- Defined the real JAXRS back end service --> 
    <jaxrs:server id="restService" 
       address="http://localhost:${CXFTestSupport.port2}/CxfRsRouterTest/rest" 
       staticSubresourceResolution="true"> 
    <jaxrs:serviceBeans> 
     <ref bean="customerService"/> 
    </jaxrs:serviceBeans>  
    </jaxrs:server> 

    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider"/> 

    <bean id="customerService" class="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" /> 

    <!-- Defined the server endpoint to create the cxf-rs consumer --> 
    <cxf:rsServer id="rsServer" address="http://localhost:${CXFTestSupport.port1}/CxfRsRouterTest/route" 
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
    loggingFeatureEnabled="true" loggingSizeLimit="20" skipFaultLogging="true"> 
    <cxf:providers> 
     <ref bean="jsonProvider"/> 
    </cxf:providers> 
    </cxf:rsServer> 

    <!-- Defined the client endpoint to create the cxf-rs consumer --> 
    <cxf:rsClient id="rsClient" address="http://localhost:${CXFTestSupport.port2}/CxfRsRouterTest/rest" 
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
    loggingFeatureEnabled="true" skipFaultLogging="true"> 
    <cxf:providers> 
     <ref bean="jsonProvider"/> 
    </cxf:providers> 
    </cxf:rsClient> 

    <!-- The camel route context --> 
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> 
    <route> 
     <!-- Just need to ignoreDeleteMethodMessageBody --> 
     <from uri="cxfrs://bean://rsServer"/> 
     <to uri="log:body?level=INFO"/> 
     <to uri="cxfrs://bean://rsClient?ignoreDeleteMethodMessageBody=true"/> 
    </route> 
    </camelContext> 

</beans> 

を行います。 また、Jaxrsタグとcxf:rsserverとcxf:rsclientタグの違いを理解したいと思います。何ラクダCXF以下に異なるタグを行うことは、彼らがCXFと言うキャメルドキュメントでは

答えて

0
  • jaxrs:server:基本エンドポイントサービスを作成します。
  • cxf:rsServer:RESTエンドポイントを作成するためのラクダコンポーネントです。リクエストを通常のJavaオブジェクトに変換します。
  • cxf:rsClient:rsServerとは逆に、JavaオブジェクトをREST要求に変換します。

    <camelContext> <route> <from uri="cxfrs://bean://rsServer" /> <to uri="log:body?level=INFO" /> <to uri="cxfrs://bean://..=true" /> </route> </camelContext>

我々はコード例に見てみるならば、我々はこれがプロキシであることがわかります。 RESTリクエストを受け取り、ログに記録してから転送します。

<cxf:rsServer id="rsServer" address="http://localhost:${CXFTestSupport.port1}/CxfRsRouterTest/route" 
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
    loggingFeatureEnabled="true" loggingSizeLimit="20" skipFaultLogging="true"> 
    <cxf:providers> 
     <ref bean="jsonProvider"/> 
    </cxf:providers> 
    </cxf:rsServer> 

    <cxf:rsClient id="rsClient" address="http://localhost:${CXFTestSupport.port2}/CxfRsRouterTest/rest" 
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
    loggingFeatureEnabled="true" skipFaultLogging="true"> 
    <cxf:providers> 
     <ref bean="jsonProvider"/> 
    </cxf:providers> 
    </cxf:rsClient> 

論文のタグあなたのCXFコンポーネントはラクダのルートから外に設定するためのものです。

このヘルプが必要です。

+0

Thomasが本当に助けてくれてありがとう。 rsServerがRequestをJava Objectに変換すると言ったときには、リクエスト内のJSONがObjectに変換されていたことを意味しましたか? –

+0

はい、jsonまたはXMLオブジェクト(Jaxrsまたはjacksonの場合) – Thomas

関連する問題