WSO2 BPS - 邮寄活动 [英] WSO2 BPS - mailing activity

查看:25
本文介绍了WSO2 BPS - 邮寄活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个在 BPEL 流程的某个点发送邮件的活动.

I need to have an activity that send a mail at a certain point of the BPEL process.

是否存在邮件活动",或者我是否必须编写某种 Web 服务来调用,以便我调用该服务并让它发送邮件?

Is there a "mail activity" or do I have to code a sort of web services to invoke so that I call the service and let it send the mail?

是否可以将 ESB 用于此业务的解决方案?

Could it be a solution to use the ESB for this business?

如何连接两者(再次使用网络服务或有更快捷、最简单的方法来链接它们)?

How to connect the two (again with a web services or there is a quicker and easiest way to link them)?

在这种情况下,将 ESB 功能添加到 BPS 以将其添加为传输功能,而不必为此添加 ESB,是否是一个很好的解决方案?

Could it be a good solution in this case to add the ESB feature to BPS to add it the transport feature without having to add the ESB just for this?

我也看到有一些例子在axis2.xml中使用transportSender而不是使用代理,但似乎这种方法总是将邮件发送到我需要能够发送邮件的相同地址从流程参数到主题(可能的抄送和密送)(在上一步中,我从数据库中读取数据并且有地址信息)tensportSender 是否可以成为要遵循的路径,或者我必须开发邮件服务?

Also I've seen that there are some example around that uses the transportSender in axis2.xml than using a proxy, but it seems that this method send the mail always to the same address I need to be able to send a mail to a subject (an possible cc and bcc) from parameters of the process (on a previous step I read data from DB and there is the address information) could the tensportSender be the path to follow or I have to develop the mailing service?

有什么提示吗?

谢谢

卢卡

推荐答案

如前所述,目前 WSO2 BPEL 没有内置邮件活动,但您可以通过调用外部 Web 服务(DSS、AS) 从 BPEL 工作流内部.

As mentioned before, currently there is no mailing activity built-in for WSO2 BPEL, but you can get this functionality by invoking an external web service(DSS, AS) from inside the BPEL workflow.

几天前我已经创建了一个具有此类功能的工作流程.基本上我创建了 Axis2 服务,它只是用于发送电子邮件的 Java 代码,我可以在其中提供主题、内容和接收者等参数,因此一旦您调用该服务,您就可以将电子邮件发送到任何电子邮件地址.我将提到的 Axis2 服务部署到 WSO2 DSS 中,并从 BPEL 工作流中调用它,然后我将其部署到 WSO2 BPS 中.

I've created one workflow with such functionality couple days ago. Basically I created and Axis2 service that is just Java code for sending email, in which I can provide the parameters such as subject, content and receiver, so once you invoke the service you can send the email to any email address. I deployed the Axis2 service mentioned into a WSO2 DSS and invoke it from BPEL workflow that later on I deployed into WSO2 BPS.

我用于发送电子邮件的 Java 代码如下:

The Java code I used for sendin the email is the following:

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class MailSender {

    public static void main(String emailAddress, String content){

        String host = "smtp.gmail.com";
        String from = "example@gmail.com";
        String subject = "Subject example";



        Properties props = System.getProperties();
        props.put("mail.smtp.host", host);
        props.put("mail.smtp.user", from);
        props.put("mail.smtp.password", "");
        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.auth", "true");

        try{
            Session session = Session.getDefaultInstance(props, null);
            InternetAddress to_address = new InternetAddress(emailAddress);

            MimeMessage message = new MimeMessage(session);         
            message.setFrom(new InternetAddress(from));
            message.addRecipient(Message.RecipientType.TO, to_address);
            message.setSubject(subject);        
            message.setContent(content, "text/html; charset=UTF-8");

            Transport transport = session.getTransport("smtp");
            transport.connect("smtp.gmail.com","example@gmail.com","Password");
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();


            }

            catch (MessagingException mex) {
            System.out.println("send failed, exception: " + mex);
            }
    }
}

这篇关于WSO2 BPS - 邮寄活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆