Sample 6: Manipulating SOAP Headers and Filtering Incoming/Outgoing Messages

<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="main"> <in> <header name="To" value="http://localhost:9000/services/SimpleStockQuoteService"/> </in> <send/> </sequence> </definitions>

Objective

Introduction to the header mediator for handling SOAP headers and the in/out mediators for filtering requests and responses.

Pre-requisites

  • Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
  • Start Synapse using the configuration numbered 6 (repository/conf/sample/synapse_sample_6.xml)
    Unix/Linux: sh synapse.sh -sample 6
    Windows: synapse.bat -sample 6

Executing the Client

In this sample we wil run the client in dumb client mode (ie without addressing information) as follows.

ant stockquote -Dtrpurl=http://localhost:8280/

The request is captured by the main sequence of Synapse and handed to the in mediator. The header mediator sets the WS-Addressing 'To' header on the request. Finally the send mediator sends the message to the EPR specified in the addressing 'To' header.

Response coming back from Axis2 will also get dispatched to the main sequence. But for the response the in mediator will not get executed. Only the send mediator will operate on responses which will simply send them back to the client.

Back to Catalog