我需要在转换消息中定义以下有效负载以发送到不同的系统,但在添加转换消息或设置有效负载组件时会出现错误。
请让我知道如何将其定义为转换消息组件中的有效负载,或者如何将其转换为 json 并在发送给 http 请求者之前再次转换为 xml?
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/enveloper/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Body>
<wd:GetMappingTable xmlns:wd="urn:com.xyz/abcd" wd:version="v40.0">
<wd:RequestRef>
<wd:MappingRef>
<wd:MappingId wd:type="Integration_Mapping_ID">ACCOUNT_MP</wd:MappingId>
</wd:MappingRef>
</wd:RequestRef>
<wd:ResponseFil>
<wd:page>1</wd:page>
<wd:count>10</wd:count>
</wd:ResponseFil>
</wd:GetMappingTable>
</env:Body>
</env:Envelope>
我假设您想要生成 XML 作为 DataWeave 脚本的输出。我使用 hack 来生成
xmlns:xsd
命名空间,因为 DataWeave 不会编写未使用的命名空间。如果您可以避免使用它,只需从信封中删除该属性即可。脚本显示了方法,您可以使用它作为示例来填充剩余的几个元素。
%dw 2.0
output application/xml
ns env http://schemas.xmlsoap.org/soap/enveloper/
ns wd urn:com.xyz/abcd
---
{
env#Envelope @("xmlns:xsd": "http://www.w3.org/2001/XMLSchema"): {
env#Body: {
wd#GetMappingTable @(wd#version:"v40.0"): {
wd#RequestRef: {
wd#MappingRef @(wd#'type':""): "ACCOUNT_MP"
},
wd#ResponseFil: "TO DO"
}
}
}
}
输出:
<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/enveloper/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Body>
<wd:GetMappingTable xmlns:wd="urn:com.xyz/abcd" wd:version="v40.0">
<wd:RequestRef>
<wd:MappingRef wd:type="">ACCOUNT_MP</wd:MappingRef>
</wd:RequestRef>
<wd:ResponseFil>TO DO</wd:ResponseFil>
</wd:GetMappingTable>
</env:Body>
</env:Envelope>