WSO2 ESB迭代调解员加入

时间:2016-09-04 23:01:17

标签: iterator wso2esb sequences

我在这个过程中遇到了一些问题。让我解释一下:

我想调用两个服务并按此顺序加入响应:

我有第一个服务的回复:

<locations xmlns="http://ssocial.com/traceit/services/location">
        <location>
            <latitude>-33.45209980</latitude>
            <longitude>-70.66241990</longitude>
            <altitude>0.0</altitude>
            <creation>2016-09-04T14:59:48.000-03:00</creation>
            <updated>2016-09-04T14:59:48.000-03:00</updated>
            <deviceId>25</deviceId>
        </location>
        <location>
            <latitude>-33.45149521</latitude>
            <longitude>-70.66146224</longitude>
            <altitude>817.0</altitude>
            <creation>2016-09-04T13:18:43.000-03:00</creation>
            <updated>2016-09-04T13:18:43.000-03:00</updated>
            <deviceId>25</deviceId>
        </location>
    </locations>

然后我有secon服务的回复:

<device xmlns="http://ssocial.com/traceit/services/device">
<id>25</id>
<code>mobile_02</code>
<type>
    <id>1</id>
    <name>MOBILE</name>
</type>

然后,我想要的最终回应是:

<locations xmlns="http://ssocial.com/traceit/services/location">
        <location>
            <latitude>-33.45209980</latitude>
            <longitude>-70.66241990</longitude>
            <altitude>0.0</altitude>
            <creation>2016-09-04T14:59:48.000-03:00</creation>
            <updated>2016-09-04T14:59:48.000-03:00</updated>
            <deviceId>25</deviceId>
            <device xmlns="http://ssocial.com/traceit/services/device">
                <id>25</id>
                <code>mobile_02</code>
                <type>
                    <id>1</id>
                    <name>MOBILE</name>
                </type>
            </device>
        </location>
        <location>
            <latitude>-33.45149521</latitude>
            <longitude>-70.66146224</longitude>
            <altitude>817.0</altitude>
            <creation>2016-09-04T13:18:43.000-03:00</creation>
            <updated>2016-09-04T13:18:43.000-03:00</updated>
            <deviceId>25</deviceId>
            <device xmlns="http://ssocial.com/traceit/services/device">
                <id>25</id>
                <code>mobile_02</code>
                <type>
                    <id>1</id>
                    <name>MOBILE</name>
                </type>
            </device>
        </location>
    </locations>

我真的有很多麻烦试图加入这样的响应,这是我在wso2中的序列:

<sequence name="getDeviceInfoByLocationProcess" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="count(//ns1:locations/ns1:location)" name="LOCATIONS_COUNT" scope="default" type="STRING" xmlns:ns1="http://ssocial.com/traceit/services/location"/>
<iterate description="" expression="//ns1:locations/ns1:location/ns1:deviceId" id="LOCATIONS_ITERATOR" xmlns:ns1="http://ssocial.com/traceit/services/location">
    <target>
        <sequence>
            <property description="device_id" expression="//ns1:deviceId" name="device_id" scope="default" type="STRING"/>
            <sequence key="getDeviceInfoProcess"/>
        </sequence>
    </target>
</iterate>
<log level="custom">
    <property expression="//ns1:locations" name="LOCATIONS" xmlns:ns1="http://ssocial.com/traceit/services/location"/>
    <property expression="//ns2:device" name="DEVICE_INFO" xmlns:ns2="http://ssocial.com/traceit/services/device"/>
</log>
<property name="ECNCLOSING_ELEMENT" scope="default">
    <wrapper xmlns=""/>
</property>
<aggregate id="AGG_01">
    <completeCondition>
        <messageCount max="-1" min="{get-property('LOCATIONS_COUNT')}"/>
    </completeCondition>
    <onComplete expression="//ns2:device" xmlns:ns2="http://ssocial.com/traceit/services/device">
        <log level="full">
            <property expression="$ctx:LOCATIONS_COUNT" name="COUNTER"/>
            <property expression="$ctx:ECNCLOSING_ELEMENT" name="ENCLOSING"/>
        </log>
        <call/>
    </onComplete>
</aggregate>

实际上这个序列,我只是得到了这个:

<device xmlns="http://ssocial.com/traceit/services/device">
<id>25</id>
<code>mobile_02</code>
<type>
    <id>1</id>
    <name>MOBILE</name>
</type>

事先,非常感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我无法看到&#34; getDeviceInfoProcess&#34;的内容。顺序,但我想你正在使用呼叫中介。因此,由于这些请求(由于迭代介体而导致的多个请求),您会收到一些响应,并且您必须在初始中介的其余部分中处理这些内容:聚合为您提供了等待所有响应的方法,但是初始消息丢失:您应该将其保存在属性(类型OM)中,并使用aggregate / onComplete中的payloadMediator之类的内容来组成最终消息。