需要一些帮助来处理下面的场景
从源系统(Workday)的有效负载中接收一个元素/属性为Muñiz,并使用SFTP写操作和SFTP写将此值作为Muñiz放在。csv文件中。
源系统团队说他们不能在工作日更改此值Muñiz,并要求我们仅在Mulesoft中处理…因此,我们在将文件写入SFTP之前使用数据转换(如下面的第二步)。
%dw 2.0
output application/csv
encoding="UTF-8"
- HTTP请求工作日调用-获取属性Muñiz中的一个工作日的响应
- 数据映射
- Pgp加密
- SFTP写
当我们在调试中看到Pgp加密之前的有效载荷值时,它显示为Muñiz
当我们在SFTP写入文件夹中打开文件时这个值显示的是。csv文件中的Muñiz
注意:我读了一个文档使用BOM(字节顺序标记)来处理这些情况,但不确定如何使用和处理使用BOM。不确定我们是否需要使用BOM或Mule中任何简单的选项。
谁能写一个简单的骡子流代码,并在这里分享,以便我将使用相同的代码?
最终输出应以。csv格式写入:Muniz
我写了一个小应用程序,使用HTTP POST
请求传递各种各样的"funky"汉字,就我而言,我能够读和写"funky"人物:
请求:
curl --request POST
--url http://localhost:8081/csv
--header 'Content-Type: application/json'
--data '{
"lastName": "Muñiz",
"greek": "Ο καθηγητής Χ. Γώγος στον ΣΚΑΪ",
"hebrew": "עִבְרִית"
}'
这是应用程序的XML:
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<http:listener-config name="HTTP_Listener_config"
doc:name="HTTP Listener config"
doc:id="100ea742-8e79-4703-a162-8400fb676aa6">
<http:listener-connection host="0.0.0.0"
port="8081" />
</http:listener-config>
<flow name="munozFlow"
doc:id="7f291db1-f477-49e7-bb12-8b8bfeb2ff71">
<http:listener doc:name="Listener"
doc:id="7fdbcd73-a2bd-433b-a04a-098ff02e2cdc"
config-ref="HTTP_Listener_config" path="/csv" />
<ee:transform doc:name="Transform Message"
doc:id="1c2d63a3-9b60-472c-8cd8-3df5e1671ad9">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/csv
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<file:write doc:id="61da842e-aa0e-46e8-85e4-c7ad349504bf"
path='#["tmp/output-" ++ (now() as String {format: "yyyyMMddHHmmssSSS"}) ++ ".csv"]' />
</flow>
</mule>
最后,生成的CSV文件如下:
lastName,greek,hebrew
Muñiz,Ο καθηγητής Χ. Γώγος στον ΣΚΑΪ,עִבְרִית
总之,如果你对从Workday获得的文本有正确的编码,那么Mule将能够适应。我敢打赌,无论您使用的是哪种Workday操作,都没有为您提供正确的编码。
还要验证您正在使用的应用程序可以显示"funky"显示文件内容时的字符
如果目标是替换CSV输出中的某些特定字符,则可以使用使用Unicode转义字符序列的replace()。
的例子:
%dw 2.0
output application/csv
fun replaceChars(s)=s replace "u00F1" with("n")
---
payload map ($ mapObject ($$): replaceChars($))
输入:
[{
"name": "Muu00F1iz",
"address": "Main Street 11"
}]
输出:name,address
Muniz,Main Street 11