axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r448852 - in /webservices/axis2/trunk/java/xdocs/1_1: mail-configuration.html mail-transport.html
Date Fri, 22 Sep 2006 07:43:41 GMT
Author: saminda
Date: Fri Sep 22 00:43:40 2006
New Revision: 448852

more improvements to mail-transport related documents 


Modified: webservices/axis2/trunk/java/xdocs/1_1/mail-configuration.html
--- webservices/axis2/trunk/java/xdocs/1_1/mail-configuration.html (original)
+++ webservices/axis2/trunk/java/xdocs/1_1/mail-configuration.html Fri Sep 22 00:43:40 2006
@@ -30,7 +30,7 @@
 <p>The inner workings of the mail transport has been divided into two parts, the transport
-sender for smtp and the transport listener for pop3. The transport listener will listen to
a particular email address periodically. When an email comes in it will be tunneled into the
+sender for smtp and the transport listener for pop3. The transport listener will listen to
a particular email address periodically. When an email comes in it will be tunneled into an
 engine. On the other hand mail transport sender sends emails to a mail server for a particular
email address.</p>
 <p>Mail transport can be used against a generic mail server or it can be used
@@ -47,7 +47,7 @@
 <p>You need to have a mail account to activate the mail functionality. This
 can either be a generic mail server or you can start up a James mail server, which will be
available <a href="">here</a>.</p>
-<p>JavaMail sets its properties to a Properties object. To get this facilities available
from every property can be mapped to a Parameter in Axis2. Mapping has been done as follows,</p>
+<p>JavaMail sets its properties to a Properties object. In Axis2, this has been mapped
to a Parameter object. Mapping has been done as follows,</p>
     <li>Every JavaMail property can be set to @name of the &lt;parameter/&gt;.
Thus, SSL connection is mapped the way it is done in JavaMail</li>
@@ -58,31 +58,94 @@
 <p>For a non-SSL connection, as an example,mail transport sender can be activated by
adding following entry to the axis2.xml file.</p>
 <source><pre>   &lt;transportSender name="mail" class="org.apache.axis2.transport.mail.MailTransportSender"&gt;
-        &lt;parameter name="" locked="false"&gt;smtp server host&lt;/parameter&gt;
-        &lt;parameter name="mail.smtp.user" locked="false"&gt;user name&lt;/parameter&gt;
-        &lt;parameter name="transport.mail.smtp.password" locked="false"&gt;password&lt;/parameter&gt;
+        &lt;parameter name="" locked="false"&gt;localhost&lt;/parameter&gt;
+        &lt;parameter name="mail.smtp.user" locked="false"&gt;mary&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.smtp.password" locked="false"&gt;mary&lt;/parameter&gt;
-</source><a name="receiver"></a>
+<p>In runtime tuning a client to set mail transport as easy as follows,</p>
+Options options =  new Options();
+HttpTransportProperties.MailProperties mailProps 
+                    = new HttpTransportProperties.MailProperties();
+Thus, a user familiar with setting up a SSL connection, he should easily do it with the MailProperties
object. For Ex: tuning the sender to talk to gmail account. This configuration should also
be done with &lt;parameter/&gt; in Axis2.xml.
+HttpTransportProperties.MailProperties props = 
+                  new HttpTransportProperties.MailProperties();
+        props.put("mail.smtp.user", "");
+        props.put("", "");
+        props.put("mail.smtp.port", "465");
+        props.put("mail.smtp.starttls.enable","true");
+        props.put("mail.smtp.auth", "true");
+        //props.put("mail.smtp.debug", "true"); // if the user wants
+        props.put("mail.smtp.socketFactory.port", "465");
+        props.put("mail.smtp.socketFactory.class", "");
+        props.put("mail.smtp.socketFactory.fallback", "false");
+        props.setPassword("password");
+<a name="receiver"></a>
 <h2>Transport Receiver</h2>
 <p>For a non-SSL connection,as an example,mail Listener can be activated by adding
the following entry to the
 axis2.xml file.</p>
 <source><pre>   &lt;transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener"&gt;
-        &lt;parameter name="" locked="false"&gt;pop server host&lt;/parameter&gt;
-        &lt;parameter name="mail.pop3.user" locked="false"&gt;user name&lt;/parameter&gt;
-        &lt;parameter name="transport.mail.pop3.password" locked="false"&gt;password&lt;/parameter&gt;
-        &lt;parameter name="transport.mail.replyToAddress" locked="false"&gt;email
+        &lt;parameter name="" locked="false"&gt;localhost&lt;/parameter&gt;
+        &lt;parameter name="mail.pop3.user" locked="false"&gt;bob&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.pop3.password" locked="false"&gt;bob&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.replyToAddress" locked="false"&gt;bob@localhost&lt;/parameter&gt;
+<p><i>Note:</i> The @name="transport.mail.replyToAddress" is an important
parameter. It supply the Endpoint reference to the listener.</p>
+<p>For an advanced user, this can be set to a SSL connection. As an example, lets use
this transport listener to pop from a specified gmail account.</p>
+&lt;transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener"&gt;
+	&lt;parameter name="" locked="false"&gt;;/parameter&gt;
+	&lt;parameter name="mail.pop3.user" locked="false"&gt;;/parameter&gt;
+	&lt;parameter name="mail.pop3.socketFactory.class" locked="false"&gt;;/parameter&gt;
+	&lt;parameter name="mail.pop3.socketFactory.fallback" locked="false"&gt;false&lt;/parameter&gt;
+	&lt;parameter name="mail.pop3.port" locked="false"&gt;995&lt;/parameter&gt;
+	&lt;parameter name="mail.pop3.socketFactory.port" locked="false"&gt;995&lt;/parameter&gt;
+	&lt;parameter name="transport.mail.pop3.password" locked="false"&gt;password&lt;/parameter&gt;
+	&lt;parameter name="transport.mail.replyToAddress" locked="false"&gt;;/parameter&gt;
 <a name="server"></a>
 <h2>Using Mail Transport in the Server Side</h2>
-<p>If the Mail Listener is need to be started as the server it can be done
+<p>If the Mail Listener is need to be started as a standalone mail listener, it can
be done
 with following command with the all the axis2 jars and the mail dependency
 jars in the classpath.</p>
 <source><pre>java org.apache.axis2.transport.mail.SimpleMailListener repository-directory</pre>
@@ -90,7 +153,7 @@
 <h2>Using Mail Transport in the Client Side</h2>
-<p>Following code segment shows how to send a oneway SOAP message using the
+<p>Following code segment shows how to send a one-way (IN-Only MEP) SOAP message using
 mail transport, this needs the Transport Sender configured.</p>
         OMElement payload = ....

Modified: webservices/axis2/trunk/java/xdocs/1_1/mail-transport.html
--- webservices/axis2/trunk/java/xdocs/1_1/mail-transport.html (original)
+++ webservices/axis2/trunk/java/xdocs/1_1/mail-transport.html Fri Sep 22 00:43:40 2006
@@ -22,7 +22,7 @@
   <li><a href="#intro">Introduction</a></li>
   <li><a href="#axis2">Using Simple Mail Server Included in Axis2</a></li>
   <li><a href="#generic">Using a Generic Mail Server</a></li>
-  <li><a href="#mailet">Calling Axis Through a James Mailet</a></li>
+  <!--li><a href="#mailet">Calling Axis Through a James Mailet</a></li-->
 <a name="prologue"></a>
@@ -38,20 +38,19 @@
 when the store opens there will be a reply to that mail with new instructions
 and updates. It is a lot like the way the old business worked but with a
 modern touch. Similarly Axis2 mail transport can be used to implement
-SETI@HOME through mail.</p>
+asynchronous messaging through mail.</p>
 <a name="intro"></a>
 <p>To start you will first need to go through the <a
 href="mail-configuration.html" target="_blank">Mail Transport
-Configuration</a> document. It will give you all the information you need on
-how to configure Axis2 to get mail transport working.</p>
+Configuration</a> document. It will provide the user with the first hand experience
in setting up the mail transports to co-exists with Axis2.</p>
 <p>Broadly speaking there are 3 ways of calling a service through mail.</p>
-  1. Using the simple mail server included in Axis2.<br>
+  1. Using the simple mail server included in Axis2.(not recommended in production)<br>
   2. Using a generic mail server.<br>
   3. Using mailets.<br>
@@ -62,11 +61,7 @@
 option 3 is somewhat harder.The mailet scenario however does provide a more
 robust and useful solution in a production environment.</p>
-<p>If you are not a guru in mail related issues you should probably get
-started on the simple mail server that has been provided with Axis2. Once you
-get the hang of the Axis2 related issues then you can move on to tackle the
-mail beast. Please do keep in mind that the mail server we have implemented
+<p>It is very easy to start learning the workings of mail transports with the aid of
Simple Mail Server that provides with Axis2. Once you get the hang of the Axis2 related issues
then you can move on to tackle the mail beast. Please do note that the Simple Mail Server
that provides with Axis2 is not graded for production use.</p>
 <a name="axis2"></a>
 <h2>1. Using Simple Mail Server Included in Axis2</h2>
@@ -165,8 +160,8 @@
 <p>This will call the service that was setup on the server and will poll the
-mail server till the response is received.Thats all there is to it. Please do
-note that serviceName and operationName need to be QNames.</p>
+mail server till the response is received.Please do note that serviceName and operationName
need to be QNames.</p>
 <a name="generic"></a>
 <h2>2. Using a Generic Mail Server</h2>
@@ -207,113 +202,11 @@
 <p>Note that a separate ConfigurationContext needs to be created and used.</p>
-<a name="mailet"></a>
-<h3>3. Calling Axis Through a James Mailet</h3>
-<p>This process will be a bit more challenging than the other two methods but
-will provide a really elegant way to use the mail transport. Before we get
-started you will have to go though the James documents <a
-target="_blank">Writing a Custom Matcher</a> and <a
-href="" target="_blank">Writing
-a Custom Mailet</a>.</p>
-<p>Now that we know the James part of it lets dive into to the Axis2 part of
-the code. Once you have set up the James side of business we need to use the
-same functionality that is used in the above code. Have a look at the code
-listing below for more details</p>
-<source><pre>    public void processMail(ConfigurationContext confContext, MimeMessage
mimeMessage) {
-        // create an Axis server
-        AxisEngine engine = new AxisEngine(confContext);
-        MessageContext msgContext = null;
-        // create and initialize a message context
-        try {
-            msgContext = new MessageContext();
-            msgContext.setConfigurationContext(confContext);
-            msgContext.setTransportIn(confContext.getAxisConfiguration().getTransportIn(new
-            msgContext.setTransportOut(confContext.getAxisConfiguration().getTransportOut(new
-            msgContext.setServerSide(true);
-            msgContext.setProperty(MailSrvConstants.CONTENT_TYPE, mimeMessage.getContentType());
-            msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING,
-                    mimeMessage.getEncoding());
-            String soapAction = getMailHeader(MailSrvConstants.HEADER_SOAP_ACTION, mimeMessage);
-            if (soapAction == null){
-            	soapAction = mimeMessage.getSubject();
-            }
-            msgContext.setSoapAction(soapAction);
-            msgContext.setIncomingTransportName(Constants.TRANSPORT_MAIL);
-            String serviceURL = mimeMessage.getSubject();
-            if (serviceURL == null) {
-                serviceURL = "";
-            }
-            String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
-            if (replyTo != null) {
-                msgContext.setReplyTo(new EndpointReference(replyTo));
-            }
-            String recepainets = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
-            if (recepainets != null) {
-                msgContext.setTo(new EndpointReference(recepainets + "/" + serviceURL));
-            }
-            // add the SOAPEnvelope
-            String message = mimeMessage.getContent().toString();
+<!--a name="mailet"></a>
-  "message[" + message + "]");
-            ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());
-            XMLStreamReader reader =
-                    StAXUtils.createXMLStreamReader(bais);
-            String soapNamespaceURI = "";
-            if (mimeMessage.getContentType().indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
> -1) {
-                soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            } else if (mimeMessage.getContentType().indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)
-                    > -1) {
-                soapNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            }
+<h3>3. Calling Axis2 Through a Mailet</h3-->
-            StAXBuilder builder = new StAXSOAPModelBuilder(reader, soapNamespaceURI);
-            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
-            msgContext.setEnvelope(envelope);
-            if (envelope.getBody().hasFault()) {
-                engine.receiveFault(msgContext);
-            } else {
-                engine.receive(msgContext);
-            }
-        } catch (Exception e) {
-            try {
-                if (msgContext != null) {
-                    MessageContext faultContext = engine.createFaultMessageContext(msgContext,
-                    engine.sendFault(faultContext);
-                }
-            } catch (Exception e1) {
-                log.error(e);
-            }
-        }
-    }</pre>
-<p>If you don't happen to have a ConfigurationContext lying around to call
-this method you can use the following bit of code to get one. Once you create
-one you can store that on the mailet and keep using it.</p>
-<source><pre>            File file = new File(MAIL_TRANSPORT_SERVER_ENABLED_REPO_PATH);
-                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(
-                    	file.getAbsolutePath(), file.getAbsolutePath() + "/conf/axis2.xml");

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message