soap:DateWeave(json转xml映射,xml中包含json)

时间:2021-11-11 01:27:30

案例:
soap:DateWeave(json转xml映射,xml中包含json)

来源结构json:

{
    "param": "{\"bus_account\":\"2950891\",\"interface_code\":\"JK20230320000002\",\"body\":{\"data\":{\"list\":[{\"refundsDeliveryNumber\":\"INSD202303310523\",\"refundsDeliveryTime\":\"2023-04-03 00:00:00\",\"refundsDeliveryType\":\"IQC_RETURN\",\"toElsAccount\":\"VEN00039\",\"refundsDeliveryStatus\":\"6\",\"refundsReason\":\"\",\"refundsPrincipal\":\"节卡.孙\",\"purchaseOrg\":\"C002\",\"purchaseRefundsDeliveryItemList\":[{\"orderNumber\":\"CGDDR20230329\",\"materialNumber\":\"2209000031\",\"refundsQuantity\":\"\",\"itemStatus\":\"7\",\"orderItemNumber\":\"10\",\"storageLocation\":\"W201\"}]},{\"refundsDeliveryNumber\":\"INSD202303311046\",\"refundsDeliveryTime\":\"2023-03-31 00:00:00\",\"refundsDeliveryType\":\"IQC_RETURN\",\"toElsAccount\":\"VEN00039\",\"refundsDeliveryStatus\":\"6\",\"refundsReason\":\"\",\"refundsPrincipal\":\"节卡.孙\",\"purchaseOrg\":\"C002\",\"purchaseRefundsDeliveryItemList\":[{\"orderNumber\":\"CGDDR20230329\",\"materialNumber\":\"2209000031\",\"refundsQuantity\":\"\",\"itemStatus\":\"7\",\"orderItemNumber\":\"10\",\"storageLocation\":\"W201\"}]}]},\"busAccount\":\"2950891\",\"simpleFlag\":\"1\",\"interfaceCode\":\"getRefundsDeliveryHeadFromWms\"}}",
    "secret": "8ed9e3c00f5b4e78bc2650be619db1fa",
    "key": "dba2b4a8"
}

目标结构xml:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
    <qqt:key xmlns:qqt="https://www.51qqt.com">dba2b4a8</qqt:key>
    <qqt:secret xmlns:qqt="https://www.51qqt.com">8ed9e3c00f5b4e78bc2650be619db1fa</qqt:secret>
  </soap:Header>
  <soap:Body>
    <qqt:invokeByKey xmlns:qqt="https://www.51qqt.com">
      <param>{"bus_account":"2950891","interface_code":"JK20230320000002","body":{"data":{"list":[{"refundsDeliveryNumber":"INSD202303310523","refundsDeliveryTime":"2023-04-03 00:00:00","refundsDeliveryType":"IQC_RETURN","toElsAccount":"VEN00039","refundsDeliveryStatus":"6","refundsReason":"","refundsPrincipal":"节卡.孙","purchaseOrg":"C002","purchaseRefundsDeliveryItemList":[{"orderNumber":"CGDDR20230329","materialNumber":"2209000031","refundsQuantity":"","itemStatus":"7","orderItemNumber":"10","storageLocation":"W201"}]},{"refundsDeliveryNumber":"INSD202303311046","refundsDeliveryTime":"2023-03-31 00:00:00","refundsDeliveryType":"IQC_RETURN","toElsAccount":"VEN00039","refundsDeliveryStatus":"6","refundsReason":"","refundsPrincipal":"节卡.孙","purchaseOrg":"C002","purchaseRefundsDeliveryItemList":[{"orderNumber":"CGDDR20230329","materialNumber":"2209000031","refundsQuantity":"","itemStatus":"7","orderItemNumber":"10","storageLocation":"W201"}]}]},"busAccount":"2950891","simpleFlag":"1","interfaceCode":"getRefundsDeliveryHeadFromWms"}}</param>
    </qqt:invokeByKey>
  </soap:Body>
</soap:Envelope>

脚本:

%dw 2.0         
output application/xml         
ns soap http://www.w3.org/2003/05/soap-envelope         
ns qqt https://www.51qqt.com         
---         
{
        soap#Envelope: {
                soap#Header: {
                        qqt#key: payload.key,
                        qqt#secret: payload.secret,
                },
                soap#Body: {
                        qqt#invokeByKey: {
                                param: payload.param
                        },
                },
        },
}