用 wso2esb 中的 get-属性 替换函数

replace function with get-property in wso2esb

我正在尝试以下选项,但出现错误,任何人都可以建议我解决方案。我添加了 synapse.xpath.dom.failover.enabled=true 代码:尝试将 ~TOKEN~ 替换为 属性 值

<property name="verificationLink" expression="fn:replace($ctx:reqVerifyUrl , '~TOKEN~', get-property('verification_code'))" scope="default" type="STRING" xmlns:fn="http://www.w3.org/2005/xpath-functions" />

错误:

TID: [-1234] [] [2017-02-15 00:14:19,318] ERROR {org.apache.synapse.util.xpath.SynapseXPath} - Evaluation of the XPath expression fn:replace($ctx:reqVerifyUrl , '~TOKEN~', get-property('verification_code')) resulted in an error {org.apache.synapse.util.xpath.SynapseXPath} net.sf.saxon.trans.XPathException: Unknown system function get-property()

get-property 不是标准的 xpath 函数,你必须告诉 xpath 引擎这个函数来自突触:

<property name="verificationLink" expression="fn:replace($ctx:reqVerifyUrl , '~TOKEN~', syn:get-property('verification_code'))" scope="default" type="STRING" xmlns:fn="http://www.w3.org/2005/xpath-functions" />

你不需要添加'syn'命名空间的定义,它在你的中介中是众所周知的(xmlns:syn="http://ws.apache.org/ns/synapse")

需要做两件事:

一个。查看此内容并确保您的 Synapse 配置设置正确。 Is there any replace function in wso2esb?

乙。然后,如果您需要在 XPath 2.0 中使用 get-属性() 等方法,则需要添加前缀 fn & syn。另请注意,您必须为“syn”和“fn”使用(包括)以下命名空间值。

xmlns:syn=”http://ws.apache.org/commons/ns/payload” 
xmlns:fn=”http://www.w3.org/2005/xpath-functions”

这是一个示例 属性 使用替换的调解器。

    <property xmlns:syn="http://ws.apache.org/commons/ns/payload" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="xmlValue" expression="fn:replace(syn:get-property('textValue'), 'xmlData=', '')></property>;