Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Route messages based on HTTP Headers with WSO2 ESB

DZone's Guide to

Route messages based on HTTP Headers with WSO2 ESB

Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

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 

The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.

Topics:

Published at DZone with permission of Achala Chathuranga Aponso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}