如何在WSO2 ESB中使用xpath将<a>fai</a> <b> 3 </b>转换为<fai> 3 </fai>

时间:2013-01-21 08:45:53

标签: json xpath wso2 wso2esb

我正在获得像这样的JSON

{"request":""AttributesCriteriaList":[
            {"FieldName":"PartyBranchId","OperationType":1,"FieldValue":"-1500000000","JoinType":2},
            {"FieldName":"AssetTypeId","OperationType":1,"FieldValue":"-1500000001","JoinType":2},
            {"FieldName":"PeriodFrom","OperationType":10,"FieldValue":"1356998400","JoinType":2},
            {"FieldName":"PeriodTo","OperationType":11,"FieldValue":"1358208000","JoinType":2},
            {"FieldName":"Status","OperationType":1,"FieldValue":"4","JoinType":2}
            ]
}

如何转换为

{"assetid":"150000001","partybranchid":"152555222"}

在WSO2 ESB中?

1 个答案:

答案 0 :(得分:0)

最简单的方法是使用XSLT翻译给定的消息(如果你知道编写XSLT,这看起来很简单)    然后你只需要写一个代理(在WSO2 ESB中),

 <proxy name="JSONTOJSONTranformProxy" transports="https,http">
  <target>
  <inSequence>
     <xslt key="translate.xslt"/>
     <property name="messageType" value="application/json" scope="axis2"/>
     <send>
        <address ="[SOME_ADDRESS]"/>
     </send>
  </inSequence>
  <outSequence>
     <send/>
  </outSequence>
  </target>
 </proxy>