If you need Follow the instructions below to convert the a SOAP message to a plain text mail (without any XML in it), follow the instructions below.
1) Download a distribution of the WSO2 ESB. For example, wso2esb-2.1.1.zip
.
2) Extract the zip file. The folder created will be referred as ESB_HOME
. For example, wso2esb-2.1.1
.
3) Uncomment the mail TransportSender
and {TransportReceiver}} from axis2.xml. For example, ESB_HOME/conf/axis2.xml
.
...
. Download and set up WSO2 ESB using instructions given in section Getting Started. We refer to the distribution home as ESB_HOME
.
2. Uncomment the mail TransportSender
and TransportReceiver
from ESB_HOME/repository/conf/axis2/axis2.xml
file.
Code Block |
---|
<transportSender name="mailto"> <parameter name="mail.smtp.host">smtp.gmail.com</parameter> <parameter name="mail.smtp.port">587</parameter> <parameter name="mail.smtp.starttls.enable">true</parameter> <parameter name="mail.smtp.auth">true</parameter> <parameter name="mail.smtp.user">synapse.demo.0</parameter> <parameter name="mail.smtp.password">mailpassword</parameter> <parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter> </transportSender> <transportReceiver name="mailto"> </transportReceiver> |
43) Add the following line to axis2.xml files's MessageFormatters
.
Code Block |
---|
<messageFormatter contentType="text/plain"/>
|
54) Build the SimpleStockQuote
service (which is residing inside the samplesand run the sample Axis2 Server (ESB_HOME\samples\axis2Server>axis2server.bat
). For exampleinstructions, ESB_HOME/samples/axis2Server/src/SimpleStockQuoteService
.
6) Run sample axis2Server
.
7) Go to the go to ESB Samples Setup and then select the sub heading Starting Sample Back-End Services.
5) Start the ESB server by running,
ESB_HOME/bin
...
/
wso2server.
...
bat
for windows
...
for linuxESB_HOME/bin/
wso2server.sh
...
86) Then the server will be started. You can access the management console using the following URL Go to the ESB management console UI (https://<host>localhost:<port>9443/carbon/
.
9) Log into the Management Console using following credentials.
username: admin
password: admin
10) and log in to it using credentials admins/admin.
7) Create a Proxy Service using the following Proxy configuration. See how to create For instructions on creating proxy services, refer to Adding a Proxy Service here.
Code Block |
---|
<!-- Using the mail transport -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="StockQuoteProxy" transports="mailto">
<parameter name="transport.mail.Address">synapse.demo.1@gmail.com</parameter>
<parameter name="transport.mail.Protocol">pop3</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="mail.pop3.host">pop.gmail.com</parameter>
<parameter name="mail.pop3.port">995</parameter>
<parameter name="mail.pop3.user">synapse.demo.1</parameter>
<parameter name="mail.pop3.password">mailpassword</parameter>
<parameter name="mail.pop3.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="mail.pop3.socketFactory.fallback">false</parameter>
<parameter name="mail.pop3.socketFactory.port">995</parameter>
<parameter name="transport.mail.ContentType">application/xml</parameter>
<target>
<inSequence>
<property name="senderAddress" expression="get-property('transport', 'From')"/>
<log level="full">
<property name="Sender Address" expression="get-property('senderAddress')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="Subject" value="Custom Subject for Response" scope="transport"/>
<property name="messageType" value="text/plain" scope="axis2-client"/>
<script language="js"><![CDATA[
mc.setPayloadXML(<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">Plain text received!</ns:text>);
]]></script>
<header name="To" expression="fn:concat('mailto:', get-property('senderAddress'))"/>
<log level="full">
<property name="message" value="Response message"/>
<property name="Sender Address" expression="get-property('senderAddress')"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
</definitions>
|
118) Send an email to synapse.demo.1@gmail.com
.
12) You will 9) Verify that you receive the response in plain text.
See the source article here.
Excerpt
hidden | true |
---|