2016-02-02 86 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中,在结果节点上定义一个模板并复制它的所有子节点。