第31章 CXFRS


CXFRS コンポーネント

cxfrs: コンポーネントは、CXF でホストされる JAX-RS サービスに接続するための Apache CXF との統合を提供します。
Maven ユーザーは、このコンポーネントの以下の依存関係を pom.xml に追加する必要があります。
<dependency>
   <groupId>org.apache.camel</groupId>
   <artifactId>camel-cxf</artifactId>
   <version>x.x.x</version>  <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap
注記
CXF をコンシューマーとして使用する場合、CXF Bean コンポーネントを使用すると、処理からメッセージペイロードを受け取る方法を RESTful または SOAP Web サービスとして消費できます。これは、多量のトランスポートを使用して Web サービスを消費する可能性があります。Bean コンポーネントの設定も簡単で、Camel および CXF を使用して Web サービスを実装する最も高速な方法を提供します。

URI 形式

cxfrs://address?options
Copy to Clipboard Toggle word wrap
ここでの address は CXF エンドポイントのアドレスを表します。
cxfrs:bean:rsEndpoint
Copy to Clipboard Toggle word wrap
rsEndpoint は、CXFRS クライアントまたはサーバーを表す Spring Bean の名前を表します。
上記のいずれかのスタイルでは、以下のように URI にオプションを追加できます。
cxfrs:bean:cxfEndpoint?resourceClasses=org.apache.camel.rs.Example
Copy to Clipboard Toggle word wrap

オプション

Expand
名前 説明 必須 ? デフォルト値
resourceClasses REST サービスとしてエクスポートするリソースクラス。複数のクラスはコンマで区切ることができます。
resourceClasses=org.apache.camel.rs.Example1,org.apache.camel.rs.Exchange2
いいえ なし
httpClientAPI Apache Camel 2.1 の新 機能。true の場合、CxfRsProducer は HttpClientAPI を使用してサービスを呼び出します。 httpClientAPI=true No true
synchronous 2.5 の新機能として、このオプションにより、CxfRsConsumer が sync または async API を使用して基礎となる作業を行うよう決定します。デフォルト値は false です。これは、デフォルトで非同期 API の使用を試みることを意味します。 synchronous=true No false
throwExceptionOnFailure 2.6 の新機能として、このオプションは CxfRsProducer に対してリターンコードを検査するように指示し、リターンコードが 207 を超える場合は Exception を生成します。 throwExceptionOnFailure=true No true
maxClientCacheSize 2.6 の新機能として、In メッセージヘッダー CamelDestinationOverrideUrl を設定して、ルートに定義されたターゲットの宛先 Web サービスまたは REST サービスを動的に上書きできるようになりました。この実装は、CXF クライアントまたは CxfProvider および CxfRsProviderClientFactoryBean をキャッシュします。このオプションを使用すると、キャッシュの最大サイズを設定できます。 maxClientCacheSize=5 いいえ 10
setDefaultBus 非推奨: Camel 2.16 以降では defaultBus オプションを使用します。CXF エンドポイントがバスを単独で作成すると、デフォルトのバスを設定します。 setDefaultBus=true いいえ false
defaultBus CXF エンドポイントがバスを単独で作成すると、デフォルトのバスを設定します。 defaultBus=true いいえ false
bus 2.9.0 の新機能CXF Bus Factory によって作成されるデフォルトのバス。レジストリーからバスオブジェクトを参照するには、\# 表記を使用します。参照オブジェクトは org.apache.cxf.Bus のインスタンスである必要があります。 bus=#busName いいえ なし
bindingStyle
2.11 以降。Camel との間でリクエストと応答をマッピングする方法を設定します。以下の 2 つの値を使用できます。
  • SimpleConsumer => Consuming a REST Request with the Simple Binding Style below を参照してください。
  • Default => (デフォルトスタイル)。コンシューマーの場合、これは MessageContentsList でルートに渡され、ルートに低レベルの処理が必要になります。
  • custom => では、binding オプションを使用してカスタムバインディングを指定できます。
bindingStyle=SimpleConsumer いいえ デフォルト
binding
カスタムの CxfRsBinding 実装を指定して、未加工の CXF 要求および応答オブジェクトの低レベルの処理を実行できます。実装は Camel レジストリーにバインドする必要があり、ハッシュ(#)表記を使用して参照する必要があります。
binding=#myBinding
No
DefaultCxfRsBinding
providers
Camel 2.12.2 以降、カスタムの JAX-RS プロバイダーリストを CxfRs エンドポイントに設定します。
providers=#MyProviders
いいえ
なし
schemaLocations
Camel 2.12.2 以降、受信 XML または JAXB 駆動型 JSON の検証に使用できるスキーマの場所を設定します。
schemaLocations=#MySchemaLocations
いいえ
なし
features
Camel 2.12.3 以降、機能リストを CxfRs エンドポイントに設定します。
features=#MyFeatures
いいえ
なし
properties
Camel 2.12.4 以降、プロパティーを CxfRs エンドポイントに設定します。
properties=#MyProperties
いいえ
なし
inInterceptors
Camel 2.12.4 以降、inInterceptors を CxfRs エンドポイントに設定します。
inInterceptors=#MyInterceptors
いいえ
なし
outInterceptors
Camel 2.12.4 以降、outInterceptor を CxfRs エンドポイントに設定します。
outInterceptors=#MyInterceptors
いいえ
なし
inFaultInterceptors
Camel 2.12.4 以降、inFaultInterceptors を CxfRs エンドポイントに設定します。
inFaultInterceptors=#MyInterceptors
いいえ
なし
outFaultIntercetpros
Camel 2.12.4 以降、outFaultInterceptors を CxfRs エンドポイントに設定します。
outFaultInterceptors=#MyInterceptors
いいえ
なし
continuationTimeout
Camel 2.14.0 以降、このオプションは CXF サーバーが Jetty または Servlet トランスポートを使用している場合にデフォルトで CxfConsumer で使用できる CXF 継続タイムアウトを設定するために使用されます。( Camel 2.14. 0 よりも前のバージョンでは、CxfConsumer は継続タイムアウトを 0 に設定するだけで、継続一時停止操作がタイムアウトしないことを意味します)。
continuationTimeout=800000
いいえ
30000
ignoreDeleteMethodMessageBody
Camel 2.14.1 以降、このオプションは HTTP API の使用時に DELETE メソッドのメッセージボディーを無視するように CxfRsProducer に指示するために使用されます。
ignoreDeleteMethodMessageBody=true
いいえ
false
modelRef
Camel 2.14.2 以降、このオプションは、アノテーションのないリソースクラスに役立つ モデルファイル を指定するために使用されます。
Camel 2.15 以降、このオプションは、ドキュメントのみのエンドポイントをエミュレートするためにサービスクラスを指定せずにモデルファイルを参照できます。
modelRef=classpath:/CustomerServiceModel.xml
いいえ
なし
performInvocation
Camel 2.15 の場合、オプションが true の場合、Camel リソースクラスインスタンスの呼び出しを実行し、応答オブジェクトをエクスチェンジに配置してさらに処理します。
performInvocation=true
いいえ
false
loggingFeatureEnabled このオプションは、インバウンドおよびアウトバウンド REST メッセージをログに書き込む CXF ロギング機能を有効にします。 - いいえ false
skipFaultLogging このオプションは、PhaseInterceptorChain がキャッチする Fault のロギングをスキップするかどうかを制御します。 - いいえ false
loggingSizeLimit ロギング機能を有効にすると、このオプションを使用してロガーが出力するバイト数を制限します。 - いいえ 0
propagateContexts
Camel 2.15 When true 以降、JAXRS UriInfo、HttpHeaders、Request、および SecurityContext コンテキストは、型指定された Camel エクスチェンジプロパティーとしてカスタム CXFRS プロセッサーで利用できます。これらのコンテキストは、JAX-RS API を使用して現在のリクエストを分析するために使用できます。
loggingFeatureEnabled
このオプションは、インバウンドおよびアウトバウンド REST メッセージをログに書き込む CXF Logging 機能を有効にします。
いいえ
false
skipFaultLogging
このオプションは、PhaseInterceptorChain がキャッチする Fault のロギングをスキップするかどうかを制御します。
いいえ
false
loggingSizeLimit
ロギング機能が有効な場合、ロガーが出力されるバイト数の合計サイズを制限します。
いいえ
0
Spring 設定を介して CXF REST エンドポイントを設定することもできます。CXF REST クライアントと CXF REST Server の間には多くの違いがあるため、それらに異なる設定が提供されます。詳細は、スキーマファイルCXF JAX-RS ドキュメント を参照してください。

Apache Camel で REST エンドポイントを設定する方法

camel-cxf スキーマファイル には、REST エンドポイント定義に 2 つの要素があります。cxf:rsServer for REST コンシューマー、cxf:rsClient (REST プロデューサーの場合)ここでは、Apache Camel REST サービスルート設定の例があります。
<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
    ">
  <!-- Defined the real JAXRS back end service  -->
  <jaxrs:server id="restService"
		        address="http://localhost:9002/rest" 
		        staticSubresourceResolution="true">
    <jaxrs:serviceBeans>
      <ref bean="customerService"/>
    </jaxrs:serviceBeans>       
  </jaxrs:server>
  
  <!--bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.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:9000/route"
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
      loggingFeatureEnabled="true" loggingSizeLimit="20" skipFaultLogging="true"/>

  <!-- Defined the client endpoint to create the cxf-rs consumer -->
  <cxf:rsClient id="rsClient" address="http://localhost:9002/rest"
    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"
      loggingFeatureEnabled="true" skipFaultLogging="true"/>
  
  <!-- The camel route context -->
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <route>
       <from uri="cxfrs://bean://rsServer"/>
       <!-- We can remove this configure as the CXFRS producer is using the HttpAPI by default -->
       <setHeader headerName="CamelCxfRsUsingHttpAPI">
         <constant>True</constant>        
       </setHeader>
       <to uri="cxfrs://bean://rsClient"/>
    </route>
  </camelContext>
  
</beans>
Copy to Clipboard Toggle word wrap

メッセージヘッダーから CXF プロデューサーアドレスを上書きする方法

camel-cxfrs プロデューサーは、CamelDestinationOverrideUrl のキーでメッセージを設定することで、サービスアドレスを上書きすることをサポートします。
// set up the service address from the message header to override the setting of CXF endpoint
exchange.getIn().setHeader(Exchange.DESTINATION_OVERRIDE_URL, constant(getServiceAddress()));
Copy to Clipboard Toggle word wrap

REST リクエストの使用 - シンプルバインディングスタイル

Camel 2.11 から利用可能
Default バインディングスタイルは代わりに低レベルであるため、ユーザーはルートに送信される MessageContentsList オブジェクトを手動で処理する必要があります。そのため、ルートロジックと JAX-RS 操作のメソッド署名およびパラメーターインデックスが密接に結合されます。悪意、難易度、エラーが発生しやすくなります。
一方、SimpleConsumer バインディングスタイルは以下のマッピングを実行し、要求データが Camel Message 内でアクセスしやすく します。
  • JAX-RS パラメーター(@HeaderParam、@QueryParam など)は IN メッセージヘッダーとして注入されます。ヘッダー名は アノテーションの値と一致します。
  • リクエストエンティティー(POJO またはその他のタイプ)は IN メッセージボディーになります。JAX-RS メソッド署名で単一のエンティティーを識別できない場合は、元の MessageContentsList にフォールバックします。
  • バイナリー @Multipart ボディーの部分は IN message attachments、DataHandlerInputStream DataSource、および CXF の Attachment クラスをサポートします。
  • バイナリー以外の @Multipart ボディーの部分は IN メッセージヘッダーとしてマッピングされます。ヘッダー名は Body Part 名と一致します。
さらに、以下のルールは Response マッピング に適用されます。
  • メッセージボディータイプが javax.ws.rs.core.Response (ユーザー構築応答)と異なる場合、新しい Response が作成され、メッセージボディーはエンティティーとして設定されます(null 以外)。応答ステータスコードは Exchange.HTTP_RESPONSE_CODE ヘッダーから取得されます。存在しない場合には、デフォルトは 200 OK に設定されます。
  • メッセージボディータイプが javax.ws.rs.core.Response と等しい場合、ユーザーはカスタム応答を構築するため、尊重され、最終的な応答になります。
  • いずれの場合も、カスタムまたはデフォルトの HeaderFilterStrategy で許可されている Camel ヘッダーが HTTP 応答に追加されます。

シンプルバインディングスタイルの有効化

このバインディングスタイルを有効にするには、コンシューマーエンドポイントの bindingStyle パラメーターを SimpleConsumer の値に設定します。
  from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
    .to("log:TEST?showAll=true");
Copy to Clipboard Toggle word wrap

異なるメソッド署名を使用した要求バインディングの例

以下は、Simple バインディングの想定される結果と共にメソッド署名の一覧です。
public Response doAction (BusinessObject request); Request payload is placed in IN メッセージボディーは IN メッセージボディーに配置され、元の MessageContentsList を置き換えます。
public Response doAction (BusinessObject request, @HeaderParam ("abcd") String abcd, @QueryParam ("defg") String defg); Request payload placed in IN メッセージボディーは、元の MessageContentsList を置き換えます。どちらのリクエストパラメーターも、abcd と defg という名前の IN メッセージヘッダーとしてマッピングされます。
public Response doAction (@HeaderParam ("abcd") String abcd, @QueryParam ("defg") String defg); Both request params mapped as IN メッセージヘッダー with names abcd and defg.元の MessageContentsList には 2 つのパラメーターのみが含まれている場合でも保持されます。
public Response doAction (@Multipart (value="body1") BusinessObject request, @Multipart (value="body2") BusinessObject request2); 最初のパラメーターは body1 という名前のヘッダーとして転送され、2 番目のパラメーターはヘッダー body2 としてマッピングされます。元の MessageContentsList は IN メッセージボディーとして保持されます。
public Response doAction (InputStream abcd); The InputStream is unwrapped from the MessageContentsList and preserved as the IN message body.
public Response doAction (DataHandler abcd); DataHandler は MessageContentsList からラップ解除され、IN メッセージボディーとして保持されます。

シンプルバインディングスタイルの例

このメソッドに JAX-RS リソースクラスがあるとします。
    @POST @Path("/customers/{type}")
    public Response newCustomer(Customer customer, @PathParam("type") String type, @QueryParam("active") @DefaultValue("true") boolean active) {
        return null;
    }
Copy to Clipboard Toggle word wrap
以下のルートでサービスを提供します。
    from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
        .recipientList(simple("direct:${header.operationName}"));

    from("direct:newCustomer")
        .log("Request: type=${header.type}, active=${header.active}, customerData=${body}");
Copy to Clipboard Toggle word wrap
XML ペイロードを使用した以下の HTTP 要求(Customer DTO が JAXB-annotated の場合)。
POST /customers/gold?active=true

Payload:
<Customer>
  <fullName>Raul Kripalani</fullName>
  <country>Spain</country>
  <project>Apache Camel</project>
</Customer>
Copy to Clipboard Toggle word wrap
メッセージを出力します。
Request: type=gold, active=true, customerData=<Customer.toString() representation>
Copy to Clipboard Toggle word wrap
要求および書き込み応答の処理方法の例は、を参照して ください

REST リクエストの使用 - デフォルトバインディングスタイル

CXF JAX-RS フロントエンドJAX-RS (JSR-311) API を実装しているため、リソースクラスを REST サービスとしてエクスポートできます。また 、CXF Invoker API を使用して、REST リクエストを通常の Java オブジェクトメソッド呼び出しに変換します。camel-restlet コンポーネントとは異なり、エンドポイント内で URI テンプレートを指定する必要はありません。CXF は JSR-311 仕様に従って、REST 要求 URI をリソースクラスメソッドマッピングに処理します。Apache Camel で行う必要があるのは、このメソッドリクエストを適切なプロセッサーまたはエンドポイントに委譲することです。
以下は CXFRS ルートの例です。
private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:" + CXT + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource";
 
 protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() {
            errorHandler(new NoErrorHandlerBuilder());
            from(CXF_RS_ENDPOINT_URI).process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Message inMessage = exchange.getIn();                        
                    // Get the operation name from in message
                    String operationName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class);
                    if ("getCustomer".equals(operationName)) {
                        String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
                        assertEquals("Get a wrong http method", "GET", httpMethod);
                        String path = inMessage.getHeader(Exchange.HTTP_PATH, String.class);
                        // The parameter of the invocation is stored in the body of in message
                        String id = inMessage.getBody(String.class);
                        if ("/customerservice/customers/126".equals(path)) {                            
                            Customer customer = new Customer();
                            customer.setId(Long.parseLong(id));
                            customer.setName("Willem");
                            // We just put the response Object into the out message body
                            exchange.getOut().setBody(customer);
                        } else {
                            if ("/customerservice/customers/400".equals(path)) {
                                // We return the remote client IP address this time
                                org.apache.cxf.message.Message cxfMessage = inMessage.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
                                ServletRequest request = (ServletRequest) cxfMessage.get("HTTP.REQUEST");
                                String remoteAddress = request.getRemoteAddr();
                                Response r = Response.status(200).entity("The remoteAddress is " + remoteAddress).build();
                                exchange.getOut().setBody(r);
                                return;
                            }
                            if ("/customerservice/customers/123".equals(path)) {
                                 // send a customer response back
                                 Response r = Response.status(200).entity("customer response back!").build();
                                 exchange.getOut().setBody(r);
                                 return;
                            }
                            if ("/customerservice/customers/456".equals(path)) {
                                Response r = Response.status(404).entity("Can't found the customer with uri " + path).build();
                                throw new WebApplicationException(r);
                            } else {
                                throw new RuntimeCamelException("Can't found the customer with uri " + path);
                            }
                        }
                    }
                    if ("updateCustomer".equals(operationName)) {
                        assertEquals("Get a wrong customer message header", "header1;header2", inMessage.getHeader("test"));
                        String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
                        assertEquals("Get a wrong http method", "PUT", httpMethod);
                        Customer customer = inMessage.getBody(Customer.class);
                        assertNotNull("The customer should not be null.", customer);
                        // Now you can do what you want on the customer object
                        assertEquals("Get a wrong customer name.", "Mary", customer.getName());
                        // set the response back
                        exchange.getOut().setBody(Response.ok().build());
                }
                }
                
            });
        }
    };
}
Copy to Clipboard Toggle word wrap
エンドポイントの設定に使用される対応するリソースクラスはインターフェイスとして定義されます。
@Path("/customerservice/")
public interface CustomerServiceResource {
 
    @GET
    @Path("/customers/{id}/")
    Customer getCustomer(@PathParam("id") String id);
 
    @PUT
    @Path("/customers/")
    Response updateCustomer(Customer customer);
 }
Copy to Clipboard Toggle word wrap
重要
デフォルトでは、JAX-RS リソースクラスは JAX-RS プロパティー のみ を設定するために使用されます。メソッドは、エンドポイントへのメッセージのルーティング中に実行され 、ルート自体はすべての処理を行います。
注記
Camel 2.15 以降では、デフォルトモードの no-op サービス実装クラスではなく、インターフェイスのみを提供するだけで十分です。Camel 2.15 以降では、performInvocation オプションが有効になっていると、サービス実装が最初に呼び出されます。応答は Camel エクスチェンジに設定され、ルートの実行は通常どおり継続されます。これは、既存の JAX-RS 実装を Camel ルートに統合する場合や、カスタムプロセッサーでの JAX-RS 応答の後処理に役立ちます。

How to invoke the REST service through camel-cxfrs producer?

CXF JAXRS フロントエンドプロキシーベースのクライアント API を実装し、この API はプロキシーを介してリモート REST サービスを呼び出すことができます。camel-cxfrs プロデューサーはこの プロキシー API に基づいています。メッセージヘッダーで操作名を指定し、メッセージボディーにパラメーターを準備するだけで、camel-cxfrs プロデューサーは適切な REST 要求を生成します。
以下に例を示します。
Exchange exchange = template.send("direct://proxy", new Processor() {

    public void process(Exchange exchange) throws Exception {
        exchange.setPattern(ExchangePattern.InOut);
        Message inMessage = exchange.getIn();
        setupDestinationURL(inMessage);
        // set the operation name 
        inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer");
        // using the proxy client API
        inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE);
        // set a customer header
        inMessage.setHeader("key", "value");
        // set the parameters , if you just have one parameter 
        // camel will put this object into an Object[] itself
        inMessage.setBody("123");
    }
    
});
     
// get the response message 
Customer response = (Customer) exchange.getOut().getBody();

assertNotNull("The response should not be null ", response);
assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
assertEquals("Get a wrong customer name", response.getName(), "John");
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
Copy to Clipboard Toggle word wrap
CXF JAXRS フロントエンドhttp 中心のクライアント API も提供し、camel-cxfrs プロデューサーからこの API を呼び出すこともできます。HTTP_PATH および Http メソッドを指定し、URI オプション httpClientAPI を使用するか、CxfConstants.CAMEL_CXF_RS_USING_HTTP_API でメッセージヘッダーを設定して、プロデューサーに HTTP 中心のクライアントの使用を知らせる必要があります。応答オブジェクトは、CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS で指定するタイプクラスに変換できます。
Exchange exchange = template.send("direct://http", new Processor() {

    public void process(Exchange exchange) throws Exception {
        exchange.setPattern(ExchangePattern.InOut);
        Message inMessage = exchange.getIn();
        setupDestinationURL(inMessage);
        // using the http central client API
        inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE);
        // set the Http method
        inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
        // set the relative path
        inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123");                
        // Specify the response class , cxfrs will use InputStream as the response object type 
        inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class);
        // set a customer header
        inMessage.setHeader("key", "value");
        // since we use the Get method, so we don't need to set the message body
        inMessage.setBody(null);                
    }
    
});
     
// get the response message 
Customer response = (Customer) exchange.getOut().getBody();

assertNotNull("The response should not be null ", response);
assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123");
assertEquals("Get a wrong customer name", response.getName(), "John");
assertEquals("Get a wrong response code", 200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
assertEquals("Get a wrong header value", "value", exchange.getOut().getHeader("key"));
Copy to Clipboard Toggle word wrap
Apache Camel 2.1 以降、CXFRS HTTP 中心クライアントの CXFRS URI からクエリーパラメーターを指定することもサポートします。
Exchange exchange = template.send("cxfrs://http://localhost:" + getPort2() + "/" + getClass().getSimpleName() + "/testQuery?httpClientAPI=true&q1=12&q2=13"
Copy to Clipboard Toggle word wrap
Dynamical ルーティングをサポートするには、CxfConstants.CAMEL_CXF_RS_QUERY_MAP ヘッダーを使用してパラメーターマップを設定して URI のクエリーパラメーターを上書きすることができます。
Map<String, String> queryMap = new LinkedHashMap<String, String>();                    
queryMap.put("q1", "new");
queryMap.put("q2", "world");                    
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_QUERY_MAP, queryMap);
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat