I am new to the WSO2 esb. I want to create a api in which i want to add a dynamic parameter from api Url to endpoint url.
My end point url is like http://example.com/api/sync/{session_id}.json
I tried to create api like
<api name="rest" context="/sync">
<resource methods="GET" uri-template="/{id}">
<inSequence>
<log level="full">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uri.var.session"
expression="get-property('uri.var.id')"
scope="axis2"/>
</log>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<send>
<endpoint name="Mecars">
<http trace="enable"
method="get"
uri-template="http://example.com/sync/{+uri.var.session}.json"/>
</endpoint>
</send>
</inSequence>
</resource>
</api>
In log i get the value of uri.var.session But on the endpoint Uri-template it is not appending.
Please guid me how append the {id} value in the api uri-template to end point uri-template?
If you specify an endpoint, the Call mediator sends the message based on the specified endpoint. The endpoint type can be Leaf Endpoint (i.e. Address/WSDL/Default/HTTP) or Group Endpoint (i.e. Failover/Load balance/Recipient list).
An endpoint defines an external destination for an outgoing message through WSO2 Enterprise Integrator. Typically, the endpoint is the address of a proxy service, which acts as the front end to the actual service.
WSO2 Enterprise Integrator (WSO2 EI) is an open-source hybrid integration platform providing graphical and CLI tooling, integration runtimes, and monitoring with a variety of deployment options. The integration runtime engine is capable of playing multiple roles in your enterprise architecture.
A Proxy service is a way of triggering a mediation flow defined in the ESB of WSO2 Enterprise Integrator (WSO2 EI). Alternatively, you can use REST APIs, Inbound Endpoints, Scheduled Tasks or Topics and Events. Overview of proxy services. Elements of a proxy service.
Check this sample I recommend you to do string concatenation at property mediator adn use that directly at uri-template, rather adding "variable +.json" at uri-template.
That is;
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uri.var.session"
expression="get-property('uri.var.id')"
scope="axis2"/>
In the above for expression do string concatenation to construct full variable with ".json" ending.
Please remove the '+' symbol from your http end point.Its working fine to me
sample API
<api xmlns="http://ws.apache.org/ns/synapse" name="Elastic Search Using NPI" context="/api/npi/professional/npi.json">
<resource methods="OPTIONS GET" uri-template="/{npi}">
<inSequence>
<log level="full">
<property name="uri.var.npi" expression="get-property('uri.var.npi')"></property>
</log>
<send>
<endpoint>
<http method="get" uri-template="example.com/{uri.var.npi}"></http>
</endpoint>
</send>
</inSequence>
</resource>
</api>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With