我正在尝试编写一个DataWeave来表示这个XML:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xsi:xsd="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<AuthenticateResult xmlns="urn:authentication.soap.sforce.com">
<Authenticated>true</Authenticated>
</AuthenticateResult>
</soapenv:Body>
</soapenv:Envelope>我很难看到是否存在通过DW支持的ns和其他XML本机语法值,或者在DataWeave中声明自定义变量。
%dw 2.0
output application/xml
ns soapenv http://schemas.xmlsoap.org/soap/envelope/
ns xsi http://www.w3.org/2001/XMLSchema-instance
---
{
soapenv#Envelope
@(xsi#xsd:"http://schemas.xmlsoap.org/soap/envelope/"): {
soapenv#Body: {
AuthenticateResult @(xmlns: "urn:authentication.soap.sforce.com"): {
Authenticated: payload.login
}
}
}
}我的有效载荷就是这样的,我希望它从真或假中得到更新:
{
"login": "true"
}发布于 2022-09-19 19:34:34
您可以使用@来定义更多ns,就像使用AuthenticateResult一样
%dw 2.0
output application/xml
ns soapenv http://schemas.xmlsoap.org/soap/envelope
---
{
soapenv#Envelope @("xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "xsi:xsd":"http://schemas.xmlsoap.org/soap/envelope/"): {
soapenv#Body: {
AuthenticateResult @(xmlns: "urn:authentication.soap.sforce.com"): {
Authenticated: payload.login
}
}
}
}https://stackoverflow.com/questions/73778267
复制相似问题