ESB中动态更改端点地址

ESB中动态更改端点地址

本文介绍了在WSO2 ESB中动态更改端点地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何动态设置端点地址?

How can I set the endpoint address dynamically?

我在运行时在属性中设置端点地址,并且需要用其值替换端点地址的URI。

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

如何用该值设置地址的URI值?

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

推荐答案

您可以创建端点像

<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>

然后在调用端点 MyEndpoint之前,将属性
设置为

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

我还发现,如果在属性名称前加上+,则不会对它进行URI编码,因此这样就可以方便地动态创建参数。否则,对于已知参数,您可以像上面针对参数f所做的操作

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 ..之类的

<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>

应将您带到

(请注意,如果您使用的是网络编辑器,它会抱怨& ..其越野车为地狱..保存为

(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;

。将其另存为&或使用javascript设置属性)

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

这篇关于在WSO2 ESB中动态更改端点地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:29