Dashboard > WSO2 ESB > Home > Sequence List
  WSO2 ESB Log in | Register   View a printable version of the current page.  
  Sequence List
Added by Evanthika Amarasiri , last edited by Evanthika Amarasiri on Jun 05, 2008  (view change)
Labels: 
(None)

Test Case # Test Condition
Sequence Definition
Status P/F
1
In-out <definitions xmlns="http://ws.apache.org/ns/synapse">
<in>
      <log level="full"/>
      <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>                                                                                                                                             
        </endpoint>
      </send>
</in>
<out>
    <send/>
</out>
</definitions>
 
2
Usage of the Filter Mediator <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="div_prop" src="file:repository/conf/sample/resources/transform/div_response.xslt" />                                                                                                 
<in>
    <filter xmlns:ns1="http://div.math.com/xsd" source="//ns1:x" regex="40">
        <log level="full" separator=",">
            <property name="Incoming_filt_prop" value="Incoming Message getting filtered"/>               
        </log>
        <send>
            <endpoint>
                <address uri="http://localhost:9001/soap/Division"/>
            </endpoint>
        </send>
    </filter>
</in>
<out>
    <send/>
</out>
</definitions>
 
3 Usage of the Transform Mediator    
  a)
Transform - XSLT (On the incoming message) <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="div_req" src="file:repository/conf/sample/resources/transform/div_request.xslt" />
<localEntry key="div_res" src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<in>
    <xslt key="div_req"/>
    <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</in>
<out>
    <log level="full" separator=",">
        <property name="after_filt_prop" value="Incoming Message getting filtered - After"/>
    </log>
    <send/>
</out>
</definitions>
 
   b)
Transform - XSLT (On the outgoing message)

<definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="div_req" src="file:repository/conf/sample/resources/transform/div_request.xslt" />
<localEntry key="div_res" src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<in>
    <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</in>
<out>
    <xslt key="div_res"/>
    <log level="full" separator=",">
        <property name="after_filt_prop" value="Incoming Message getting filtered - After"/>
    </log>
    <send/>
</out>
</definitions>
 
   c)
Transform - XSLT (Both on the incoming and outgoing messages) <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="div_req" src="file:repository/conf/sample/resources/transform/div_request.xslt" />
<localEntry key="div_res" src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<in>
    <xslt key="div_req"/>
    <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</in>
<out>
    <xslt key="div_res"/>
    <log level="full" separator=",">
        <property name="after_filt_prop" value="Incoming Message getting filtered - After"/>
    </log>
    <send/>
</out>
</definitions>
 
4 Usage of the  Validate Mediator <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="filter_validate_schema" src="file:repository/conf/sample/resources/validate/div_schema.xsd" />
<in>
<filter xmlns:ns1="http://div.math.com/xsd" source="//ns1:x" regex="40">
        <validate>
            <schema key="filter_validate_schema"/>
            <on-fail>
                <log level="full" separator=",">
                    <property name="validate_prop" value="Validation Failed"/>
                </log>
            </on-fail>
        </validate>
    <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</filter>
</in>
<out>
    <send/>
</out>
</definitions>
 
5 References to Endpoints <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="div_prop" src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<endpoint name="Subtraction">
    <address uri="http://localhost:9001/soap/Subtraction"/>
</endpoint>
<in>
    <log level="full" separator=",">
        <property name="test" expression="get-property('transport','To')"/>
    </log>
    <filter xmlns:ns1="http://div.math.com/xsd" xpath="//ns1:divide">
        <send>
            <endpoint>
                <address uri="http://localhost:9001/soap/Division"/>
            </endpoint>
        </send>
    </filter>
    <filter xmlns:ns1="http://subt.math.com/xsd" xpath="//ns1:subt">
        <send>
            <endpoint key="Subtraction"/>
        </send>
    </filter>
</in>
<out>
    <send/>
</out>
</definitions>
 
6 Enabling Security on Endpoints <definitions xmlns="http://ws.apache.org/ns/synapse">
<localEntry key="sec_policy" src="file:repository/conf/sample/resources/policy/policy_3.xml" />
<endpoint name="Subtraction">
    <address uri="http://localhost:9000/soap/SecureStockQuoteService3">
         <enableSec policy="sec_policy"/>
          <enableAddressing/>
    </address>
</endpoint>
<in>
    <header name="To" value="http://localhost:9000/soap/SecureStockQuoteService3"/>
      <send>
             <endpoint key="Subtraction"/>
      </send>
</in>
<out>
    <header name="wsse:Security" action="remove" xmlns:wsse=
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
    <send/>
</out>

</definitions>
 
7 References to Sequences - Sequence Ref (Main sequence referring to other sequences)
<definitions xmlns="http://ws.apache.org/ns/synapse">
<endpoint name="division_epr">
    <address uri="http://localhost:9001/soap/Division">
        <enableAddressing/>
    </address>
</endpoint>
<localEntry key="filter_validate_schema"  src="file:repository/conf/sample/resources/validate/div_schema.xsd" />
<sequence name="onErrorSequence">
    <log level="full" separator=",">
        <property name="Error_prop" value="Error Occurred"/>
    </log>
</sequence>
<sequence name="filter_validate_for_scenario3" onError="onErrorSequence">
    <filter xmlns:ns1="http://div.math.com/xsd" source="//ns1:x" regex="40"/>
    <log level="full" separator=",">
        <property name="Incoming_filt_prop" value="Incoming Message getting filtered"/>
    </log>
    <validate>
        <schema key="filter_validate_schema"/>
            <on-fail>
                <log level="full" separator=",">
                    <property name="validate_prop" value="Validation Failed"/>
                </log>
            </on-fail>
    </validate>
</sequence>
<sequence name="main">
<in>
    <sequence key="filter_validate_for_scenario3"/>
    <switch xmlns:ns="http://div.math.com/xsd" source="//ns:x">
        <case regex="40">
            <send>
                <endpoint>
                    <address uri="http://localhost:9001/soap/Division"/>
                </endpoint>
            </send>
        </case>
        <case regex="50">
            <send>
                <endpoint>
                    <address uri="http://localhost:9001/soap/Subtraction"/>
                </endpoint>
            </send>
        </case>
    </switch>
</in>
<out>
    <send/>
</out>
</sequence>
</definitions>
 
8 Usage of the Error Handling Sequence when validation fails - Filter/Validate and Error Handling (Calling the error handling sequence when the validation fails)
<definitions xmlns="http://ws.apache.org/ns/synapse">
<endpoint name="division_epr">
    <address uri="http://localhost:9001/soap/Division">
        <enableAddressing/>
    </address>
</endpoint>
<localEntry key="filter_validate_schema"  src="file:repository/conf/sample/resources/validate/div_schema.xsd" />
<sequence name="onErrorSequence">
    <log level="full" separator=",">
        <property name="Error_prop" value="Error Occurred"/>
    </log>
</sequence>
<sequence name="filter_validate_for_scenario3" onError="onErrorSequence">
    <filter xmlns:ns1="http://div.math.com/xsd" source="//ns1:x" regex="40"/>
    <log level="full" separator=",">
        <property name="Incoming_filt_prop" value="Incoming Message getting filtered"/>
    </log>
    <validate>
        <schema key="filter_validate_schema"/>
            <on-fail>
                <sequence key="onErrorSequence"/>
                <log level="full" separator=",">
                    <property name="validate_prop" value="Validation Failed"/>
                </log>
            </on-fail>
    </validate>
    <send>
        <endpoint>
             <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</sequence>
<sequence name="main">
    <in>
        <sequence key="filter_validate_for_scenario3"/>
    </in>
    <out>
        <send>
            <endpoint>
                 <address uri="http://localhost:9001/soap/NonExistingService"/>
            </endpoint>
        </send>
    </out>
</sequence>
</definitions>
 
9 Sequences with XSLT, XPATH and Switch mediators <definitions xmlns="http://ws.apache.org/ns/synapse">
<endpoint name="division_epr">
    <address uri="http://localhost:9001/soap/Division">
        <enableAddressing/>
    </address>
</endpoint>
<localEntry key="div_response" src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<localEntry key="div_request" src="file:repository/conf/sample/resources/transform/div_request.xslt" />
<localEntry key="filter_validate_schema"  src="file:repository/conf/sample/resources/validate/div_schema.xsd" />

<sequence name="onErrorSequence">
    <log level="full" separator=",">
        <property name="Error_prop" value="Error Occurred"/>
    </log>
</sequence>
<sequence name="main" onError="onErrorSequence">
<in>
    <send>
        <endpoint>
            <address uri="http://localhost:9001/soap/Division"/>
        </endpoint>
    </send>
</in>
<out>
    <switch xmlns:ns="http://div.math.com/xsd" source="//ns:return">
        <case regex="2">
            <xslt key="div_request"/>
        </case>
        <case regex="3">
            <send>
                <endpoint>
                     <address uri="http://localhost:9001/soap/Subtraction1"/>
                </endpoint>
            </send>
        </case>
           <default>
            <log level="full" separator=",">
                <property name="Error_prop" value="Error Occurred"/>
            </log>    
           </default>
    </switch>

    <send/>
</out>
</sequence>
</definitions>
 
10 Usage of Static XML Properties <definitions xmlns="http://ws.apache.org/ns/synapse">
        <localEntry key="validate_schema">
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:axis2="http://div.math.com" xmlns:ns="http://div.math.com/xsd" xmlns:ns0="http://div.math.com/xsd" xmlns:ns1="http://org.apache.axis2/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://div.math.com/xsd">
        <xs:element name="divide">
        <xs:complexType>
        <xs:sequence>
        <xs:element name="z" nillable="true" type="xs:int"/>
        <xs:element name="y" nillable="true" type="xs:int"/>
        </xs:sequence>
        </xs:complexType>
        </xs:element>
        <xs:element name="divideResponse">
        <xs:complexType>
        <xs:sequence>
        <xs:element name="return" nillable="true" type="xs:int"/>
        </xs:sequence>
        </xs:complexType>
        </xs:element>
        </xs:schema>
        </localEntry>
    <sequence name="onErrorSequence">
        <log level="full" separator=",">
            <property name="Error_prop" value="Error Occurred"/>
        </log>
    </sequence>
        <endpoint name="division">
                  <address uri="http://localhost:9001/soap/Division"/>
      </endpoint>
        <sequence name="division_request">
            <validate>
                <schema key="validate_schema"/>
                <on-fail>
                    <makefault>
                        <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
                        <reason value="Invalid custom quote request"/>
                    </makefault>
                <sequence key="onErrorSequence"/>
                    <send/>
                </on-fail>
            </validate>
            <send>
                <endpoint key="division"/>
            </send>
        </sequence>
      <sequence name="main">
        <in>
            <filter xmlns:ns1="http://div.math.com/xsd" xpath="//ns1:divide">
                <sequence key="division_request"/>
            </filter>
        </in>
    <out>
        <send/>
    </out>
        </sequence>
</definitions>
 
11 Usage of Registries - URL source properties, registry based properties and the XSLT mediator <definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
        <parameter name="root">file:registry</parameter>
        <parameter name="cachableDuration">15000</parameter>
    </registry>
        <localEntry key="div_request" src="file:repository/conf/sample/resources/transform/div_request.xslt" />
        <endpoint name="divide">
            <address uri="http://localhost:9000/soap/Division"/>
        </endpoint>
      <sequence name="main">
        <in>
            <xslt key="div_request"/>
            <send>
                <endpoint key="divide"/>
            </send>
        </in>
        <out>
            <xslt key="transform/div_response.xslt"/>
            <send/>
        </out>
    </sequence>
</definitions>
 
12 Usage of the Switch Mediator <definitions xmlns="http://ws.apache.org/ns/synapse">
<endpoint name="division_epr">
    <address uri="http://localhost:9000/soap/Division">
        <enableAddressing/>
    </address>
</endpoint>
<localEntry key="div_response"  src="file:repository/conf/sample/resources/transform/div_response.xslt" />
<localEntry key="div_request"  src="file:repository/conf/sample/resources/transform/div_request.xslt" />
<localEntry key="filter_validate_schema"   src="file:repository/conf/sample/resources/validate/div_schema.xsd" />
<sequence name="onErrorSequence">
    <log level="full" separator=",">
        <property name="Error_prop" value="Error Occurred"/>
    </log>
</sequence>
<sequence name="main" onError="onErrorSequence">
<in>
    <send>
        <endpoint>
            <address uri="http://localhost:9000/soap/Division"/>
        </endpoint>
    </send>
</in>
<out>
    <switch xmlns:ns1="http://div.math.com/xsd" source="//ns1:return">
        <case regex="2">
            <xslt key="div_request"/>
        </case>
        <case regex="3">
            <send>
                <endpoint>
                     <address  uri="http://localhost:9000/soap/Subtraction"/>
                </endpoint>
            </send>
        </case>
           <default>
            <log level="full" separator=",">
                <property name="Error_prop" value="Error Occurred"/>
            </log>    
           </default>
    </switch>

    <send/>
</out>
</sequence>
</definitions>
 
13 Usage of Registries
 
a) References to Sequences <definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
        <parameter name="root">file:repository/conf/sample/resources</parameter>
        <parameter name="cachableDuration">15000</parameter>
    </registry>

    <sequence name="main">
        <sequence key="sequence/dynamic_div_seq.xml"/>
    </sequence>
</definitions>
 
b)
References to Endpoints
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
        <parameter name="root">file:repository/conf/sample/resources</parameter>
        <parameter name="cachableDuration">15000</parameter>
    </registry>

        <endpoint name="dynamic_div_endpt" key="endpoint/dynamic_div_endpt.xml"/>
    <sequence name="main">
       <in>
            <send>
                <endpoint key="dynamic_div_endpt"/>
            </send>
        </in>
        <out>
            <send/>
        </out>
    </sequence>
</definitions>

14 Usage of Proxy Services    
a)
General Proxy service <definitions xmlns="http://ws.apache.org/ns/synapse">
    <localEntry key="div_proxy_wsdl" src="file:repository/conf/sample/resources/proxy/division.wsdl" />
    <sequence name="div_in_seq">
        <send>
            <endpoint>
                <address uri="http://localhost:9000/soap/Division"/>
            </endpoint>
        </send>
    </sequence>        
    <proxy name="DivideProxy" transports="https http" startOnLoad="true">
        <description>This is the proxy used for the Division Service</description>
        <target inSequence="div_in_seq"/>
            <publishWSDL key="div_proxy_wsdl"/>
        </proxy>
    <log level="custom">
        <property name="position" value="Inside Main Mediator"/>
    </log>
    <sequence name="main">
    <in>
        <send>
            <endpoint>
                <address uri="http://localhost:9000/soap/Division"/>
            </endpoint>
        </send>
    </in>
    <out>
        <send/>
    </out>
    </sequence>
    </definitions>
 
b)
Proxy service with security <definitions xmlns="http://ws.apache.org/ns/synapse">
    <localEntry key="proxy_wsdl" src="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl" />
    <localEntry key="sec_policy" src="file:repository/conf/sample/resources/policy/policy_1.xml" />
    <log level="full"/>

    <proxy name="StockQuoteProxy" transports="https http" startOnLoad="true">
        <description>This is the proxy used for the Division Service</description>
        <target inSequence="stock_seq">
            <header name="wsse:Security" action="remove"

xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
                    <send>
                        <endpoint>
                     <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
                </endpoint>
                    </send>
        </target>
            <publishWSDL key="proxy_wsdl"/>
            <policy key="sec_policy"/>
        </proxy>

    <sequence name="main">
        <in>
            <header name="wsse:Security" action="remove"
                    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
            <send>
                <endpoint>
                <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
            </endpoint>
            </send>
        </in>
        <out>
            <send/>
        </out>
    </sequence>
    </definitions>
 
15 Usage of Script Mediators
<definitions xmlns="http://ws.apache.org/ns/synapse">
        <proxy name="JMSFileUploadProxy" transports="jms">
            <target>
		<inSequence>
        		<sequence name="mtom_proxy">
	            <header name="Action" value="urn:uploadFileUsingMTOM"/>
				<send>
					<endpoint>
						<address uri="http://localhost:9000/soap/MTOMSampleService" optimize="mtom"/>
					</endpoint>
				</send>
        		</sequence>
		</inSequence>
		</target>
            <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}element</parameter>
        </proxy>
        <proxy name="JMSTextProxy" transports="jms">
		<target>
		<inSequence>
			<sequence name="text_proxy">
				<header name="Action" value="urn:placeOrder"/>
					<script.js><![CDATA[
					var args = mc.getPayloadXML().toString().split(" ");
					mc.setPayloadXML(
					<m:placeOrder xmlns:m="http://services.samples/xsd">
						<m:order>
							<m:price>{args[0]}</m:price>
							<m:quantity>{args[1]}</m:quantity>
							<m:symbol>{args[2]}</m:symbol>
						</m:order>
					</m:placeOrder>);
					]]></script.js>
				<send>
					<endpoint>
						<address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
					</endpoint>
				</send>
			</sequence>
		</inSequence>
            </target>

            <parameter name="transport.jms.Wrapper">{http://services.samples/xsd}text</parameter>
        </proxy>
        <proxy name="JMSPoxProxy" transports="jms">
            <target>
		<inSequence>
			<sequence name="pox_proxy">
				<header name="Action" value="urn:placeOrder"/>
				<send>
					<endpoint>
						<address uri="http://localhost:9000/soap/SimpleStockQuoteService" force="soap"/>
					</endpoint>
		            </send>
        		</sequence>
		</inSequence>
		</target>

	</proxy>

    <log level="full"/>
    <drop/>
</definitions>

 
16 Cache mediator with Proxy Services
<definitions xmlns="http://ws.apache.org/ns/synapse">
 	<localEntry key="version">0.1</localEntry>
 	<localEntry key="xslt-key-req" src="file:repository/conf/sample/resources/transform/transform.xslt" />
 	<localEntry key="xslt-key-res" src="file:repository/conf/sample/resources/transform/transform_back.xslt" />
 		<proxy name="StockQuoteProxy1">
 		<target>
 			<inSequence>
 				<cache timeout="30000" scope="per-host" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator">
 					<implementation type="memory" maxSize="1"/>
 				</cache>
 				<xslt key="xslt-key-req"/>
 				<send>
 					<endpoint name="simple">
 						<address uri="http://10.100.1.228:9001/soap/SimpleStockQuoteService"/>
 					</endpoint>
 				</send>
 			</inSequence>
 			<outSequence>
 				<xslt key="xslt-key-res"/>
 				<cache/>
 				<send/>
 			</outSequence>
 		</target>
 		<publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
 	</proxy>
 	<proxy name="StockQuoteProxy2">
 		<target>
 			<inSequence>
				<cache timeout="30000" scope="per-host" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator">
					<implementation type="memory" maxSize="1"/>
				</cache>
				<property name="direction" value="incoming"/>
				<log level="custom">
					<property name="Text" value="Sending quote request"/>
					<property name="version" expression="get-property('version')"/>
					<property name="direction" expression="get-property('direction')"/>
				</log>
				<send>
					<endpoint name="simple">
						<address uri="http://10.100.1.228:9001/soap/SimpleStockQuoteService"/>
					</endpoint>
				</send>
 			</inSequence>
 			<outSequence>
				<cache/>
				<send/>
 			</outSequence>
 		</target>
 		<publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
 	</proxy>
</definitions>

17 Clone mediator 
<?xml version="1.0" encoding="UTF-8"?>
<syn:definitions xmlns:syn="http://ws.apache.org/ns/synapse">
    <syn:registry provider="org.wso2.esb.registry.ESBRegistry">
        <syn:parameter name="root">file:registry/?</syn:parameter>
    </syn:registry>
    <syn:localEntry key="sec_policy" src="file:repository/conf/sample/resources/policy/policy_3.xml" />
    <syn:sequence statistics="enable" name="main" trace="enable">
        <syn:sequence key="clone_sequence"/>
    </syn:sequence>
    <syn:sequence name="dbsequence">
        <syn:log level="custom" separator=",">
            <syn:property name="text" value="* Reporting to the Database *"/>
        </syn:log>
        <syn:dbreport>
            <syn:connection>
                <syn:pool>
                    <syn:driver>org.apache.derby.jdbc.ClientDriver</syn:driver>
                    <syn:password>esb</syn:password>
                    <syn:user>esb</syn:user>
                    <syn:url>jdbc:derby://localhost:1527/esbdb;create=false</syn:url>
                </syn:pool>
            </syn:connection>
            <syn:statement>
                <syn:sql>update company set price=? where name =?</syn:sql>
                <syn:parameter xmlns:m0="http://services.samples/xsd" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" expression="//m0:return/m0:last/child::text()" type="DOUBLE"/>
                <syn:parameter xmlns:m0="http://services.samples/xsd" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" expression="//m0:return/m0:symbol/child::text()" type="VARCHAR"/>
            </syn:statement>
        </syn:dbreport>
        <syn:send/>
    </syn:sequence>
    <syn:sequence name="endpoint_reference">
        <syn:send>
            <syn:endpoint>
                <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
            </syn:endpoint>
        </syn:send>
    </syn:sequence>
    <syn:sequence name="fault">
        <syn:log level="custom" separator=",">
            <syn:property name="text" value="An unexpected error occured"/>
            <syn:property xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="message" expression="get-property('ERROR_MESSAGE')"/>
        </syn:log>
        <syn:drop/>
    </syn:sequence>
    <syn:sequence name="mailing_sequence">
        <syn:property name="OUT_ONLY" value="true"/>
        <syn:send>
            <syn:endpoint>
                <syn:address uri="mailto:evanthika@wso2.com"/>
            </syn:endpoint>
        </syn:send>
    </syn:sequence>
    <syn:sequence name="logging_sequence">
        <syn:log level="full" separator=","/>
    </syn:sequence>
    <syn:sequence statistics="enable" name="clone_sequence">
        <syn:in>
            <syn:clone>
                <syn:target sequence="logging_sequence"/>
                <syn:target sequence="endpoint_reference"/>
            </syn:clone>
            <syn:log level="full" separator=","/>
        </syn:in>
        <syn:out>
            <syn:clone>
                <syn:target sequence="dbsequence"/>
                <syn:target sequence="mailing_sequence"/>
            </syn:clone>
        </syn:out>
    </syn:sequence>
</syn:definitions>
 
18 DB Lookup Mediator
<syn:sequence name="dblookup_sequence">
        <syn:in>
            <syn:log level="custom" separator=",">
                <syn:property name="text" value="** Looking up from the Database **"/>
            </syn:log>
            <syn:dblookup>
                <syn:connection>
                    <syn:pool>
                        <syn:driver>org.apache.derby.jdbc.ClientDriver</syn:driver>
                        <syn:password>esb</syn:password>
                        <syn:user>esb</syn:user>
                        <syn:url>jdbc:derby://localhost:1527/esbdb;create=false</syn:url>
                    </syn:pool>
                </syn:connection>
                <syn:statement>
                    <syn:sql>select * from company where name =?</syn:sql>
                    <syn:parameter xmlns:m0="http://services.samples/xsd" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" expression="//m0:getQuote/m0:request/m0:symbol" type="VARCHAR"/>
                    <syn:result name="company_id" column="id"/>
                </syn:statement>
                <syn:statement>
                    <syn:sql>select * from company where name ='GOOGLE'</syn:sql>
                    <syn:result name="company_name" column="name"/>
                </syn:statement>
                <syn:statement>
                    <syn:sql>select * from company where price>0.00</syn:sql>
                    <syn:result name="stock_price" column="price"/>
                </syn:statement>
            </syn:dblookup>
            <syn:log level="custom" separator=",">
                <syn:property xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="text" expression="fn:concat('Company Name - ',get-property('company_name'))"/>
                <syn:property xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="text" expression="fn:concat('Stock Price - ',get-property('stock_price'))"/>
                <syn:property xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="text" expression="fn:concat('Company ID - ',get-property('company_id'))"/>
            </syn:log>
            <syn:switch xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" source="get-property('company_id')">
                <syn:case regex="c1">
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" expression="fn:concat('Company Id - ',get-property('company_id'))"/>
                        <syn:property name="text" value="fn:concat('Company Name - ','IBM')"/>
                    </syn:log>
                    <syn:send>
                        <syn:endpoint>
                            <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
                        </syn:endpoint>
                    </syn:send>
                </syn:case>
                <syn:case regex="c2">
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" expression="fn:concat('Company ID - ',get-property('company_id'))"/>
                        <syn:property name="text" expression="fn:concat('Company Name - ','SUN')"/>
                    </syn:log>
                    <syn:send>
                        <syn:endpoint>
                            <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
                        </syn:endpoint>
                    </syn:send>
                </syn:case>
                <syn:case regex="c3">
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" expression="fn:concat('Company ID - ',get-property('company_id'))"/>
                        <syn:property name="text" expression="fn:concat('Company Name - ','MSFT')"/>
                    </syn:log>
                    <syn:send>
                        <syn:endpoint>
                            <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
                        </syn:endpoint>
                    </syn:send>
                </syn:case>
                <syn:case regex="c4">
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" expression="fn:concat('Company ID - ',get-property('company_id'))"/>
                        <syn:property name="text" expression="fn:concat('Company Name - ','GOOGLE')"/>
                    </syn:log>
                    <syn:send>
                        <syn:endpoint>
                            <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
                        </syn:endpoint>
                    </syn:send>
                </syn:case>
                <syn:case regex="c5">
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" expression="fn:concat('Company ID - ',get-property('company_id'))"/>
                        <syn:property name="text" expression="fn:concat('Company Name - ','MULE')"/>
                    </syn:log>
                    <syn:send>
                        <syn:endpoint>
                            <syn:address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
                        </syn:endpoint>
                    </syn:send>
                </syn:case>
                <syn:default>
                    <syn:log level="custom" separator=",">
                        <syn:property name="text" value="** Unrecognized Company ID **"/>
                    </syn:log>
                    <syn:makefault version="soap11">
                        <syn:code xmlns:sf11="http://schemas.xmlsoap.org/soap/envelope/" value="sf11:Server"/>
                        <syn:reason value="** Unrecognized Company ID **"/>
                    </syn:makefault>
                    <syn:property name="RESPONSE" value="true"/>
                    <syn:header name="To" action="remove"/>
                    <syn:send/>
                    <syn:drop/>
                </syn:default>
            </syn:switch>
        </syn:in>
        <syn:out>
            <syn:send/>
        </syn:out>
    </syn:sequence>


18 XQuery Mediators
<syn:sequence name="xquery_sequence">
<syn:in>
        <syn:xquery key="xquery_add_req">
        	<syn:variable name="payload" type="ELEMENT"/>
        	<syn:variable xmlns:m0="http://add.math.com" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="x" expression="self::node()//m0:add/m0:x/child::text()" type="INT"/>
        	<syn:variable xmlns:m0="http://add.math.com" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="y" expression="self::node()//m0:add/m0:y/child::text()" type="INT"/>
        </syn:xquery>
        <syn:send>
        <syn:endpoint>
                <syn:address uri="http://localhost:9001/soap/Adding"/>
        </syn:endpoint>
        </syn:send>
</syn:in>
<syn:out>
        <syn:xquery key="xquery_add_res">
        	<syn:variable name="payload" type="ELEMENT"/>
        	<syn:variable xmlns:m0="http://add.math.com" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="return" expression="self::node()//m0:return/child::text()" type="INT"/>
        </syn:xquery>
        <syn:send/>
</syn:out>
</syn:sequence>
 

Powered by a free Atlassian Confluence Open Source Project License granted to WSO2 Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators