23.17. 文字セットの設定
POST
を使用してデータを送信している場合は、Exchange
プロパティーを使用して charset
を設定できます。
exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
23.17.1. スケジュールされたポーリングのサンプル リンクのコピーリンクがクリップボードにコピーされました!
このサンプルは、Google ホームページを 10 秒ごとにポーリングし、そのページをファイル message.html
に書き込みます。
from("timer://foo?fixedRate=true&delay=0&period=10000") .to("http://www.google.com") .setHeader(FileComponent.HEADER_FILE_NAME, "message.html") .to("file:target/google");
from("timer://foo?fixedRate=true&delay=0&period=10000")
.to("http://www.google.com")
.setHeader(FileComponent.HEADER_FILE_NAME, "message.html")
.to("file:target/google");
23.17.2. エンドポイント URI からの URI パラメーター リンクのコピーリンクがクリップボードにコピーされました!
このサンプルには、Web ブラウザーに入力したものとまったく同じ完全な URI エンドポイントがあります。もちろん、Web ブラウザーと同じように &
文字を区切り文字として使用して、複数の URI パラメーターを設定できます。Camel はここでトリックを行いません。
// we query for Camel at the Google page template.sendBody("http://www.google.com/search?q=Camel", null);
// we query for Camel at the Google page
template.sendBody("http://www.google.com/search?q=Camel", null);
23.17.3. メッセージからの URI パラメーター リンクのコピーリンクがクリップボードにコピーされました!
Map headers = new HashMap(); headers.put(Exchange.HTTP_QUERY, "q=Camel&lr=lang_en"); // we query for Camel and English language at Google template.sendBody("http://www.google.com/search", null, headers);
Map headers = new HashMap();
headers.put(Exchange.HTTP_QUERY, "q=Camel&lr=lang_en");
// we query for Camel and English language at Google
template.sendBody("http://www.google.com/search", null, headers);
上記のヘッダー値では、?
を接頭辞として付けるべきでは ない ことに注意してください。&
文字を使用して、通常どおりパラメーターを区切ることができます。
23.17.4. 応答コードの取得 リンクのコピーリンクがクリップボードにコピーされました!
Exchange.HTTP_RESPONSE_CODE
を使用して Out メッセージヘッダーから値を取得することにより、HTTP コンポーネントから HTTP 応答コードを取得できます。