Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically change endpoint address in WSO2 ESB

How can I set the endpoint address dynamically?

I set endpoint address in a property at runtime, and need to replace the URI of endpoint address with its value.

How can I set the URI value of address with this value?

like image 506
Ramtin Ramtin Avatar asked Apr 08 '13 10:04

Ramtin Ramtin


1 Answers

You can create your endpoint like

<endpoint xmlns="http://ws.apache.org/ns/synapse" name="MyEndpoint">
   <http uri-template="{uri.var.full}?f={uri.var.f}{+uri.var.extra}" method="put">
   </http>
</endpoint>

Then before calling the endpoint 'MyEndpoint' set the properties .. the properties, to be parsed for an endpoint must begin with uri.

I also found out, that if you put a + before the property name, it doesn't URI encode it, so it's handy for creating parameters on the fly.. otherwise for known parameters, you can do like above for paramameter f

so .. something like

<property name="uri.var.full" value="http://jarhedz.com/viewtopic.php"/>
<property name="url.var.f" value="2"/>
<property name="uri.var.extra" value="&t=39"/>
<send>
    <endpoint key="MyEndpoint"></endpoint>
</send>

should bring you to the url http://jarhedz.com/viewtopic.php?f=2&t=39

(btw just as a note, if you're using the web editor, it'll complain about the & .. its buggy as hell .. save it as

&amp; 

.. and that saves it as & or set the property using javascript )

like image 181
Brian Avatar answered Sep 30 '22 05:09

Brian