Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Objective: Introduction to the dbreport mediator

 

Code Block
languagehtml/xml
<definitions xmlns="http://ws.apache.org/ns/synapse">

    <sequence name="main">
        <in>
            <send>
                <endpoint>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                </endpoint>
            </send>
        </in>

        <out>
            <log level="custom">
                <property name="text"
                          value="** Reporting to the Database **"/>
            </log>
            <dbreport xmlns="http://ws.apache.org/ns/synapse"><dbreport>
                <connection>
                    <pool>
                        <driver>org.apache.derby.jdbc.ClientDriver</driver>
                        <url>jdbc:derby://localhost:1527/esbdb;create=false</url>
                        <user>esb</user>
                        <password>esb</password>
                    </pool>
                </connection>
                <statement>
                    <sql>update company set price=? where name =?</sql>
                    <parameter expressionxmlns:m1="http://services.samples/xsd" xmlns:m0="http:return/m1:last/child::text()/services.samples"
                               xmlns:m0expression="http://services.samples" xmlns:m1="http://services.samples/xsdm0:return/m1:last/child::text()" type="DOUBLE"/>
                    <parameter expressionxmlns:m1="http://services.samples/xsd" xmlns:m0="http:return/m1:symbol/child::text()/services.samples"
                               xmlns:m0expression="http://services.samples" xmlns:m1="http://services.samples/xsdm0:return/m1:symbol/child::text()" type="VARCHAR"/>
                </statement>
            </dbreport>
            <send/>
        </out>
    </sequence>

</definitions>

Prerequisites:

  • Start the Synapse configuration numbered 361: i.e. wso2esb-samples -sn 361
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already done

...