0

私のアプリケーションは、2 つの Web サービスのいずれかを使用できます。WS A と WS B と呼びましょう。どちらにも同じインターフェイスが含まれています。

HTTP ヘッダーとリクエスト チャネルでいくつかのロジックを実行したいと考えています。WS B は、特定の要求チャネルでのみ使用する必要があります。使用するチャネルを決定するために、リクエスト チャネルを文字列パラメータとして受け取る Java クラスを作成しました。

<http:outbound-gateway request-channel="XXXXX"
        url-expression="'${EL EXP}'" http-method="GET"
        extract-request-payload="true" expected-response-type="java.lang.String"
        charset="UTF-8" reply-timeout="3000" reply-channel="XXXXX">
    </http:outbound-gateway>

次に、コンテキストが初期化されるときに url-expression が評価されることを読みました。

ソース: http://forum.springsource.org/showthread.php?113446-Usage-of-expressions-in-http-namespace-element-url

<int-http:outbound-gateway  request-channel="requestChannel"
        url="dummy"
        http-method="GET" extract-request-payload="true" expected-response-type="java.lang.String"
        charset="UTF-8" reply-timeout="3000" reply-channel="sysLoggerRequestChannel"> 
          <int-http:uri-variable name="teststring" expression="test"/>
          <int-http:uri-variable name="url" expression="evalClass.getDestinationForChannel(teststring)"/>
    </int-http:outbound-gateway>

このアプローチの問題点は、int-http:uri-variable 内の式が評価されていないように見えることです。

これらすべてが、私が間違ったアプローチを取っていると信じさせます。どんな助けでも大歓迎です。

4

2 に答える 2

0

2 つの別個の Web サービス エンドポイントがあり、メッセージごとにどちらを使用するかを決定する方法がある場合、Spring Integrationルーターはメッセージの転送に適しています。これには、送信前にエンドポイントに固有のメッセージをさらに処理できるという利点があります。

ルーターを構成するには、完全にカスタムなものを作成するなど、さまざまな方法があるため、そのセクション全体を読んで、最適な方法を確認することをお勧めします。

メッセージ タイプに基づく簡単な例:

<int:payload-type-router input-channel="requests">
   <int:mapping type="my.business.WebServiceARequest" channel="wsA" />
   <int:mapping type="my.business.WebServiceBRequest" channel="wsB" />
</int:payload-type-router>

<int-http:outbound-gateway request-channel="wsA" url="http://wsA.com/whatever" 
     ... />
<int-http:outbound-gateway request-channel="wsB" url="http://wsB.com/foo" 
     ... />
于 2013-08-13T16:26:49.537 に答える