Author: heshan
Date: Fri Jun 17 06:03:13 2011
New Revision: 1136780
URL: http://svn.apache.org/viewvc?rev=1136780&view=rev
Log:
SYNAPSE-765
Adding the documentation for the sample 157.
Modified:
synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
Modified: synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml?rev=1136780&r1=1136779&r2=1136780&view=diff
==============================================================================
--- synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml Fri Jun 17 06:03:13
2011
@@ -193,6 +193,8 @@
<a href="#Sample155">Sample 155: Dual channel invocation on both client side
and server side of Synapse with Proxy Services</a></li>
<li>
<a href="#Sample156">Sample 156: Service Integration with specifying the
receiving sequence</a></li>
+<li>
+<a href="#Sample157">Sample 157: Conditional Router for Routing Messages
based on HTTP URL, HTTP Headers and Query Parameters</a></li>
</ul></li>
<li>
<a href="#ProxyServiceQoS">QoS addition and deduction for service mediation
(proxy) samples</a>
@@ -2320,7 +2322,122 @@ proxy service, it sends the same request
<p>Above sample uses the concept of specifying the receiving sequence in the
send mediator. In this case once the message is sent from the in sequence then
the response won't come to
out sequence as the receiving sequence is specified in the send mediator.</p>
+<h2>
+<a name="Sample157" id="Sample157">Sample 157: Conditional Router for Routing
Messages based on HTTP URL, HTTP Headers and Query Parameters</a></h2>
+<pre xml:space="preserve">
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+ <proxy name="StockQuoteProxy" transports="https
http" startOnLoad="true" trace="disable">
+ <target>
+ <inSequence>
+ <conditionalRouter continueAfter="false">
+ <conditionalRoute breakRoute="false">
+ <condition>
+ <match xmlns=""
type="header" source="foo" regex="bar.*"/>
+ </condition>
+ <target sequence="cnd1_seq"/>
+ </conditionalRoute>
+
+ <conditionalRoute breakRoute="false">
+ <condition>
+ <and xmlns="">
+ <match type="header"
source="my_custom_header1" regex="foo.*"/>
+ <match type="url"
regex="/services/StockQuoteProxy.*"/>
+ </and>
+ </condition>
+ <target sequence="cnd2_seq"/>
+ </conditionalRoute>
+
+ <conditionalRoute breakRoute="false">
+ <condition>
+ <and xmlns="">
+ <match type="header"
source="my_custom_header2" regex="bar.*"/>
+ <equal type="param"
source="qparam1" value="qpv_foo"/>
+ <or>
+ <match type="url"
regex="/services/StockQuoteProxy.*"/>
+ <match type="header"
source="my_custom_header3" regex="foo.*"/>
+ </or>
+ <not>
+ <equal type="param"
source="qparam2" value="qpv_bar"/>
+ </not>
+ </and>
+ </condition>
+ <target sequence="cnd3_seq"/>
+ </conditionalRoute>
+ </conditionalRouter>
+ </inSequence>
+ <outSequence>
+ <send/>
+ </outSequence>
+ </target>
+ </proxy>
+
+ <sequence name="cnd1_seq">
+ <log level="custom">
+ <property name="MSG_FLOW" value="Condition (I)
Satisfied"/>
+ </log>
+ <sequence key="send_seq"/>
+ </sequence>
+ <sequence name="cnd2_seq">
+ <log level="custom">
+ <property name="MSG_FLOW" value="Condition (II)
Satisfied"/>
+ </log>
+ <sequence key="send_seq"/>
+ </sequence>
+ <sequence name="cnd3_seq">
+ <log level="custom">
+ <property name="MSG_FLOW" value="Condition (III)
Satisfied"/>
+ </log>
+ <sequence key="send_seq"/>
+ </sequence>
+
+ <sequence name="send_seq">
+ <log level="custom">
+ <property name="DEBUG" value="Condition
Satisfied"/>
+ </log>
+ <send>
+ <endpoint name="simple">
+ <address
uri="http://localhost:9000/services/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </sequence>
+</definitions>
+</pre>
+ <p>
+ <strong>Objective: Routing Messages based on the HTTP Transport
properties.</strong>
+ </p>
+ <p>
+ <strong>Prerequisites:</strong><br/> Start the Synapse configuration
numbered 157: i.e. wso2esb-samples -sn 157
+ <br/>Start the Axis2 server and deploy the SimpleStockQuoteService
if not already done.
+ For this particular case we will be using 'curl' to send requests
with custom HTTP Headers to the proxy service. You may use a similar tool with
facilitate those requirements.
+ <br/><br/>The request file : stockQuoteReq.xml, should contain the
following request.
+ </p>
+ <pre xml:space="preserve"><soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ser="http://services.samples"
xmlns:xsd="http://services.samples/xsd">
+ <soap:Header/>
+ <soap:Body>
+ <ser:getQuote>
+ <ser:request>
+ <xsd:symbol>IBM</xsd:symbol>
+ </ser:request>
+ </ser:getQuote>
+ </soap:Body>
+ </soap:Envelope></pre>
+
+ <p>
+ Condition I : Matching HTTP Header <br/>
+ </p>
+ <pre xml:space="preserve">curl -d @stockQuoteReq.xml -H "Content-Type:
application/soap+xml;charset=UTF-8" -H "foo:bar"
"http://localhost:8280/services/StockQuoteProxy"
+ </pre>
+
+ <p>
+ Condition II : Matching HTTP Header AND Url<br/>
+ </p>
+ <pre xml:space="preserve">curl -d @stockQuoteReq.xml -H "Content-Type:
application/soap+xml;charset=UTF-8" -H "my_custom_header1:foo1"
"http://localhost:8280/services/StockQuoteProxy"</pre>
+
+ <p>
+ Condition III : Complex conditions with AND, OR and NOT<br/>
+ </p>
+ <pre xml:space="preserve">curl -d @stockQuoteReq.xml -H "Content-Type:
application/soap+xml;charset=UTF-8" -H "my_custom_header2:bar" -H
"my_custom_header3:foo"
"http://localhost:8280/services/StockQuoteProxy?qparam1=qpv_foo&qparam2=qpv_foo2"</pre>
<h1>
<a name="ProxyServiceQoS" id="ProxyServiceQoS">QoS addition and deduction for
service mediation (proxy) samples</a> </h1>