在 WSO2 ESB 中动态更改端点地址 [英] Dynamically change endpoint address in WSO2 ESB

查看:19
本文介绍了在 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?

推荐答案

你可以像这样创建你的端点

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>

然后在调用端点MyEndpoint"之前设置属性.. 为端点解析的属性必须以 uri 开头.

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

所以..类似

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

应该将您带到网址 http://jarhedz.com/viewtopic.php?f=2&t=39

(顺便说一句,如果您使用的是网络编辑器,它会抱怨 & .. 它的 buggy .. 将其保存为

(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 中动态更改端点地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆