我使用本地条目来注册参数,而不是在工件中固定,我不知道这是否是更好的解决方案。
当我在 ESB Config 中创建本地条目时,一切正常,但当我在项目注册表资源中创建时,我无法正确读取。
我使用下面的代码来读取本地条目并写入属性:
<Property description = "SetPPSUserName" expression = "get-property ('registry', 'conf: /local-entries/PPS_Username.xml')" name = "SetPPSUserName" scope = "default" type = "STRING" />
问题是它加载本地条目的整个 xml 内容,而不仅仅是内容,例如属性:
SetPPSUserName = "<localEntry key="PPS_Username" xmlns="http://ws.apache.org/ns/synapse"><![CDATA [content test blablab]]></ localEntry>"
正确的是:
SetPPSUserName = "content test blablab"
注意:当我将CAR上传到站点时,项目注册表资源的本地条目不会出现在管理控制台的本地条目列表中。
使用谷歌翻译器将消息从葡萄牙语翻译成英语
最佳答案
试试这个:
在属性中设置 type = OM 而不是 STRING。
<Property description = "SetPPSUserName" expression = "get-property ('registry', 'conf: /local-entries/PPS_Username.xml')" name = "SetPPSUserName" scope = "default" type = "OM" />
<log level="custom">
<property name="call_testProp" expression="$ctx:SetPPSUserName" type="STRING"/>
</log>
更新1:
注册表中我的 localEntry:
<localEntry key="PPS_Usernamelocal" xmlns="http://ws.apache.org/ns/synapse">
<a>
<b>TEST</b>
</a>
</localEntry>
我的 esb 代理内的属性和日志中介:
<property name="PPS_Username"
expression="get-property('registry','conf:/localentries/PPS_Username.xml')"
scope="default"
type="OM"/>
<log level="custom">
<property name="PPS_UsernameB" expression="$ctx:PPS_Username//syn:a/syn:b" xmlns:syn="http://ws.apache.org/ns/synapse"/>
</log>
我的 ESB 回复:
[2017-02-22 16:21:42,680] INFO - LogMediator PPS_UsernameB = TEST
关于wso2 - 如何从注册表资源中读取本地条目的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42352713/