-->

Can we Set a Send mediator with Xpath expression

2019-08-13 15:26发布

问题:

i am trying to send a message to my email for that i am using send mediator as well i setup required configurations in AXIS2 file

is it work for below proxy if not what is the way to give xpath to send mediator

<proxy xmlns="http://ws.apache.org/ns/synapse" name="mailCheck" transports="http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="Subject" value="Alert Message From WSO2 ESB - Service Down !!!" scope="transport" type="STRING"/>
         <property name="messageType" value="text/html" scope="axis2" type="STRING"/>
         <property name="ContentType" value="text/html" scope="axis2" type="STRING"/>
         <property name="Mail" value="mailto:faisal.shaik@youtility.in" scope="default" type="STRING"/>
         <log level="full">
            <property name="Mail" value="mailto:faisal.shaik@youtility.in"/>
         </log>
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
         <send>
            <endpoint key-expression="get-property('Mail')"/>
         </send>
      </inSequence>
      <outSequence/>
   </target>
   <description></description>
</proxy>

if need any changes pls let me know

回答1:

if you want to get the email address from a property value then use the header mediator to set value of "To" to "mailto:faisal.shaik@youtility.in".

You can do that adding the following before the send mediator

<header name="To" expression="fn:concat('mailto:', get-property('Mail'))"/>


回答2:

You can use this:

<property name="To" expression="get-property('uri.var.to')" scope="transport"/>
<send>
    <endpoint>
        <address uri="mailto:"/>
     </endpoint>
</send>


回答3:

   <send>
             <address uri="mailto:xxx@yyy"/>
         </send>

key-expression also can be used..