# データサービスのRESTエンドポイントURLでコンテキスト変数を使用

コンテキスト変数はRESTサービスプロバイダーでサポートされており、データサービスのコンシューマーエンドポイントで利用できます。これにより、エンドポイントをコンテキスト化しながら、複数の対話するサービスをTalend Studioでローカルに実行できるため、異なるコンテキストを使用してさまざまな環境にサービスをデプロイできます。

Talendでサポートされているテクノロジーの詳細は、[Talendコンポーネント](https://help.qlik.com/talend/r/ja-JP/7.3/components/esb-rest)をご覧ください。

絶対パスか相対パスを使い、tRESTRequest、tRESTClient、cRESTのエンドポイントURLでコンテキスト変数を使用することができます。

たとえば、次のコンテキスト変数はTalend Studioで定義されています。

| [Context] (コンテキスト) | 値 |
| --- | --- |
| context.full\_a | http://localhost:8090/services/customers |
| context.full\_b | http://localhost:8090/customers |
| context.full\_c | http://localhost:8090/any/customers |
| context.url\_a | /customers |
| context.url\_b | /services/customers |
| context.port\_a | 8090 |
| context.port\_b | 8091 |

コンテキスト変数を使用してエンドポイントURLを指定すると、サービスは次のアドレスで公開されます。

| [Endpoint] (エンドポイント) | Studio | Runtime (ランタイム) | マイクロサービス(app/docker) |
| --- | --- | --- | --- |
| context.full\_a | http://localhost:8090/services/customers | http://localhost:8090/services/customers | http://localhost:8090/services/customers |
| context.full\_b | http://localhost:8090/customers | http://localhost:8090/customers | http://localhost:8090/customers |
| context.full\_c | http://localhost:8090/any/customers | http://localhost:8090/any/customers | http://localhost:8090/any/customers |
| context.url\_a | http://localhost:8090/customers | http://localhost:8040/services/customers | http://localhost:8065/services/customers |
| context.url\_b | http://localhost:8090/services/customers | http://localhost:8040/services/customers | http://localhost:8065/services/customers |
| "http://localhost:"+ context.port\_b + context.url\_b | http://localhost:8091/services/customers | http://localhost:8091/services/customers | http://localhost:8091/services/customers |
| context.url\_a + "/rest" | http://localhost:8090/customers/rest | http://localhost:8040/services/customers/rest | http://localhost:8065/services/customers/rest |
| "http://localhost:8090" + context.url\_a + "/" + System.getProperty("user.name") | http://localhost:8090/customers/&lt;DynamicOSLoginUserName&gt; | http://localhost:8040/services/customers/&lt;DynamicOSLoginUserName&gt; | http://localhost:8065/services/customers/&lt;DynamicOSLoginUserName&gt; |

情報メモ注: エンドポイントにSystem.getPropertyなどのJavaコードが含まれている場合、ユーザーは Talend Runtimeまたはマイクロサービスでバンドルを実行する前にこのプロパティを設定する必要があります。そうしないと、プロパティが欠落しているため、エラーが発生します。

### このセクション内

* [Talend Runtimeのコンテキストによるサービスエンドポイントの選択](https://help.qlik.com/talend/ja-JP/components/7.3/esb-rest/trestclient-choosing-service-endpoint-by-context-in-talend-runtime)

**関連概念**

[tRESTClient](https://help.qlik.com/talend/ja-JP/components/7.3/esb-rest/trestclient "CXF (JAX-RS)を使用してHTTPおよびHTTPSリクエストを送信し、対応するレスポンスを得ることで、RESTful Webサービスプロバイダーとのインタラクションを行います。")