プロキシサービス(Proxy Services)


As the name implies, a proxy service acts as a service hosted in Synapse, and typically fronts an existing service endpoint. A proxy service can be created and exposed on a different transport, schema, WSDL, or QoS (such as WS-Security, WS-Reliable Messaging) aspect than the real service and could mediate the messages before being delivered to the actual endpoint, and the responses before they reach the client.
その名のとおり、プロキシサービスは、Synapseの中にサービスをホストしているかのように動作し、そして、一般的に、サービスのエンドポイントの前面に配置されます。プロキシサービスは、異なるトランスポート、スキーマWSDLや、元のサービス以上のQoS(WS-Security、WS-Reliable Messagingのような)の上に、作成・公開することができます。そして、プロキシサービスは、実際のエンドポイントに届く前のメッセージや、クライアントに届く前のエンドポイントの応答を、仲介することができます。


Clients can send requests for proxy services directly to Synapse, as the client sees as if they are hosted on it, and for example can perform ?wsdl and view the WSDL of the virtual proxy service. But in the Synapse configuration, such requests can be handled in anyway you like. Most obvious thing would be to do some processing to the message and send it to the actual service, probably running on a different computer. But it is not necessary to always send the message to the actual service. You may list any combination of tasks to be performed on the messages received for the proxy service and terminate the flow or send some java back to the client even without sending it to an actual service. Let's explore a simple proxy services scenario step by step to get a better feeling. As you have downloaded and installed Synapse in the previous section, now you can start directly on the sample.
クライアントは、Synapseのプロキシサービスにリクエストを送信します。クライアントからは、Synapseの上に、サービスがホストされているように見えます。例えば、"?wsdl"を実行できたり、仮想プロキシサービスのWSDLを参照することができます。ですが、Synapseの設定によって、そのようなリクエストを好きな方法で扱うことができます。もっとも明らかなことは、メッセージに何らかの処理を行い、実際のサービス、大抵は異なるコンピュータの上で動作しているサービスにメッセージを送信することです。しかし、実際のサービスにメッセージを送信することが、常に必要なわけではありません。プロキシサービスは、実際のサービスにメッセージを送信せずに、処理のフロー(?flow)を終了したり、java(?)をクライアントに送り返したりするための、メッセージの受信により実行される任意のタスクを並べることができます。よりよい理解をえるために、シンプルなプロキシサービスのシナリオをひとつひとつ見てみましょう。

サンプルを実行する。(Running the sample)


As in the previous section, there should be three entities running to demonstrate proxy services, the server, client and Synapse. Let's start with the server.
前のセクションと同様に、プロキシサービスを説明するために、サーバ、クライアント、そしてSynapseの3つの要素を実行します。

Axis2サーバのサンプルをスタートする。(Starting the sample Axis2 server)


As you have built and deployed the SimpleStockQuote service in the previous section, you can simply start the server by switching to the /samples/axis2Server directory and running the following command.
前のセクションで、SimpleStockQuoteサービスをビルドしてデプロイしているなら、/samples/axis2Serverディレクトリに移動して、以下のコマンドでサーバを起動するだけです。


You can see the console messages as in the previous section.
前回のセクションと同様のメッセージがコンソールに表示されます。

Synapseを起動する。(Starting Synapse)


We have to start Synapse with a configuration containing a proxy service definition. In this case we are using the synapse_sample_150.xml, so that you don't have to write the configuration your self.
プロキシサービスの定義を含む設定で、Synapseを起動します。今回は、synapse_sample_150.xml を使用します。新たに設定を書く必要はありません。

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="StockQuoteProxy">
        <target>
            <endpoint>
                <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
            </endpoint>
            <outSequence>
                <send/>
            </outSequence>
        </target>
        <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
    </proxy>
</definitions>


The above configuration will expose a proxy service named StockQuoteProxy and specifies an endpoint (http://localhost:9000/soap/SimpleStockQuoteService) as the target for the proxy service. Therefore, messages coming to the proxy service will be directed to the address http://localhost:9000/soap/SimpleStockQuoteService specified in the endpoint. There is also an out sequence for the proxy service, which is applicable for response messages. In the out sequence, we just send the messages back to the client. The publishWSDL tag specifies an WSDL to be published for this proxy service. Let's start Synapse with this sample configuration by running the below command from the /bin directory. It is possible to specify a sequence of mediation for incoming messages instead of a target endpoint, and many other possibilities and options are available to configure proxy services. These are explained in the samples and configuration guides.
上記の設定は、StockQuoteProxyという名前でプロキシサービスを公開します。そして、プロキシサービスのターゲットとして、エンドポイント(http://localhost:9000/soap/SimpleStockQuoteService)を指定しています。この設定により、プロキシサービスに到達したメッセージは、エンドポイントに指定した http://localhost:9000/soap/SimpleStockQuoteService のアドレスに送信されます。プロキシサービスには、応答メッセージに適用される外に出て行くシーケンス(an out sequence?)もあります。外に出て行くシーケンス(out sequence?)は、クライアントにメッセージを送り返すだけです。publishWSDLタグは、このプロキシサービスがWSDLを公開するように指定しています。では、このサンプルの設定を使用して、以下に示す/bin内の以下のコマンドで、Synapseを起動しましょう。ターゲットとなるエンドポイントの代わりに、入ってくるメッセージを仲介するシーケンス指定でき、そして、他の多くの設定(possiblity and options)がプロキシサービスを設定するために利用することができます。それらは、サンプルや、設定ガイドの中で、説明されています。


Synapse will display a set of messages as in the previous section describing the steps of starting procedure. Before running the client, it is time to observe another feature of proxy services. That is displaying the published WSDL. Just open a web browser and point it to the address http://localhost:8080/soap/StockQuoteProxy?wsdl. You will see the sample_proxy_1.wsdl specified in the configuration but containing the correct EPR for the service over http/s.
Synapseは、前回のセクションの処理の起動のステップで記述したときと同様のメッセージを画面に表示します。クライアントを実行するまえに、公開されたWSDLを表示するプロキシサービスの別の機能を見てみましょう。Webブラウザを起動し、そして、http://localhost:8080/soap/StockQuoteProxy?wsdl のアドレスを指定してください。設定の中で指定された sample_proxy_1.wsdl ではなく、http/s上のサービスの正しいEPRが表示されるはずです。

クライアントを実行する。(Run the client)


Now it is time to see it in action. Go to the /samples/axis2Clients directory and type the following command:
さて、実行してみましょう。/samples/axis2Clients ディレクトリに移動して、以下のコマンドをタイプしてください。

ant stockquote -Dtrpurl=http://localhost:8080/soap/StockQuoteProxy -Dmode=quote -Dsymbol=IBM


The above command sends a stockquote request directly to the provided transport endpoint at: http://localhost:8080/soap/StockQuoteProxy. You will see the response from the server displayed on the console as follows:
上記のコマンドは、http://localhost:8080/soap/StockQuoteProxy のエンドポイントに株価情報のリクエストを送信します。その結果、以下に示すようなサーバからの応答がコンソールに表示されます。

Standard :: Stock price = $165.32687331383468


This quick guide illustrates the simple use case of proxy services. Please refer to samples #150 and above in the Samples guide, for in depth coverage of more advanced use cases.
このクイックガイドでは、プロキシサービスの簡単な使用法を説明しています。より高度な使用方法を深く知るには、サンプルガイドの中の150番そして、それ以上の番号のサンプルを参考にしてください。


Yes, you are done with a quick look at Synapse. Now it is time to go deeper and reveal the advanced features of Synapse. You can browse through the samples for your interested areas. If you have any issue regarding Synapse as a user, feel free ask it in the Synapse user mailing list (http://synapse.apache.org/mail-lists.html).
これで、Synapseの概要を見たことになります。Synapseの高度な機能をより深く、そして明らかにしていきましょう。あなたは関心のある機能のサンプルを参照することができます。Synapseを利用している際に、何らかの問題があったときは、遠慮なくSynapuseユーザメーリングリスト(http://synapse.apache.org/mail-lists.html)に質問してください。