如何比较 wso2 esb 中过滤器中介中的整数属性? [英] how to compare integer properties in filter mediation in wso2 esb?

查看:15
本文介绍了如何比较 wso2 esb 中过滤器中介中的整数属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 wso2 esb 的新手,并定义了 3 个返回整数值并使用过滤器调解器从一个路由到另一个的服务,但工作不正确,并且在过滤器模式下总是返回 false我的来源是:

i am new in wso2 esb and define 3 service that return integer value and use filter mediator to rout from one to another , but not correct work and in filter mode always return false my source is :

<sequence xmlns="http://ws.apache.org/ns/synapse" name="SeqOne">
<log level="full"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://tempuri.org/"        name="CParam" expression="//m0:SumSerViseResponse/m0:SumSerViseResult" scope="default"   type="INTEGER"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="CParam"  expression="$ctx:CParam"/>
</log>
<property name="propertyA" value="4" scope="default" type="INTEGER"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="propertyA" expression="get-property('propertyA')"/>
</log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="propertyCompare" expression="$ctx:CParam > get-property('propertyA')" type="STRING"/>
<log level="custom">
  <property xmlns:ns="http://org.apache.synapse/xsd" name="propertyCompare" expression="get-property('propertyCompare')"/>
</log>
<filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('propertyCompare')" regex="true">
  <then>

推荐答案

我尝试了你的场景,得到了和你一样的输出.然后深入研究它,因为这是一个基本功能,而且我认为我以前做过类似的事情.

I tried your scenario and got the same output as yours. Then looked deep into it as this was a basic functionality and as I thought I've done something similar before.

这里的问题在于属性的类型.由于某些奇怪的原因, INTEGER 在这里不起作用.您需要有 DOUBLESTRING.即使你有字符串,当你像这里一样进行比较时,它也会正确地转换它.以下对我有用.

The issue here is in the type of the property. For some strange reason INTEGER does not work here. You need to have DOUBLE or STRING. Even if you have string, it will correctly cast it when you do a comparison as in here. The following worked for me.

<inSequence>
     <log level="full"/>
     <property xmlns:m0="http://tempuri.org/"
               name="CParam"
               expression="//m0:SumSerViseResponse/m0:SumSerViseResult"
               scope="default"
               type="DOUBLE"/>
     <log level="custom">
        <property name="CParam" expression="$ctx:CParam"/>
     </log>
     <property name="propertyA" value="4.0" scope="default" type="DOUBLE"/>
     <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd"
                  name="propertyA"
                  expression="get-property('propertyA')"/>
     </log>
     <property name="propertyCompare"
               expression="$ctx:CParam > get-property('propertyA')"
               scope="default"
               type="BOOLEAN"/>
     <log level="custom">
        <property name="propertyCompare" expression="get-property('propertyCompare')"/>
     </log>
     <filter xpath="$ctx:CParam > get-property('propertyA')">
        <then>
           <send>
              <endpoint>
                 <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
              </endpoint>
           </send>
        </then>
        <else>
           <drop/>
        </else>
     </filter>
  </inSequence>

这篇关于如何比较 wso2 esb 中过滤器中介中的整数属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆