Enterprise Integration Zone is brought to you in partnership with:

I am a graduate of University of Westminster UK (IIT) B Sc Software Engineering ( First Class Honours). I am a Sun Certified Java Programmer for Java 2 platform, 1.5 versions (SCJP 1.5). – 93% and a Sun Certified Web Component Developer 97%. I work as a Software Engineer at WSO2. Achala is a DZone MVB and is not an employee of DZone and has posted 21 posts at DZone. You can read more from them at their website. View Full User Profile

Route messages based on HTTP Headers with WSO2 ESB

03.15.2013
| 2982 views |
  • submit to reddit

The following code can be used to route messages based on HTTP Headers in the WSO2 Enterprise Service Bus.

<proxy xmlns="http://ws.apache.org/ns/synapse" name="test1" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log level="custom">
            <property name="log" expression="get-property('transport','Accept')" />
         </log>
         <filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('transport','Accept')" regex="text/html">
            <then>
               <log level="custom">
                  <property name="test" value="text/html" />
               </log>
               <sequence key="sequence1" />
            </then>
            <else>
               <log level="custom">
                  <property name="test" value="other" />
               </log>
               <sequence key="sequence2" />
            </else>
         </filter>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap12" />
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send />
      </outSequence>
   </target>
</proxy>


More details available at [1]

[1] http://wso2.org/project/esb/java/4.0.3/docs/samples/proxy_samples.html#Sample157 

Published at DZone with permission of Achala Chathuranga Aponso, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)