【发布时间】:2020-06-04 23:40:20
【问题描述】:
请发现我的请求带有标签<Date xsi:nil="true"/>,当它穿过Multipart/form-data 数据编织时,它正在删除xsi:nil="true 部分,这在我的场景中是不期望的。我希望它是一样的。
此外,它正在删除不是预期情况的命名空间。如果我尝试在第一个数据编织中声明 ns xsi http://www.w3.org/2001/XMLSchema-instance。在响应根元素中,它以 xsi:Locations 为前缀。
我正在为此苦苦挣扎。
想要下面提到的响应,无论输入相同,都应该在不改变的情况下出来。
使用writeNilOnNull=true 会在我不想要的所有字段上置零,只想要日期。
有人可以帮忙吗?谢谢。
输入:
<Locations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<Id>2</Id>
<CarId>78</CarId>
<Packages>1</Packages>
<Date xsi:nil="true"/>
</Location>
</Locations>
预期响应:
<Locations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<Id>2</Id>
<CarId>78</CarId>
<Packages/>
<Date xsi:nil="true"/>
</Location>
</Locations>
流程:
<flow name="question" doc:id="8c836a85-9d0a-47a8-8e5a-f670b16f91eb" >
<http:listener doc:name="Listener" doc:id="52ffdb08-9587-4cb2-8232-9467e85ea0dc" config-ref="HTTP_Listener_config" path="/question"/>
<ee:transform doc:name="Transform Message" doc:id="da995adf-196b-4c7b-a265-874f059ed1bb" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<ee:transform doc:name="Transform Message" doc:id="75e5d876-855e-4d38-8468-3484c859f36e" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output multipart/form-data
---
{
"parts": {
"file": {
"headers": {
"Content-Disposition": {
"name": "file",
"filename": "",
"subtype": "form-data"
},
"Content-Type": "application/xml"
},
"content": payload
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
【问题讨论】:
-
问题不在于表单数据转换,而在于第一次转换。
标签: mule dataweave mulesoft mule4