ESB 9
WSO2 ESB Tutorial:
Manipulating SOAP Headers &
Filters Incoming/Outgoing
Messages
1. Introduction
2. EI configuration Example
3. Running Example
4. Conclusion
The header mediator is useful for handling SOAP headers and the in/out mediators for filtering requests and responses. I mean, the requests are redirected to the in channel and the responses are redirected to the out channel.
The client sends the request to the EI and it is processed by the main sequence and redirected to the in mediator. There is another mediator inside, a header mediator. The header mediator allows you to manipulate SOAP and HTTP headers. This time we are going to experiment with to Soap Header. The header mediator sets the WS-Addressing 'To' header on the request. It specifies the address URI of the ultimate receiver of this message. The last mediator, send, it sends the message to the endpoint specified by the to header. The responses from the backend are redirected to the main sequence, but because it is a response, it does not go through the main sequence, it goes to the send mediator directly, and that mediator sends the response back to the client.

Start the Axis2 server with the back-end service SimpleStockQuoteService:

Configure the EI with the code shown on EI configuration Example. It is better to write it than to copy and paste the code to remember better the key mediators and EI configuration in general. Now, type this command line to send the request:
$ ant stockquote -Dtrpurl=http://localhost:8280/

The request sent is this one:

You can use SOAPUI to replicate the request:

The request is correctly sent to the backend specified in TO header. This is the request that is sent from EI to the backend:

And this is the response coming from the backend:

As you can see there are two important concepts here. That is, to understand what mediator processes the request and the response, IN and OUT respectively. The SEND mediator, on our example, is always executed by the response and never pass through the IN sequence. Other cases the response will be processed by the OUT sequence. On the other hand, we have shown the big utility that is TO header to change the endpoint where the request is redirected. This can be very useful for instance with Message Router channel, where depending on the value of the payload or some header fields the message can be redirected to different endpoints.
Manipulating SOAP Headers &
Filters Incoming/Outgoing
Messages
Index
1. Introduction
2. EI configuration Example
3. Running Example
4. Conclusion
1. Introduction
The header mediator is useful for handling SOAP headers and the in/out mediators for filtering requests and responses. I mean, the requests are redirected to the in channel and the responses are redirected to the out channel.
2. EI configuration Example
The client sends the request to the EI and it is processed by the main sequence and redirected to the in mediator. There is another mediator inside, a header mediator. The header mediator allows you to manipulate SOAP and HTTP headers. This time we are going to experiment with to Soap Header. The header mediator sets the WS-Addressing 'To' header on the request. It specifies the address URI of the ultimate receiver of this message. The last mediator, send, it sends the message to the endpoint specified by the to header. The responses from the backend are redirected to the main sequence, but because it is a response, it does not go through the main sequence, it goes to the send mediator directly, and that mediator sends the response back to the client.

3. Running Example
Start the Axis2 server with the back-end service SimpleStockQuoteService:

Configure the EI with the code shown on EI configuration Example. It is better to write it than to copy and paste the code to remember better the key mediators and EI configuration in general. Now, type this command line to send the request:
$ ant stockquote -Dtrpurl=http://localhost:8280/

The request sent is this one:

You can use SOAPUI to replicate the request:

The request is correctly sent to the backend specified in TO header. This is the request that is sent from EI to the backend:

And this is the response coming from the backend:

4. Conclusion
As you can see there are two important concepts here. That is, to understand what mediator processes the request and the response, IN and OUT respectively. The SEND mediator, on our example, is always executed by the response and never pass through the IN sequence. Other cases the response will be processed by the OUT sequence. On the other hand, we have shown the big utility that is TO header to change the endpoint where the request is redirected. This can be very useful for instance with Message Router channel, where depending on the value of the payload or some header fields the message can be redirected to different endpoints.
No comments:
Post a Comment