json - wso2 JMS JSON 到没有肥皂信封或非 xml html 的 html 电子邮件
问题描述
我想从 JMS JSON 消息中使用 wso2 4.9.0 发送一个适当的完全动态(到、从、正文、主题)html 电子邮件。
这是我想要的 SMTP 交换,其中所有值都来自 json 消息:
From: foo <noreply@bar>
Reply-To: foo <noreply@bar>
To: foobar@bar
Cc: bar@bar
Subject: =?UTF8?Q?test;_eacute:_=C3=A9?=
MIME-Version: 1.0
Content-Type: text/html; charset=UTF8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html><html><body>Hello =C3=A9<br> and a=
long line is split before 76 chars</body></html>
我试过(为了清楚起见缩写):
mc.setPayloadXML(<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">{message}</ns:text>);
// Almost OK but with 4.9.0, the PlainTextFormatter forces the Content-Type to text/plain (I think this is solved in wso2esb 5+)
我也试过:
//Using in axis2.xml : <messageFormatter contentType="text/html" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
mc.setPayloadXML(<html><body>{message}</body></html>)
// Not ok: Escapes the message
// if it didn't escape the message, it would result in invalid xml anyway
我还尝试了十几种其他组合,但都没有奏效。
是否可以接收 JSON JMS 消息,对其进行解析并从值发送正确的 html 电子邮件?
解决方案
以下步骤将帮助您实现您的要求
- 一旦 JSON 消息被读入 ESB,它将是 SOAP 格式。因此,使用 xslt 调解器将内容更改为您想要的输出 html
- 将 messageType 和 ContentType 设置为 text/html
在 /repository/conf/axis2/axis2.xml 中启用 text/html 消息格式化程序
发送电子邮件
此博客包含使用上述方法的电子邮件功能示例实现 https://medium.com/@Jenananthan/wso2-esb-sending-email-notification-2150f8dca2aa
推荐阅读
- javascript - PHP 不解码使用 Javascript 创建的 JSON 对象。错误总是返回 4
- git - 将现有代码推送到现有存储库:Bitcucket
- python - Google Drive API:如何从 google drive 下载文件?
- r - R tidytext 如果是相关二元组的一部分,则删除单词,但如果不是则保留
- angular - 如何在事件中更改 ag-grid 中的样式?
- typescript - 为什么在此示例中会出现类型推断错误以及如何做得更好?
- c# - BearerOption.SaveToken 未将令牌保存在服务器中
- r - 在数据表 R 上查找内部值
- security - 在 istio AuthorizationPolicy 中如何匹配包含查询字符串参数的路径
- dns - 我忘记更新我的域,它进入待删除状态。我现在如何恢复域?