简体   繁体   English

来自Property或XPath-expression的WSO2 ESB Collout地址

[英]WSO2 ESB Collout address from Property or XPath-expression

I have the config with development and production sections. 我有开发和生产部分的配置。 This sections contain the URLs of backends. 本部分包含后端的URL。 In my inSequence i need it to Callout to these backends several times per request. 在我的inSequence中,我需要针对每个请求多次调用这些后端。

<config>
 <env>prod</env>
 <backend env="prod">http://localhost:1234/</backend>
 <backend env="dev">http://localhost:2345/</backend>
</config>

I read this config from Local Entry (as XML) and want to set Callout's URL as an Property. 我从本地条目(作为XML)中读取了此配置,并希望将标注的URL设置为属性。 I don't want to hardcode these backends inside my code with "Switch" statement, because it's possible to use more than two environments. 我不想使用“ Switch”语句在代码中对这些后端进行硬编码,因为可以使用两个以上的环境。 Could you please show me an example? 你能给我举个例子吗?

Thank you. 谢谢。

You can read xml file in registry. 您可以在注册表中读取xml文件。 Simply define property of OM type like this: 只需这样定义OM类型的属性:

<property name="test" expression="get-property('registry','conf:/test.xml')" scope="default" type="OM" />

Then you can see the value by logging like this: 然后,您可以通过如下记录来查看该值:

<log level="custom"> <property name="test.b" expression="$ctx:test//b" /> </log>

And in the xml file that you have put in the root of registry, you would fill it like: 在注册表根目录下的xml文件中,您可以像这样填充它:

<a>Hello<b>WSO2</b></a>

I have learned it from this link . 我已经从这个链接中学到了。

I found the answer. 我找到了答案。 According to source of Callout mediator: 根据标注调解器的来源:

CalloutMediator.java CalloutMediator.java

It uses "To" header if URL is not specified. 如果未指定URL,则使用“ To”标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM