axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saminda Abeyruwan" <samin...@gmail.com>
Subject Improvements to Mail Transport
Date Tue, 03 Apr 2007 14:49:37 GMT
Hi Devs,

We've made changes and improvements to Mail Transport available in Axis2.
All these changes are visible in  the current Axis2 1.2 branch.

We change the client side Mail sender configuration as follows.

In client side axis2.xml following entry should be present to initialize
mail transport sender.

<transportSender name="mailto" class="
org.apache.axis2.transport.mail.MailTransportSender"/>

That's the only entry needed.

Mail transport sender uses Java Mail API. This API uses
java.util.Propertiesobject to set properties. Thus, in your client
code you should initialize a
Properties object and put the relevant properties. This properties object
should be set in Option object with the key
org.apache.axis2.transport.mail.Constants.MAIL_SMTP. Ex:

====================
...
            ConfigurationContext cc = ...;
            ServiceClient client = new ServiceClient(cc, null);
            Options options = new Options();
            options.setTo(new EndpointReference("mailto:saminda@foo.org
?X-Service-Path=/axis2/services/Foo"));
            Properties p = new Properties();
            p.setProperty("mail.smtp.from","client@bar.org");
            p.setProperty("mail.smtp.host","bar.org");

            options.setProperty(
org.apache.axis2.transport.mail.Constants.MAIL_SMTP,p);

            options.setSoapVersionURI(
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
            client.setOptions(options);
            client.sendRobust(ele);
...
====================

Mail transport listener configuration is as usual.

With the popular request,  mail transport supports request/response (similar
to HTTP request/response).  The implementation of this uses mail headers
"From" and "In-Reply-To".

In client side one has to set the following property to get this behavior,
*options.setProperty(org.apache.axis2.transport.mail.Constants.MAIL_SYNC,
Boolean.TRUE);*

It has to be noted that user MUST set the "mail.smtp.from" property to get
this working IF addressing is not used. Even this scenario, a
SimpleMailListener started internally and run it will run in the main
thread. Thus, until proper message receives, it will block the execution of
client. Listener will be timeout, if it is not received a message. This
timeout period is configurable and it uses options.setTimeOutInMilliSeconds().


Configuration of this listener can be done in client axis2.xml or at run
time via properties object. Ex:

<transportReceiver name="mailto" class="
org.apache.axis2.transport.mail.SimpleMailListener" />

==================
...
       Properties pp = new Properties();
        pp.setProperty("mail.pop3.host","localhost");
        pp.setProperty("mail.pop3.user","blue");
        pp.setProperty("transport.mail.pop3.password","blue");
        pp.setProperty("mail.store.protocol","pop3");
        pp.setProperty("transport.mail.replyToAddress","blue@localhost");
        pp.setProperty("transport.listener.interval","3000");
        options.setProperty(
org.apache.axis2.transport.mail.Constants.MAIL_POP3,pp);

...
==================

Thus, setting the properties object with
rg.apache.axis2.transport.mail.Constants.MAIL_POP3 key, will configure the
listener.

In addition to this I've deprecated
org.apache.axis2.transport.http.HttpTransportProperties.MailProperties and
users are encourage  the use of Properties object instead.

Thank you

Saminda




-- 
Saminda Abeyruwan

Software Engineer
WSO2 Inc. - www.wso2.org

Mime
View raw message