是否可以使用WSO2ESB使用标头发送电子邮件

时间:2013-07-03 07:13:36

标签: wso2 wso2esb wso2carbon wso2dss

我希望使用Header mediator向我的客户发送电子邮件。 是否有可能 像我这样的代理

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="Mail"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <log/>
         <property name="workpartybranchid"
                   expression="//workpartybranchid/text()"
                   scope="default"
                   type="STRING"/>
         <payloadFactory>
            <format>
               <p:SelectMail_Op xmlns:p="http://ws.wso2.org/dataservice">
                  <p:workpartybranchid>$1</p:workpartybranchid>
               </p:SelectMail_Op>
            </format>
            <args>
               <arg expression="get-property('workpartybranchid')"/>
            </args>
         </payloadFactory>
         <send receive="Mailseq">
            <endpoint>
               <address uri="http://192.168.1.4:9773/services/muser_DataService/"
                        format="soap11"/>
            </endpoint>
         </send>
      </inSequence>
   </target>
</proxy

和相应的序列是

<sequence xmlns="http://ws.apache.org/ns/synapse" name="Mailseq" onError="fault">
   <property name="CONTENT_TYPE"
             value="application/json"
             scope="axis2"
             type="STRING"/>
   <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
 <property xmlns:ns="http://org.apache.synapse/xsd"
             xmlns:s="http://ws.wso2.org/dataservice"
             name="primarymail"
             expression="//s:primarymail/text()"
             scope="axis2"
             type="STRING"/>
<log>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             xmlns:s="http://ws.wso2.org/dataservice"
             name="primarymail"
             expression="//s:primarymail/text()"
             scope="axis2"
             type="STRING"/>
   </log>

<header name="To" expression="fn:concat('mailto:', get-property('primarymail'))"/>
<send/>
<log>
<property name="mail" value="ts working"/></log>
</sequence>

我们可以发送这样的电子邮件吗?我从中得到了参考 http://docs.wso2.org/wiki/display/ESB460/Sample+256%3A+Proxy+Services+with+the+Mail+Transport 我以另一种方式发布我的要求也请参考这个 Can we send Multiple Mail in wso2esb in same sequence or dynamically set a mail

1 个答案:

答案 0 :(得分:0)

只需按照以下网址中的步骤操作(但不要使用标题部分,请使用端点,如下所示..这对我有用)

http://docs.wso2.org/wiki/display/ESB460/Sample+256%3A+Proxy+Services+with+the+Mail+Transport

为邮件添加发送,如下所示...(不需要标头中介)

 <send> <endpoint>
<address uri="mailto:yourmailaddr@gmail.com" />
</endpoint>
</send>