| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ Licensed to the Apache Software Foundation (ASF) under one |
| ~ or more contributor license agreements. See the NOTICE file |
| ~ distributed with this work for additional information |
| ~ regarding copyright ownership. The ASF licenses this file |
| ~ to you under the Apache License, Version 2.0 (the |
| ~ "License"); you may not use this file except in compliance |
| ~ with the License. You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, |
| ~ software distributed under the License is distributed on an |
| ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~ KIND, either express or implied. See the License for the |
| ~ specific language governing permissions and limitations |
| ~ under the License. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 256</title> |
| </properties> |
| <body> |
| <section name="Sample 256: Proxy Services with the Mail Transport"> |
| <div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <proxy name="StockQuoteProxy" transports="mailto"> |
| |
| <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"/> |
| <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/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| |
| <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> |
| |
| </proxy> |
| |
| </definitions></div> |
| <subsection name="Objective"> |
| <p> |
| This sample show cases the mail transport of Synapse. The mail transport allows |
| Synapse to receive and send e-mails using common protocols like POP, IMAP and |
| SMTP. |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| You need access to an e-mail account to try out this sample |
| </li> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 |
| </li> |
| <li> |
| Enable the mail transport listener and mail transport sender for Synapse |
| (refer <a href="setup/mail.html#mailTransportSender">Mail transport setup</a> |
| guide for more details) |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 256 (repository/conf/sample/synapse_sample_256.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 256<br/> |
| Windows: synapse.bat -sample 256 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| Send an e-mail to <a href="mailto:synapse.demo.1@gmail.com">synapse.demo.1@gmail.com</a> |
| with the following payload. |
| </p> |
| <div class="xmlConf"><getQuote xmlns="http://services.samples"> |
| <request xmlns="http://services.samples/xsd"> |
| <symbol>IBM</symbol> |
| </request> |
| </getQuote></div> |
| <p> |
| Synapse will be polling on the above e-mail account for any incoming requests. When |
| your mail arrives at this account, Synapse will pick it up and send the payload to |
| Axis2 over HTTP. The response will be mailed back to your e-mail account. Synapse |
| retrieves the sender information from the original request to determine the recipient |
| of the response mail. |
| </p> |
| <p> |
| Note that in this sample we used the transport.mail.ContentType property to make |
| sure that the transport parses the request message as POX. If you remove this |
| property, you may still be able to send requests using a standard mail client if |
| instead of writing the XML in the body of the message, you add it as an attachment. |
| In that case, you should use .xml as a suffix for the attachment and format the |
| request as a SOAP 1.1 message. Indeed, for a file with suffix .xml the mail client |
| will most likely use text/xml as the content type, exactly as required for SOAP 1.1. |
| Sending a POX message using this approach will be a lot trickier, because most |
| standard mail clients don't allow the user to explicitly set the content type. |
| </p> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |