Skip to content

Instantly share code, notes, and snippets.

@Asitha
Last active August 13, 2017 14:30
Show Gist options
  • Select an option

  • Save Asitha/05b6eaa179ed0be3eb7a51f11548ca8e to your computer and use it in GitHub Desktop.

Select an option

Save Asitha/05b6eaa179ed0be3eb7a51f11548ca8e to your computer and use it in GitHub Desktop.
Example code using Synapse $url XPath variable to retrieve query param. Details can be found at http://asitha.github.io/cs/programming/wso2/esb/mediators/2017/08/14/get-query-params-with-wso2-esb/
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse" name="StoreAPI" context="/store">
<resource methods="GET" uri-template="/view*">
<inSequence>
<!--Read and set the parameteres to a property -->
<property name="name" expression="$url:name" scope="default" type="STRING"/>
<property name="age" expression="$url:age" scope="default" type="STRING"/>
<!--Directly use in a payload factory as follows -->
<payloadFactory media-type="xml">
<format>
<user xmlns="">
<name>$1</name>
<age>$2</age>
</user>
</format>
<args>
<arg evaluator="xml" expression="$url:name"/>
<arg evaluator="xml" expression="$url:age"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
</resource>
</api>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment