Reusing Sequences¶
This example demonstrates how to reuse sequences in the Micro Integrator.
Synapse configuration¶
This configuration creates two Proxy Services. The first Proxy Service (StockQuoteProxy1) uses the sequence named "proxy_1" to process incoming messages and the sequence named "out" to process outgoing responses. The second Proxy Service (StockQuoteProxy2) is set to directly forward messages that are received to the endpoint named "proxy_2_endpoint" without any mediation.
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="proxy_2_endpoint">
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="proxy_wsdl" src="file:samples/wsdl/sample_proxy_1.wsdl"/>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="proxy_1">
<send>
<endpoint><address uri="http://localhost:9000/services/SimpleStockQuoteService"/></endpoint>
</send>
</sequence>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="out">
<send/>
</sequence>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy1">
<publishWSDL key="proxy_wsdl"/>
<target inSequence="proxy_1" outSequence="out"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy2">
<publishWSDL key="proxy_wsdl"/>
<target endpoint="proxy_2_endpoint" outSequence="out"/>
</proxy>
Build and run¶
Create the artifacts:
- Set up ESB Integration Studio.
- Create an integration project with an ESB Configs module and an Composite Exporter.
- Create the proxy services, the mediation sequences, the local entry, and the endpoint with the configurations given above.
- Deploy the artifacts in your Micro Integrator.
Set up the back-end service:
- Download the back-end service.
- Extract the downloaded zip file.
- Open a terminal, navigate to the
axis2Server/bin/
directory inside the extracted folder. -
Execute the following command to start the axis2server with the SimpleStockQuote back-end service:
sh axis2server.sh
axis2server.bat
Download the sample_proxy_1.wsdl file and copy it to the MI_HOME/samples/wsdl
folder (create this folder if does not already exist).
You could send a stock quote request to each of these proxy services and receive the reply generated by the actual back-end service.
-
Request to StockQuoteProxy1:
POST http://localhost:8290/services/StockQuoteProxy1.StockQuoteProxy1HttpSoap11Endpoint HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: text/xml;charset=UTF-8 SOAPAction: "urn:getQuote" Content-Length: 416 Host: Chanikas-MacBook-Pro.local:8290 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd"> <soapenv:Header/> <soapenv:Body> <ser:getQuote> <ser:request> <xsd:symbol>IBM</xsd:symbol> </ser:request> </ser:getQuote> </soapenv:Body> </soapenv:Envelope>
-
Request to StockQuoteProxy2:
POST http://localhost:8290/services/StockQuoteProxy2.StockQuoteProxy2HttpSoap11Endpoint HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: text/xml;charset=UTF-8 SOAPAction: "urn:getQuote" Content-Length: 416 Host: Chanikas-MacBook-Pro.local:8290 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd"> <soapenv:Header/> <soapenv:Body> <ser:getQuote> <ser:request> <xsd:symbol>IBM</xsd:symbol> </ser:request> </ser:getQuote> </soapenv:Body> </soapenv:Envelope>