作为整个项目的一部分,我需要创建一个Message-Broker应用程序,它接受XML格式的数据并生成电子邮件。
我创建了一个消息流,如下所示
“MQ输入 - 计算 - emailoutput”
请帮助我在xml文件中写什么来生成上述流程。
esql文件包含以下代码: 创建功能Main()RETURNS BOOLEAN 开始 CALL CopyMessageHeaders();
-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Cc = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Bcc = '<recipient email address>';
-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = '<sender email address>';
SET OutputRoot.EmailOutputHeader."Reply-To" = '<reply email address>';
-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = 'Replaced by ESQL compute node.';
-- Add SMTP server information to the LocalEnvironment
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- Create a new message body, which will be sent as the main text of the email.
SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);
RETURN TRUE;
END;
答案 0 :(得分:0)
我完全不知道您正在谈论的xml文件。 通过添加和连接您指定的三个节点,在消息代理工具箱中布置msg流。然后将您的代码添加到计算节点。
答案 1 :(得分:0)
您可以使用XPATH,使用InputRoot.XMLNC,使用Environment或LocalEnvironment传递值。 如果我们满足您的要求, 看起来消息来自您正在使用XMLNSC Parser的MQInput节点。
-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = InputRoot.XMLNSC.EmailData.To;
-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = InputRoot.XMLNSC.EmailData.From;
-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = InputRoot.XMLNSC.EmailData.Subject;
-- Add SMTP server information to the LocalEnvironment
-- You can Add Smtp Server From Configuration in Your Broker Administration side as Configurable Service
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- Create a new message body, which will be sent as the main text of the email.
SET OutputRoot.BLOB.BLOB = CAST(InputRoot.EmailData.Body AS BLOB CCSID 1208);
对于测试,在测试客户端中键入此XML文件
<EmailData>
<To>recieverEmail@example.com</To>
<From>fooSenderEmail@example.com</From>
<Subject>Testing Email App</Subject>
<Body><![CDATA[<h1>Testing Email Data</h1><br/><hr /><br/><h6>Testing Email</h6></hr />]]></Body>
</EmailData>