【问题标题】:MULE example: Sending a CSV file through Email using SMTPMULE 示例:使用 SMTP 通过电子邮件发送 CSV 文件
【发布时间】:2016-09-19 07:46:24
【问题描述】:

嘿嘿, 我是 MULE 的新手,我尝试从 Mule 的 sida 中学习“如何”:https://www.mulesoft.com/exchange#!/sending-csv-email-smtp?searchTerm=email 我认为我做的一切都很好,项目正在部署,但是当文件被获取时抛出异常并且我得到了沟通: 异常堆栈是: 1. 无法将 :binary 强制转换为 :array (com.mulesoft.weave.model.values.coercion.exception.UnsupportedTypeCoercionException) com.mulesoft.weave.model.values.formatting.ArrayFormatTypeCoercionValue:31 (null) 2.执行时出现异常: 有效载荷映射{ ^ 无法将 :binary 强制转换为 :array (com.mulesoft.weave.mule.exception.WeaveExecutionException) com.mulesoft.weave.mule.WeaveMessageProcessor:124 (null)。

没有人知道发生了什么。有人对这个例子有同样的问题吗?

【问题讨论】:

标签: mule anypoint-studio


【解决方案1】:

在您的 DataWeave 中使用以下 mimeType:- <dw:input-payload doc:sample="list_csv.csv" mimeType="application/csv"/>

所以,完整的代码如下:-

  <smtp:gmail-connector doc:name="Gmail" name="Gmail" validateConnections="true"/>
    <flow name="csv-to-smtpFlow">
        <file:inbound-endpoint doc:name="Poll files" metadata:id="a75d5954-7fb4-4721-85f6-7ee66b793750" path="E:\test" responseTimeout="10000"/>
        <dw:transform-message doc:name="Transform CSV to Map" metadata:id="84d175de-b3c6-4480-af9d-150e736f051e">
            <dw:input-payload doc:sample="list_csv.csv" mimeType="application/csv"/>
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map {
    name: $.name,
    orderId: $.orderId,
    pricePerUnit: $.pricePerUnit as :number,
    units: $.units as :number,
    totalPrice: ($.units * $.pricePerUnit ) as :number
}]]></dw:set-payload>
        </dw:transform-message>
        <logger doc:name="Log the processed objects" level="INFO" message="Processing objects: #[payload]"/>
     <smtp:outbound-endpoint connector-ref="Gmail" doc:name="Send an email via SMTP" from="${mail.from}" host="${smtp.host}" password="${smtp.password}" port="587" responseTimeout="10000" subject="${mail.subject}" to="${mail.to}" user="${smtp.user}"/> 
    </flow>

这将解决您的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-06
    • 2017-05-12
    • 2011-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    相关资源
    最近更新 更多