我有一个WSO2 ESB 4.8.1序列,它将消息发送到定义为的HTTP端点
<http method="get" uri-template="http://host.example.com/v1/entity/{uri.var.id}/attributes/foo">该属性以前由XPath设置:
<property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.id" expression="//id" scope="default" type="STRING" />有时它会调用正确的URL,有时它会直接调用http://host.example.com/v1/entity/{uri.var.id}/attributes/foo而不替换变量。 为什么?
I have a WSO2 ESB 4.8.1 sequence which sends a message to an HTTP endpoint defined as
<http method="get" uri-template="http://host.example.com/v1/entity/{uri.var.id}/attributes/foo">The property is previously set by XPath:
<property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.id" expression="//id" scope="default" type="STRING" />Sometimes it invokes the correct URL, and sometimes it literally calls http://host.example.com/v1/entity/{uri.var.id}/attributes/foo without substituting the variable. Why?
最满意答案
可能有其他可能的原因,但似乎是我的问题的原因是逃避。 如果ID是纯字母数字字符串,那么它可以工作,但如果它包含空格字符,则它不会被替换。 记录错误消息并转到故障序列会更有帮助,但这是用WSO2引发的。
我发现的修复是通过编辑repository/conf/synapse.properties来启用XPath 2.0并取消注释synapse.xpath.dom.failover.enabled=true ; 然后使用XPath 2.0的转义功能:
<property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.id" expression="encode-for-uri(//id)" scope="default" type="STRING"/>There may be other possible reasons, but what seems to be the cause of my problems is escaping. If the ID is a pure alphanumeric string then it works, but if it includes a space character then it isn't substituted. It would be more helpful to log an error message and go to the fault sequence, but that's something to raise with WSO2.
The fix which I've found is to enable XPath 2.0 by editing repository/conf/synapse.properties and uncommenting synapse.xpath.dom.failover.enabled=true ; and then to use XPath 2.0's escaping functionality:
<property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.id" expression="encode-for-uri(//id)" scope="default" type="STRING"/>
更多推荐
发布评论