WSO2 ESB : DYNAMICALLY CHANGE ENDPOINT ADDRESS

好久不见. 提交于 2019-11-28 01:57:15

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 )

Use Header meditaor to set "to" header and use default endpoint..Check this post for sample.

Use header mediator to set the "To" Address header with the value you extract from your assigned property.

karl

When the server doesn't publish its WSDL, see Myobis comment here. Tried addPort without success.

This method is worked for me correctly.

I need to create bellow dynamic url

http://localhost:8787/{dynamic parameter}

Inside the end point url is like this

http://localhost:8787/{uri.var.servicepath}

Set "test" variable as my dynamic parameter (If you need to set Expression value set it). Set "test" value inside the property mediator.(I did this insideproxy service)

<property name="uri.var.servicepath" scope="default" type="STRING" value="test"/>

create endpoint

In here I created HTTP End point

<endpoint name="ServiceEP" xmlns="http://ws.apache.org/ns/synapse">
   <http method="post" uri-template="http://localhost:8787/{uri.var.servicepath}"/>
</endpoint>

Then add this endpoint inside your Proxy service or API

<send>
   <endpoint key="ServiceEP"/>
</send>

Finally your proxy look like this

<inSequence>
   <property name="uri.var.servicepath" scope="default" type="STRING" 
   value="test"/>

   <send>
      <endpoint key="SurepayVASAppsEP"/>
    </send>
</inSequence>

Like this you can change every url parameter.Ex-:

http://{uri.var.hostname}:{uri.var.port}/{uri.var.servicepath}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!