在WSO2 ESB(4.8.1)中迭代DSS(3.2.2)响应不能按预期工作

时间:2016-09-04 13:18:10

标签: iterator wso2 esb dss

我正在对DSS响应进行迭代,但没有按预期工作

以下是DSS的有效负载和呼叫:

<payloadFactory media-type="xml">
      <format>
         <p:getNominaIDDetails xmlns:p="http://ws.wso2.org/dataservice">
            <xs:column1 xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:column1>
            <xs:column2 xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:column2>
            <xs:column3 xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:column3>
            <xs:column4 xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:column4>
         </p:getNominaIDDetails>
      </format>
      <args>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column1')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column2')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column3')" evaluator="xml"></arg>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column4')" evaluator="xml"></arg>
      </args>
   </payloadFactory>

   <header name="Action" scope="default" value="urn:xxxxxxx"></header>
   <call>
      <endpoint key="gov:/dss/endpoint"></endpoint>
   </call>
    <filter xmlns:ns="http://org.apache.synapse/xsd"
           xmlns:ds="http://ws.wso2.org/dataservice"
           xpath="get-property('db_count')&gt;0">
      <then>
         <iterate id="xxx"
                  preservePayload="true"
                  attachPath="//ds:xxxx"
                  expression="//ds:xxx/ds:xxx">
            <target sequence="My_seq">
            </target>
         </iterate>
      </then>
      <else>
         <drop/>
      </else>
   </filter>

来自dss的回应是:

<response xmlns="http://ws.wso2.org/dataservice">       
        <id>
            <column1>234</column1>
            <column1>4455</column1>
            <column1>567778</column1>
        </id>
        <id>
            <column1>546</column1>
            <column1>56866</column1>
            <column1>464453</column1>
        </id>
        <id>
            <column1>546</column1>
            <column1>56866</column1>
            <column1>464453</column1>
        </id>
    </response>

上述响应在第一次迭代时完成,并且在全局超时后保留所有消息到期。下面是第一次迭代后的日志:

{org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2016-09-04 06:26:13,471]  WARN {org.apache.synapse.core.axis2.SynapseCallbackReceiver} -  Synapse received a response for the request with message Id : urn:uuid:c62d7dae-5290-49d1-b1bd-b5d2dcba7e04 But a callback is not registered (anymore) to process this response {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2016-09-04 06:26:42,144]  WARN {org.apache.synapse.core.axis2.TimeoutHandler} -  Expiring message ID : urn:uuid:36df3897-73be-4bc3-a434-aaab618c7ce3; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}
TID: [0] [ESB] [2016-09-04 06:26:42,145]  WARN {org.apache.synapse.core.axis2.TimeoutHandler} -  Expiring message ID : urn:uuid:d8ec8998-95c6-4d70-9e33-c11bda271e90; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}

注意:迭代器内部执行以下操作(sequence =“My_seq”)

执行银行电话会议 - &gt; DSS呼叫 - &gt;使用呼叫媒体进行SAP呼叫

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="My_seq" >
    <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ds="http://ws.wso2.org/dataservice" name="id" expression="//ds:dss_response/ds:Id" scope="default" type="STRING"/>
    <payloadFactory media-type="xml">
        <format>
            <h:opertion xmlns:h="http://ws.wso2.org/xxxxxx">
                <h2h:id>$1</h2h:id>
            </h:opertion>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('id')"/>
        </args>
    </payloadFactory>
    <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('xxxxx:xxxxxxxx'))" scope="transport" type="STRING"/>
    <property name="ContentType" value="application/soap+xml" scope="axis2" type="STRING"/>
    <property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/>
     <call>
        <endpoint key="gov:/endpoint"/>
     </call>
    <sequence key="next_sequence_to_be_DSS_then_SAP"/>
</sequence>

1 个答案:

答案 0 :(得分:1)

我认为这应该符合您的要求。在这里,我检查传入响应的状态,并且只有在每个请求都成功时才向客户端发送OK。

<api xmlns="http://ws.apache.org/ns/synapse" name="MyAPI" context="/myapi">
   <resource methods="POST GET" url-mapping="/">
      <inSequence>
         <call blocking="true">
            <endpoint>
               <http uri-template="http://www.mocky.io/v2/57cd6f422d00000101b15868"/>
            </endpoint>
         </call>
         <property name="Staus" value="OK" type="STRING"/>
         <iterate xmlns:ds="http://ws.wso2.org/dataservice" id="xxx" preservePayload="true" expression="//ds:response/ds:id">
            <target>
               <sequence>
                  <send>
                     <endpoint>
                        <http uri-template="http://www.mocky.io/v2/57cd70c22d00002401b1586c"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
         </iterate>
      </inSequence>
      <outSequence>
         <filter source="$axis2:HTTP_SC" regex="200">
            <then/>
            <else>
               <property name="Staus" value="NOT OK" type="STRING"/>
            </else>
         </filter>
         <aggregate id="xxx">
            <completeCondition>
               <messageCount/>
            </completeCondition>
            <onComplete xmlns:ds="http://ws.wso2.org/dataservice" expression="/">
               <log level="custom">
                  <property name="Final Staus" expression="$ctx:Staus"/>
               </log>
               <payloadFactory media-type="xml">
                  <format>
                     <status>$1</status>
                  </format>
                  <args>
                     <arg evaluator="xml" expression="$ctx:Status"/>
                  </args>
               </payloadFactory>
               <send/>
            </onComplete>
         </aggregate>
      </outSequence>
   </resource>
</api>