2016-02-02 120 views
0

我有一個代理編寫來彙總來自不同DSS服務的消息,並將所有內容組合到一個響應中。代理配置變爲如下wso2 esb聚合和響應豐富

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="AggregateEmpMessageProxy" 
     transports="https,http" 
     statistics="disable" 
     trace="disable" 
     startOnLoad="true"> 
    <target> 
     <inSequence> 
     <log level="full"/> 
     <clone> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <p:select_with_key_emp_id_operation xmlns:p="http://ws.wso2.org/dataservice"> 
          <p:id>$1</p:id> 
         </p:select_with_key_emp_id_operation> 
        </format> 
        <args> 
         <arg xmlns:m="http://ws.wso2.org/dataservice" 
          evaluator="xml" 
          expression="//m:select_with_key_emp_id_operation/m:id"/> 
        </args> 
        </payloadFactory> 
        <header name="Action" 
          scope="default" 
          value="http://ws.wso2.org/dataservice/select_with_key_emp_id_operation"/> 
        <send> 
        <endpoint name="ID_Service"> 
         <address uri="http://compute-1.amazonaws.com:9767/services/emp_id_DataService.HTTPEndpoint"/> 
        </endpoint> 
        </send> 
       </sequence> 
      </target> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <p:select_with_key_emp_desig_operation xmlns:p="http://ws.wso2.org/dataservice"> 
          <p:id>$1</p:id> 
         </p:select_with_key_emp_desig_operation> 
        </format> 
        <args> 
         <arg xmlns:m="http://ws.wso2.org/dataservice" 
          evaluator="xml" 
          expression="//m:select_with_key_emp_id_operation/m:id"/> 
        </args> 
        </payloadFactory> 
        <header name="Action" 
          scope="default" 
          value="http://ws.wso2.org/dataservice/select_with_key_emp_desig_operation"/> 
        <send> 
        <endpoint name="Exp_Service"> 
         <address uri="http://compute-1.amazonaws.com:9767/services/emp_desig_DataService.HTTPEndpoint"/> 
        </endpoint> 
        </send> 
       </sequence> 
      </target> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <p:select_with_key_emp_exp_operation xmlns:p="http://ws.wso2.org/dataservice"> 
          <p:id>$1</p:id> 
         </p:select_with_key_emp_exp_operation> 
        </format> 
        <args> 
         <arg xmlns:m="http://ws.wso2.org/dataservice" 
          evaluator="xml" 
          expression="//m:select_with_key_emp_id_operation/m:id"/> 
        </args> 
        </payloadFactory> 
        <header name="Action" 
          scope="default" 
          value="http://ws.wso2.org/dataservice/select_with_key_emp_exp_operation"/> 
        <send> 
        <endpoint name="Desig_Service"> 
         <address uri="http://compute-1.amazonaws.com:9767/services/emp_exp_DataService.HTTPEndpoint"/> 
        </endpoint> 
        </send> 
       </sequence> 
      </target> 
     </clone> 
     </inSequence> 
     <outSequence> 
     <aggregate> 
      <completeCondition> 
       <messageCount/> 
      </completeCondition> 
      <onComplete xmlns:s12="http://www.w3.org/2003/05/soap-envelope" 
         xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" 
         expression="/s11:Envelope/s11:Body/child::*[position()=1] | /s12:Envelope/s12:Body/child::*[position()=1]"> 
       <send/> 
      </onComplete> 
     </aggregate> 
     </outSequence> 
    </target> 
    <parameter name="enableMTOM">false</parameter> 
    <description/> 
</proxy> 

我得到的是

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
    <soapenv:Body> 
     <result xmlns="http://ws.wso2.org/dataservice"> 
     <id>1</id> 
     <name>meeran</name> 
     </result> 
     <result xmlns="http://ws.wso2.org/dataservice"> 
     <designation>engineer</designation> 
     <level>B2</level> 
     </result> 
     <result xmlns="http://ws.wso2.org/dataservice"> 
     <age>26</age> 
     <exp>3</exp> 
     </result> 
    </soapenv:Body> 
</soapenv:Envelope> 

的反應,但我回應,我在找的是

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
     <soapenv:Body> 
      <result xmlns="http://ws.wso2.org/dataservice"> 
      <id>1</id> 
      <name>meeran</name>   
      <designation>engineer</designation> 
      <level>B2</level>   
      <age>26</age> 
      <exp>3</exp> 
      </result> 
     </soapenv:Body> 
    </soapenv:Envelope> 

如何實現上述迴應?我應該在聚合介體之後使用什麼介體。請幫忙。

回答

0

在aggregate/onComplete中,在發送之前,您可以使用xslt mediatior並在您的xsl中,在結果節點上定義一個模板並複製它的所有子節點。