我有像htt://api.orgsync.com/orgs/{orgId}/events?key={orgSyncKey}&startdate={startDate}&enddate={endDate}这样的字符串
我需要用1234替换{orgId},用2345替换{orgSyncKey},用12/01/2004替换{startDate},用15/02/2005替换{endDate}。
在wso2esb中有替换的函数吗?
发布于 2016-10-20 08:35:04
replace
是XPath 2.0附带的一个函数。要启用XPath 2.0函数,请取消synapse.properties文件中的以下条目,该条目位于$ESB_HOME/存储库/conf目录中。
synapse.xpath.dom.failover.enabled=true
然后你必须指定调解员如下,
<property
expression="fn:replace('your_original_string', 'pattern_to_replace', 'your_new_string')"
name="NEWSTRING" scope="default" type="STRING"
xmlns:fn="http://www.w3.org/2005/xpath-functions" />
发布于 2016-10-20 17:16:29
参见https://docs.wso2.com/display/ESB480/HTTP+Endpoint#HTTPEndpoint-XMLConfigurationXMLConfiguration中提到的示例
可以使用要在url中替换的键和值创建属性中介程序。然后,您可以调用send,该中介具有带有这些占位符的端点url。
发布于 2016-10-29 02:02:56
您可以使用xpath函数,该函数可以从XPath 2.0中获得。首先,您需要在esb上启用XPath2.0。设置如下属性:
synapse.xpath.dom.failover.enabled=true
在[ESB_HOME]/repository/conf/synapse.properties
文件。
假设原始字符串设置为属性,如下所示。
<property name="OriginalString"
value="htt://api.orgsync.com/orgs/{orgId}/events?key={orgSyncKey}&startdate={startDate}&enddate={endDate}"
scope="default" type="STRING"/>
可以包括以下内容,以使用属性中介器替换字符串中所需的部分。
<property name="ReplacedString" expression="fn:replace(fn:replace(fn:replace((fn:replace($ctx:OriginalString , '\{orgId\}', '1234')), '\{orgSyncKey\}', '2345'), '\{startDate\}' ,'12/01/2004'), '\{endDate\}' , '15/02/2005')" scope="default" type="STRING" xmlns:fn="http://www.w3.org/2005/xpath-functions" />
https://stackoverflow.com/questions/40148230
复制相似问题