You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by he...@apache.org on 2005/06/02 14:39:06 UTC

svn commit: r179585 - in /webservices/axis/trunk/java: ./ modules/core/ modules/core/src/org/apache/axis/clientapi/ modules/core/src/org/apache/axis/deployment/ modules/core/src/org/apache/axis/transport/ modules/core/src/org/apache/axis/transport/mail/ modules/samples/ modules/samples/test/org/apache/axis/engine/ modules/samples/test/org/apache/axis/integration/ modules/wsdl/

Author: hemapani
Date: Thu Jun  2 05:39:05 2005
New Revision: 179585

URL: http://svn.apache.org/viewcvs?rev=179585&view=rev
Log:
fixing the smtp transport

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/EmailReceiver.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/EMailSender.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/OneWayRawXMLTest.java
Modified:
    webservices/axis/trunk/java/maven.xml
    webservices/axis/trunk/java/modules/core/project.xml
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MessageSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/client.xml
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/server.xml
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailWorker.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java
    webservices/axis/trunk/java/modules/samples/project.xml
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/MailEchoRawXMLTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
    webservices/axis/trunk/java/modules/wsdl/project.xml

Modified: webservices/axis/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/maven.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/maven.xml (original)
+++ webservices/axis/trunk/java/maven.xml Thu Jun  2 05:39:05 2005
@@ -93,7 +93,7 @@
 	    <ant:include name="log4j/jars/log4j-1.2.8.jar"/>
 	    <ant:include name="stax/jars/stax-1.1.1-dev.jar"/>
 	    <ant:include name="commons-fileupload/jars/commons-fileupload-1.0.jar"/>
-            <ant:include name="axis/jars/axis-wsdl4j-1.2-RC3.jar"/>
+            <ant:include name="axis/jars/axis-wsdl4j-1.2.jar"/>
 	</ant:fileset> 
 	</ant:copy> 
     </goal>		

Modified: webservices/axis/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/project.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/project.xml (original)
+++ webservices/axis/trunk/java/modules/core/project.xml Thu Jun  2 05:39:05 2005
@@ -109,7 +109,7 @@
         <dependency>
             <groupId>axis</groupId>
             <artifactId>axis-wsdl4j</artifactId>
-            <version>1.2-RC3</version>
+            <version>1.2</version>
             <properties>
                 <module>true</module>
             </properties>

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java Thu Jun  2 05:39:05 2005
@@ -19,6 +19,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.axis.Constants;
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.addressing.MessageInformationHeadersCollection;
 import org.apache.axis.addressing.miheaders.RelatesTo;
@@ -41,6 +42,7 @@
     
     public InOnlyMEPClient(ServiceContext service) {
         super(service,WSDLConstants.MEP_URI_IN_ONLY);
+        messageInformationHeaders = new MessageInformationHeadersCollection();
     }
 
     public void send(OperationDescription axisop, final MessageContext msgctx) throws AxisFault {
@@ -75,12 +77,14 @@
         response.setOperationContext(msgctx.getOperationContext());
         response.setServiceContext(msgctx.getServiceContext());
 
-        //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
-        HTTPTransportReceiver receiver = new HTTPTransportReceiver();
-        receiver.checkForMessage(response, sysContext);
-        SOAPEnvelope resenvelope = response.getEnvelope();
-        if (response!= null && resenvelope.getBody().hasFault()) {
-            throw new AxisFault(resenvelope.getBody().getFault().getException());
+        if(Constants.TRANSPORT_HTTP.equals(senderTransport.getName().getLocalPart())){
+            //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
+            HTTPTransportReceiver receiver = new HTTPTransportReceiver();
+            receiver.checkForMessage(response, sysContext);
+            SOAPEnvelope resenvelope = response.getEnvelope();
+            if (response!= null && resenvelope.getBody().hasFault()) {
+                throw new AxisFault(resenvelope.getBody().getFault().getException());
+            }
         }
     }
 
@@ -137,6 +141,7 @@
         serviceContext.getEngineContext().getAxisConfiguration().engageModule(name);
     }
     
- 
-
-}
+    public void setSenderTransport(String senderTransport) throws AxisFault{
+        this.senderTransport = serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(new QName(senderTransport));
+    }
+ }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MessageSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MessageSender.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MessageSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/MessageSender.java Thu Jun  2 05:39:05 2005
@@ -19,8 +19,11 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.ConfigurationContextFactory;
 import org.apache.axis.context.ServiceContext;
 import org.apache.axis.description.OperationDescription;
+import org.apache.axis.description.ServiceDescription;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.om.OMElement;
 
@@ -34,9 +37,30 @@
     public MessageSender(ServiceContext service) {
         super(service);
     }
+
+    public MessageSender() throws AxisFault {
+        super(assumeServiceContext());
+    }
     public void send(String opName, OMElement toSend) throws AxisFault {
         OperationDescription axisOp = new OperationDescription(new QName(opName));
         serviceContext.getServiceConfig().addOperation(axisOp);
-        super.send(axisOp,prepareTheSystem(toSend));
+        super.send(axisOp, prepareTheSystem(toSend));
+    }
+
+    private static ServiceContext assumeServiceContext() throws AxisFault {
+        ConfigurationContext sysContext = null;
+        if (ListenerManager.configurationContext == null) {
+            ConfigurationContextFactory efac = new ConfigurationContextFactory();
+            sysContext = efac.buildClientEngineContext(null);
+        } else {
+            sysContext = ListenerManager.configurationContext;
+        }
+
+        //create new service
+        QName assumedServiceName = new QName("AnonnoymousService");
+        ServiceDescription axisService = new ServiceDescription(assumedServiceName);
+        sysContext.getAxisConfiguration().addService(axisService);
+        ServiceContext service = sysContext.createServiceContext(assumedServiceName);
+        return service;
     }
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/client.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/client.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/client.xml (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/client.xml Thu Jun  2 05:39:05 2005
@@ -20,6 +20,7 @@
     </transportReceiver>
     <transportSender name="tcp" class="org.apache.axis.transport.tcp.TCPTransportSender"/>
 
+<!--
     <transportReceiver name="mail" class="org.apache.axis.transport.mail.SimpleMailListener">
         <parameter name="transport.mail.pop3.host" locked="xsd:false">mail.itambalama.com</parameter>
         <parameter name="transport.mail.pop3.user" locked="xsd:false">axis2.mail.test@itambalama.com</parameter>
@@ -35,6 +36,20 @@
     </transportSender>
 
 
+<transportReceiver name="mail" class="org.apache.axis.transport.mail.SimpleMailListener">
+        <parameter name="transport.mail.pop3.host" locked="xsd:false">127.0.0.1</parameter>
+        <parameter name="transport.mail.pop3.user" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.pop3.password" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.pop3.port" locked="xsd:false">110</parameter>
+        <parameter name="transport.mail.replyToAddress" locked="xsd:false">axis2@127.0.0.1</parameter>
+    </transportReceiver>
+    <transportSender name="mail" class="org.apache.axis.transport.mail.MailTransportSender">
+        <parameter name="transport.mail.smtp.host" locked="xsd:false">127.0.0.1</parameter>
+        <parameter name="transport.mail.smtp.user" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.smtp.password" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.smtp.port" locked="xsd:false">25</parameter>
+    </transportSender>  
+-->
 
 </client>
 

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/server.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/server.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/server.xml (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/deployment/server.xml Thu Jun  2 05:39:05 2005
@@ -21,7 +21,7 @@
     </transportReceiver>
 
     <transportSender name="tcp" class="org.apache.axis.transport.tcp.TCPTransportSender"/>
-
+<!--
     <transportReceiver name="mail" class="org.apache.axis.transport.mail.SimpleMailListener">
         <parameter name="transport.mail.pop3.host" locked="xsd:false">mail.itambalama.com</parameter>
         <parameter name="transport.mail.pop3.user" locked="xsd:false">axis2.mail.test@itambalama.com</parameter>
@@ -35,6 +35,24 @@
         <parameter name="transport.mail.smtp.password" locked="xsd:false">2sixa.mail</parameter>
         <parameter name="transport.mail.smtp.port" locked="xsd:false">25</parameter>
     </transportSender>
+    
+    
+  <transportReceiver name="mail" class="org.apache.axis.transport.mail.SimpleMailListener">
+        <parameter name="transport.mail.pop3.host" locked="xsd:false">127.0.0.1</parameter>
+        <parameter name="transport.mail.pop3.user" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.pop3.password" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.pop3.port" locked="xsd:false">110</parameter>
+        <parameter name="transport.mail.replyToAddress" locked="xsd:false">axis2@127.0.0.1</parameter>
+    </transportReceiver>
+    <transportSender name="mail" class="org.apache.axis.transport.mail.MailTransportSender">
+        <parameter name="transport.mail.smtp.host" locked="xsd:false">127.0.0.1</parameter>
+        <parameter name="transport.mail.smtp.user" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.smtp.password" locked="xsd:false">axis2</parameter>
+        <parameter name="transport.mail.smtp.port" locked="xsd:false">25</parameter>
+    </transportSender>  
+    
+    -->
+    
 
     <!--   <module ref="addressing"/> -->
     <phaseOrder type="inflow">

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/EmailReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/EmailReceiver.java?rev=179585&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/EmailReceiver.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/EmailReceiver.java Thu Jun  2 05:39:05 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ *  Runtime state of the engine
+ */
+package org.apache.axis.transport;
+
+import java.util.Properties;
+
+import javax.mail.Authenticator;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.NoSuchProviderException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Store;
+
+import org.apache.axis.engine.AxisFault;
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class EmailReceiver {
+
+    private String user;
+    private String host;
+    private String popPort;
+    private String password;
+    private Store store;
+    private Folder inbox;
+
+    public EmailReceiver(String user, String host, String popPort, String password) {
+        this.user = user;
+        this.host = host;
+        this.popPort = popPort;
+        this.password = password;
+    }
+    
+    
+    public void connect() throws AxisFault{
+        try {
+            final PasswordAuthentication authentication =
+                new PasswordAuthentication(user, password);
+            Properties props = new Properties();
+            props.put("mail.user", user);
+            props.put("mail.host", host);
+            props.put("mail.store.protocol", "pop3");
+            props.put("mail.transport.protocol", "smtp");
+            props.put("mail.pop3.port", popPort);
+            Session session = Session.getInstance(props, new Authenticator() {
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return authentication;
+                }
+            });
+
+            store = session.getStore();
+            store.connect();
+            Folder root = store.getDefaultFolder();
+            inbox = root.getFolder("inbox");
+
+
+        } catch (NoSuchProviderException e) {
+            throw new AxisFault(e);
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
+        }
+    
+    }
+    
+    public void disconnect() throws AxisFault{
+        try {
+            inbox.close(true);
+            store.close();
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
+        }
+    }
+    
+
+    public Message[] receive() throws AxisFault {
+        try{
+            inbox.open(Folder.READ_WRITE);
+            Message[] msgs = inbox.getMessages();
+
+            int numMessages = msgs.length;
+            if (msgs.length == 0) {
+                return null;
+            } else {
+                return msgs;
+            }
+
+        } catch (NoSuchProviderException e) {
+            throw new AxisFault(e);
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
+        }
+    }
+
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/EMailSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/EMailSender.java?rev=179585&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/EMailSender.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/EMailSender.java Thu Jun  2 05:39:05 2005
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ *  Runtime state of the engine
+ */
+package org.apache.axis.transport.mail;
+
+import java.io.InputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.Properties;
+
+import javax.mail.Authenticator;
+import javax.mail.Flags;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.transport.EmailReceiver;
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class EMailSender {
+    private String user;
+    private String host;
+    private String smtpPort;
+    private String password;
+
+    public EMailSender(String user, String host, String smtpPort, String password) {
+        this.user = user;
+        this.host = host;
+        this.smtpPort = smtpPort;
+        this.password = password;
+    }
+
+    public void send(String subject, String targetEmail, String message) throws AxisFault {
+        try {
+            final PasswordAuthentication authentication =
+                new PasswordAuthentication(user, password);
+            Properties props = new Properties();
+            props.put("mail.user", user);
+            props.put("mail.host", host);
+            props.put("mail.store.protocol", "pop3");
+            props.put("mail.transport.protocol", "smtp");
+            props.put("mail.smtp.port", smtpPort);
+            Session session = Session.getInstance(props, new Authenticator() {
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return authentication;
+                }
+            });
+
+            MimeMessage msg = new MimeMessage(session);
+
+            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(targetEmail));
+            msg.setSubject(subject);
+            msg.setText(message);
+            Transport.send(msg);
+        } catch (AddressException e) {
+            throw new AxisFault(e);
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        String user = "hemapani";
+        String host = "127.0.0.1";
+        String smtpPort = "25";
+        String password = "hemapani";
+        EMailSender sender = new EMailSender(user, host, smtpPort, password);
+
+        sender.send("Testing mail sending", "hemapani@127.0.0.1", "Hellp, testing");
+
+        EmailReceiver receiver = new EmailReceiver(user, host, "110", password);
+        receiver.connect();
+        Message[] msgs = receiver.receive();
+        if (msgs != null) {
+            for (int i = 0; i < msgs.length; i++) {
+                MimeMessage msg = (MimeMessage) msgs[i];
+                if (msg != null) {
+                    System.out.println(msg.getSender());
+                    System.out.println(msg.getContent());
+                }
+                msg.setFlag(Flags.Flag.DELETED, true);
+            }
+
+        }
+        receiver.disconnect();
+
+    }
+}

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailTransportSender.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailTransportSender.java Thu Jun  2 05:39:05 2005
@@ -21,16 +21,6 @@
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.io.Writer;
-import java.util.Properties;
-
-import javax.mail.Authenticator;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.PasswordAuthentication;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
 
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.context.MessageContext;
@@ -53,59 +43,56 @@
 
     public void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)
         throws AxisFault {
+            try {
+                TransportOutDescription transportOut = msgContext.getTransportOut();
+                user = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_USER));
+                host = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_HOST));
+                password =
+                    Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PASSWORD));
+                smtpPort = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PORT));
+                if (user != null && host != null && password != null && smtpPort != null) {
+                    EMailSender sender = new EMailSender(user, host, smtpPort, password);
 
-    }
-
-    public void startSendWithToAddress(MessageContext msgContext, Writer writer) throws AxisFault {
-        try {
-            TransportOutDescription transportOut = msgContext.getTransportOut();
-            user = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_USER));
-            host = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_HOST));
-            password =
-                Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PASSWORD));
-            smtpPort = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PORT));
-            if (user != null && host != null && password != null && smtpPort != null) {
-                final PasswordAuthentication authentication =
-                    new PasswordAuthentication(user, password);
-                Properties props = new Properties();
-                props.put("mail.user", user);
-                props.put("mail.host", host);
-                props.put("mail.store.protocol", "pop3");
-                props.put("mail.transport.protocol", "smtp");
-                props.put("mail.smtp.port", smtpPort);
-                Session session = Session.getInstance(props, new Authenticator() {
-                    protected PasswordAuthentication getPasswordAuthentication() {
-                        return authentication;
+                    //TODO this is just a temporary hack, fix this to use input streams
+                    
+                
+                    byte[] message = new byte[in.available()];
+                    in.read(message);
+                
+                    String eprAddress = msgContext.getTo().getAddress();
+                    int index = eprAddress.indexOf('/');
+                    String subject = "";
+                    String email = null;
+                    if(index > 0){
+                        subject = eprAddress.substring(index+1);
+                        email = eprAddress.substring(0,index);
                     }
-                });
-
-                MimeMessage msg = new MimeMessage(session, in);
-                String action = msgContext.getWSAAction();
-                if (action != null) {
-                    msg.setHeader("transport.mail.soapaction", action);
-                }
                 
-                msg.addRecipient(Message.RecipientType.TO,  new InternetAddress(msgContext.getTo().getAddress()));
-                msg.setSubject(msgContext.getTo().getAddress());
-                Transport.send(msg);
-
-            } else {
-                throw new AxisFault(
-                    "user, port, host or password not set, "
-                        + "   [user null = "
-                        + (user == null)
-                        + ", password null= "
-                        + (password == null)
-                        + ", host null "
-                        + (host == null)
-                        + ",port null "
-                        + (smtpPort == null));
+                    System.out.println(subject);
+                    System.out.println(email);
+
+                    sender.send(subject, email, new String(message));
+                } else {
+                    throw new AxisFault(
+                        "user, port, host or password not set, "
+                            + "   [user null = "
+                            + (user == null)
+                            + ", password null= "
+                            + (password == null)
+                            + ", host null "
+                            + (host == null)
+                            + ",port null "
+                            + (smtpPort == null));
 
+                }
+            } catch (IOException e) {
+                throw new AxisFault(e);
             }
-        } catch (MessagingException e) {
-            throw new AxisFault(e);
-        }
 
+
+    }
+
+    public void startSendWithToAddress(MessageContext msgContext, Writer writer) throws AxisFault {
     }
 
     protected Writer openTheConnection(EndpointReference epr) throws AxisFault {

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailWorker.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailWorker.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailWorker.java Thu Jun  2 05:39:05 2005
@@ -84,9 +84,9 @@
             msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType());
             msgContext.setWSAAction(getMailHeader(MailConstants.HEADER_SOAP_ACTION));
 
-            String to = mimeMessage.getSubject();
-            if (to != null) {
-                msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, to));
+            String serviceURL = mimeMessage.getSubject();
+            if (serviceURL == null) {
+                serviceURL = "";
             }
 
             String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
@@ -94,15 +94,21 @@
                 msgContext.setReplyTo(
                     new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
             }
+            
+             
 
-            String sendFrom = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
-            if (sendFrom != null) {
-                msgContext.setFrom(new EndpointReference(AddressingConstants.WSA_FROM, sendFrom));
+            String recepainets = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
+            
+            
+            if (recepainets != null) {
+                msgContext.setTo(new EndpointReference(AddressingConstants.WSA_FROM, recepainets+ "/"+serviceURL));
             }
 
             // add the SOAPEnvelope
+            String message = mimeMessage.getContent().toString();
+            System.out.println("message["+message+"]");
             ByteArrayInputStream bais =
-                new ByteArrayInputStream(mimeMessage.getContent().toString().getBytes());
+                new ByteArrayInputStream(message.getBytes());
             XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
             StAXBuilder builder = new StAXSOAPModelBuilder(reader);
             msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java Thu Jun  2 05:39:05 2005
@@ -16,15 +16,8 @@
 
 package org.apache.axis.transport.mail;
 
-import java.util.Properties;
-
-import javax.mail.Authenticator;
 import javax.mail.Flags;
-import javax.mail.Folder;
 import javax.mail.Message;
-import javax.mail.PasswordAuthentication;
-import javax.mail.Session;
-import javax.mail.Store;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.axis.addressing.AddressingConstants;
@@ -33,6 +26,7 @@
 import org.apache.axis.context.ConfigurationContextFactory;
 import org.apache.axis.description.TransportInDescription;
 import org.apache.axis.engine.AxisFault;
+import org.apache.axis.transport.EmailReceiver;
 import org.apache.axis.transport.TransportListener;
 import org.apache.axis.util.Utils;
 import org.apache.commons.logging.Log;
@@ -74,7 +68,7 @@
 
     private String replyTo;
 
-    public SimpleMailListener() {
+    public SimpleMailListener() throws AxisFault{
     }
 
     public SimpleMailListener(
@@ -150,43 +144,26 @@
         }
         while (!stopped) {
             try {
-                final PasswordAuthentication authentication = new PasswordAuthentication(user, password);
-                Properties props = new Properties();
-                props.put("mail.user", user);
-                props.put("mail.host", host);
-                props.put("mail.store.protocol", "pop3");
-                props.put("mail.transport.protocol", "smtp");
-                Session session = Session.getInstance(props,new Authenticator() {
-                    protected PasswordAuthentication getPasswordAuthentication() {
-                        return authentication;
-                    }
-                });
-                Store store = session.getStore();
-                store.connect();
-                Folder root = store.getDefaultFolder();
-                Folder inbox = root.getFolder("inbox");
-                inbox.open(Folder.READ_WRITE);
-                Message[] msgs = inbox.getMessages();
-                int numMessages = msgs.length;
-                if (msgs.length == 0) {
-                    System.out.println("No messages in inbox");
-                }
-                for (int i = 0; i < msgs.length; i++) {
-                    MimeMessage msg = (MimeMessage) msgs[i];
-                    if (msg != null) {
-                        MailWorker worker = new MailWorker(msg, configurationContext);
-                        if (doThreads) {
-                            Thread thread = new Thread(worker);
-                            thread.setDaemon(true);
-                            thread.start();
-                        } else {
+                
+                EmailReceiver receiver = new EmailReceiver(user, host, port, password);
+                receiver.connect();
+                Message[] msgs = receiver.receive();
+
+                if (msgs != null && msgs.length>0) {
+                    System.out.println(msgs.length + " Message Found");
+                    for (int i = 0; i < msgs.length; i++) {
+                        MimeMessage msg = (MimeMessage) msgs[i];
+                        if (msg != null) {
+                            MailWorker worker = new MailWorker(msg, configurationContext);
                             worker.run();
                         }
+                        msg.setFlag(Flags.Flag.DELETED, true);
                     }
-                    msg.setFlag(Flags.Flag.DELETED, true);
+
                 }
-                inbox.close(true);
-                store.close();
+                
+                receiver.disconnect();
+               
             } catch (Exception e) {
                 //log.debug(Messages.getMessage("exception00"), e); TODO Issue
                 // #1 CT 07-Feb-2005.
@@ -194,19 +171,6 @@
                 e.printStackTrace();
                 break;
             }
-            try {
-                pop3.logout();
-                pop3.disconnect();
-                Thread.sleep(3000);
-            } catch (Exception e) {
-                //log.error(Messages.getMessage("exception00"), e); TODO Issue
-                // #1 CT 07-Feb-2005.
-                log.debug(
-                    "An error occured when trying to disconnect from the Server." + e.getMessage(),
-                    e);
-                System.out.println(
-                    "An error occured when trying to disconnect from the Server." + e.getMessage());
-            }
         }
 
         log.info("Mail listner has been stoped.");
@@ -217,28 +181,6 @@
     }
 
     /**
-     * POP3 connection
-     */
-    private POP3Client pop3;
-
-    /**
-     * Obtain the serverSocket that that SimpleMailListner is listening on.
-     */
-    public POP3Client getPOP3() {
-        return pop3;
-    }
-
-    /**
-     * Set the serverSocket this server should listen on. (note : changing this
-     * will not affect a running server, but if you stop() and then start() the
-     * server, the new socket will be used).
-     */
-    public void setPOP3(POP3Client pop3) {
-        this.pop3 = pop3;
-    }
-
-    //CT 03-Feb-2005 I think it should be POP instead of HTTP
-    /**
      * Start this server.
      * 
      * Spawns a worker thread to listen for HTTP requests.
@@ -306,7 +248,6 @@
             POP3Client pop3 = new POP3Client();
             SimpleMailListener sas =
                 new SimpleMailListener(host, port, optUserName, optPassword, optDir);
-            sas.setPOP3(pop3);
             sas.start();
         } catch (Exception e) {
             // log.error(Messages.getMessage("exception00"), e); TODO Issue #1
@@ -342,8 +283,6 @@
                     + (port == null));
         }
 
-        POP3Client pop3 = new POP3Client();
-        this.setPOP3(pop3);
     }
 
     /* (non-Javadoc)

Modified: webservices/axis/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/project.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis/trunk/java/modules/samples/project.xml Thu Jun  2 05:39:05 2005
@@ -88,7 +88,7 @@
         <dependency>
             <groupId>axis</groupId>
             <artifactId>axis-wsdl4j</artifactId>
-            <version>1.2-RC3</version>
+            <version>1.2</version>
             <properties>
                 <module>true</module>
             </properties>
@@ -124,6 +124,8 @@
 	    <exclude>**/*Util*.java</exclude>
 		<exclude>**/*InteropStubTest.java</exclude>
 		<exclude>**/*MailEchoRawXMLTest.java</exclude> 
+		<exclude>**/*OneWayRawXMLTest.java</exclude> 
+		
       </excludes>
      <includes>
         <include>**/*Test.java</include>

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/MailEchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/MailEchoRawXMLTest.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/MailEchoRawXMLTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/MailEchoRawXMLTest.java Thu Jun  2 05:39:05 2005
@@ -42,8 +42,7 @@
 public class MailEchoRawXMLTest extends TestCase {
     private EndpointReference targetEPR =
             new EndpointReference(AddressingConstants.WSA_TO,
-                    "http://127.0.0.1:"
-            + (UtilServer.TESTING_PORT)
+                    "axis2@127.0.0.1"
             + "/axis/services/EchoXMLService/echoOMElement");
     private Log log = LogFactory.getLog(getClass());
     private QName serviceName = new QName("EchoXMLService");
@@ -148,4 +147,6 @@
                 (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
         result.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
     }
+    
+    
 }

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/OneWayRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/OneWayRawXMLTest.java?rev=179585&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/OneWayRawXMLTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/OneWayRawXMLTest.java Thu Jun  2 05:39:05 2005
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.axis.engine;
+
+//todo
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.MessageSender;
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.ConfigurationContextFactory;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.integration.UtilServer;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.transport.mail.SimpleMailListener;
+import org.apache.axis.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class OneWayRawXMLTest extends TestCase {
+    private EndpointReference targetEPR =
+        new EndpointReference(
+            AddressingConstants.WSA_TO,
+            "axis2@127.0.0.1" + "/axis/services/EchoXMLService/echoOMElement");
+    private Log log = LogFactory.getLog(getClass());
+    private QName serviceName = new QName("EchoXMLService");
+    private QName operationName = new QName("echoOMElement");
+    private QName transportName = new QName("http://localhost/my", "NullTransport");
+
+    private AxisConfiguration engineRegistry;
+    private MessageContext mc;
+
+    private SOAPEnvelope envelope;
+
+    private boolean finish = false;
+
+    public OneWayRawXMLTest() {
+        super(OneWayRawXMLTest.class.getName());
+    }
+
+    public OneWayRawXMLTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        SimpleMailListener ml = new SimpleMailListener();
+        ConfigurationContextFactory builder = new ConfigurationContextFactory();
+        ConfigurationContext configContext =
+            builder.buildEngineContext(UtilServer.TESTING_REPOSITORY);
+        ml.init(
+            configContext,
+            configContext.getAxisConfiguration().getTransportIn(
+                new QName(Constants.TRANSPORT_MAIL)));
+        ml.start();
+
+        ServiceDescription service = new ServiceDescription(serviceName);
+        OperationDescription operation = new OperationDescription(operationName);
+        operation.setMessageReciever(new MessageReceiver() {
+            public void recieve(MessageContext messgeCtx) throws AxisFault {
+                envelope = messgeCtx.getEnvelope();
+            }
+        });
+
+        configContext.getAxisConfiguration().addService(service);
+        Utils.resolvePhases(configContext.getAxisConfiguration(), service);
+    }
+
+    protected void tearDown() throws Exception {
+    }
+
+    private OMElement createEnvelope() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+        OMElement method = fac.createOMElement("echoOMElement", omNs);
+        OMElement value = fac.createOMElement("myValue", omNs);
+        value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+        method.addChild(value);
+
+        return method;
+    }
+
+    public void testEchoXMLSync() throws Exception {
+        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+        OMElement payload = createEnvelope();
+
+        MessageSender sender = new MessageSender();
+
+        sender.setTo(targetEPR);
+        sender.setSenderTransport(Constants.TRANSPORT_MAIL);
+
+        sender.send(operationName.getLocalPart(), payload);
+        while(envelope != null){
+            Thread.sleep(4000);
+        }
+    }
+
+}

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java Thu Jun  2 05:39:05 2005
@@ -38,8 +38,8 @@
     private static SimpleHTTPServer reciver;
     public static final int TESTING_PORT = 5555;
     public static final String FAILURE_MESSAGE = "Intentional Faliure";
-    public static final String TESTING_REPOSITORY = "target/test-resources/samples";
-   //public static final String TESTING_REPOSITORY = "modules/samples/target/test-resources/samples";
+   public static final String TESTING_REPOSITORY = "target/test-resources/samples";
+    //public static final String TESTING_REPOSITORY = "modules/samples/target/test-resources/samples";
 
     public static synchronized void deployService(ServiceDescription service) throws AxisFault {
         reciver.getSystemContext().getAxisConfiguration().addService(service);

Modified: webservices/axis/trunk/java/modules/wsdl/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/project.xml?rev=179585&r1=179584&r2=179585&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/project.xml (original)
+++ webservices/axis/trunk/java/modules/wsdl/project.xml Thu Jun  2 05:39:05 2005
@@ -67,7 +67,7 @@
 		<dependency>
             <groupId>axis</groupId>
             <artifactId>axis-wsdl4j</artifactId>
-            <version>1.2-RC3</version>
+            <version>1.2</version>
             <properties>
                 <module>true</module>
             </properties>