This documentation is work in progress and will be released with the next WSO2 EI version.
Sample 390: Introduction to XQuery Mediator - WSO2 Enterprise Integrator 6.x.x - WSO2 Documentation

All docs This doc
||
Skip to end of metadata
Go to start of metadata

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

This example uses the XQuery mediator to perform transformations and behaves the same as Sample 8 . The only difference is that this sample uses XQuery instead of XSLT for transformation.

  <!-- Introduction to the XQuery mediator -->
<definitions xmlns="http://ws.apache.org/ns/synapse">

    <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
    <registry provider="org.wso2.esb.registry.ESBRegistry">
        <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
        <parameter name="root">file:repository/samples/resources/</parameter>
        <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
        <parameter name="cachableDuration">15000</parameter>
    </registry>

    <localEntry key="xquery-key-req"
                src="file:repository/samples/resources/xquery/xquery_req.xq"/>
    <proxy name="StockQuoteProxy">
        <target>
            <inSequence>
                <xquery key="xquery-key-req">
                    <variable name="payload" type="ELEMENT"/>
                </xquery>
                <send>
                    <endpoint>
                        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                    </endpoint>
                </send>
            </inSequence>
            <outSequence>
                <out>
                    <xquery key="xquery/xquery_res.xq">
                        <variable name="payload" type="ELEMENT"/>
                        <variable name="code" type="STRING"
                                  expression="self::node()//m0:return/m0:symbol/child::text()"
                                  xmlns:m0="http://services.samples/xsd"/>
                        <variable name="price" type="DOUBLE"
                                  expression="self::node()//m0:return/m0:last/child::text()"
                                  xmlns:m0="http://services.samples/xsd"/>
                    </xquery>
                    <send/>
                </out>
            </outSequence>
        </target>
        <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
    </proxy>
</definitions> 

Execute the custom quote client as 'ant stockquote -Dmode=customquote ...'

ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=customquote 
  • No labels