You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by he...@apache.org on 2005/05/20 13:11:08 UTC

svn commit: r171100 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/clientapi/ core/src/org/apache/axis/transport/ core/src/org/apache/axis/transport/http/ core/src/org/apache/axis/transport/mail/ core/src/org/apache/axis/transport/tcp/ core/test/org/apache/axis/transport/ samples/ samples/test/org/apache/axis/engine/ samples/test/org/apache/axis/integration/

Author: hemapani
Date: Fri May 20 04:11:07 2005
New Revision: 171100

URL: http://svn.apache.org/viewcvs?rev=171100&view=rev
Log:
add tcp and mail transport improvements

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/TCPEchoRawXMLTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilsTCPServer.java
Removed:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListner.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOnlyMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Stub.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailConstants.java
    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/tcp/TCPServer.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPTransportSender.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/SimpleMailListnerTest.java
    webservices/axis/trunk/java/modules/samples/project.xml
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java

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=171100&r1=171099&r2=171100&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 Fri May 20 04:11:07 2005
@@ -80,7 +80,7 @@
 
         //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
         HTTPTransportReceiver receiver = new HTTPTransportReceiver();
-        receiver.invoke(response, sysContext);
+        receiver.checkForResponse(response, sysContext);
         SOAPEnvelope resenvelope = response.getEnvelope();
         if (response!= null && resenvelope.getBody().hasFault()) {
             throw new AxisFault(resenvelope.getBody().getFault().getException());

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java Fri May 20 04:11:07 2005
@@ -18,8 +18,13 @@
 package org.apache.axis.clientapi;
 
 import java.io.IOException;
+import java.io.Reader;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axis.Constants;
 import org.apache.axis.addressing.EndpointReference;
@@ -34,7 +39,9 @@
 import org.apache.axis.engine.AxisEngine;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.om.OMException;
+import org.apache.axis.om.impl.llom.builder.StAXBuilder;
 import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
 import org.apache.axis.transport.http.HTTPTransportReceiver;
 import org.apache.wsdl.WSDLConstants;
 
@@ -58,21 +65,19 @@
      *      SMTP transport support only two channel case
      */
     protected boolean useSeparateListener = false;
-    
+
     /**
      * The address the message should be send
      */
     protected EndpointReference to;
 
-
     //variables use for internal implementations
-    
+
     /**
      * This is used for the Receiving the Async Messages 
      */
     protected CallbackReceiver callbackReceiver;
-    
-    
+
     /**
      * This accepts a ServiceContext, and the ServiceContext should have all the parents set in to it right
      * Ideall this should be generated from a WSDL, we do not have it yet. 
@@ -82,7 +87,7 @@
      *  ConfigurationContextFactory efac = new ConfigurationContextFactory();
         ConfigurationContext sysContext = efac.buildClientEngineContext(null); 
         // above line "null" may be a file name if you know the client repssitory
-
+    
         //create new service
         QName assumedServiceName = new QName("Your Service");
         ServiceDescription axisService = new ServiceDescription(assumedServiceName);
@@ -93,7 +98,7 @@
      * </code>
      * 
      * @param serviceContext
-     */    
+     */
 
     public InOutMEPClient(ServiceContext serviceContext) {
         super(serviceContext, WSDLConstants.MEP_URI_OUT_IN);
@@ -101,11 +106,11 @@
         callbackReceiver = new CallbackReceiver();
     }
 
-//    this method is commented out, till we implemented it     
-//    public InOutMEPClient(String wsdlfile) {
-//        super(null, WSDLConstants.MEP_URI_OUT_IN);
-//        throw new UnsupportedOperationException();
-//    }
+    //    this method is commented out, till we implemented it     
+    //    public InOutMEPClient(String wsdlfile) {
+    //        super(null, WSDLConstants.MEP_URI_OUT_IN);
+    //        throw new UnsupportedOperationException();
+    //    }
 
     public MessageContext invokeBlocking(OperationDescription axisop, final MessageContext msgctx)
         throws AxisFault {
@@ -115,16 +120,7 @@
         msgctx.setServiceContext(serviceContext);
         ConfigurationContext syscontext = serviceContext.getEngineContext();
 
-        if (senderTransport == null) {
-            senderTransport = inferTransport(to);
-        }
-        final TransportInDescription transportIn =
-            syscontext.getEngineConfig().getTransportIn(new QName(senderTransport));
-        final TransportOutDescription transportOut =
-            syscontext.getEngineConfig().getTransportOut(new QName(listenerTransport));
-
-        msgctx.setTransportIn(transportIn);
-        msgctx.setTransportOut(transportOut);
+        checkTransport(msgctx);
 
         ConfigurationContext sysContext = serviceContext.getEngineContext();
         AxisConfiguration registry = sysContext.getEngineConfig();
@@ -154,13 +150,20 @@
             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.invoke(response, sysContext);
-            SOAPEnvelope resenvelope = response.getEnvelope();
-            if (resenvelope.getBody().hasFault()) {
-                throw new AxisFault(resenvelope.getBody().getFault().getException());
+            SOAPEnvelope resenvelope = checkReturnChannel(response);
+            if (resenvelope != null) {
+                response.setEnvelope(resenvelope);
+                engine = new AxisEngine(serviceContext.getEngineContext());
+                engine.receive(response);
+
+                resenvelope = response.getEnvelope();
+                if (resenvelope.getBody().hasFault()) {
+                    throw new AxisFault(resenvelope.getBody().getFault().getException());
+                }
+            } else {
+                throw new AxisFault("Blocking invocation always expect a response");
             }
+            response.getTransportOut().getSender().cleanUp();
             return response;
         } catch (OMException e) {
             throw AxisFault.makeFault(e);
@@ -181,27 +184,8 @@
             final ConfigurationContext syscontext = serviceContext.getEngineContext();
 
             AxisEngine engine = new AxisEngine(syscontext);
-
-            if (senderTransport == null) {
-                senderTransport = inferTransport(to);
-            }
-            if(listenerTransport == null){
-                listenerTransport = senderTransport;
-            }
-
-
-            if(msgctx.getTransportIn() == null){
-                final TransportInDescription transportIn =
-                    syscontext.getEngineConfig().getTransportIn(new QName(senderTransport));
-                msgctx.setTransportIn(transportIn);
-            }
-            if(msgctx.getTransportOut() == null){
-                final TransportOutDescription transportOut =
-                    syscontext.getEngineConfig().getTransportOut(new QName(listenerTransport));
-                msgctx.setTransportOut(transportOut);
-            }
-
-
+            //TODO
+            checkTransport(msgctx);
 
             if (useSeparateListener) {
                 String messageID = String.valueOf(System.currentTimeMillis());
@@ -209,10 +193,11 @@
                 axisop.setMessageReciever(callbackReceiver);
                 callbackReceiver.addCallback(messageID, callback);
                 msgctx.setReplyTo(
-                ListenerManager.replyToEPR(
+                    ListenerManager.replyToEPR(
                         serviceContext.getServiceConfig().getName().getLocalPart()
                             + "/"
-                            + axisop.getName().getLocalPart(),listenerTransport));
+                            + axisop.getName().getLocalPart(),
+                        listenerTransport));
 
             }
             msgctx.setOperationContext(axisop.findOperationContext(msgctx, serviceContext, false));
@@ -237,12 +222,20 @@
                             response.setOperationContext(msgctx.getOperationContext());
                             response.setServiceContext(msgctx.getServiceContext());
 
-                            HTTPTransportReceiver receiver = new HTTPTransportReceiver();
-                            receiver.invoke(response, syscontext);
-                            SOAPEnvelope resenvelope = response.getEnvelope();
-                            AsyncResult asyncResult = new AsyncResult();
-                            asyncResult.setResult(resenvelope);
-                            callback.onComplete(asyncResult);
+                            SOAPEnvelope resenvelope = checkReturnChannel(response);
+                            if (resenvelope != null) {
+                                response.setEnvelope(resenvelope);
+                                AxisEngine engine =
+                                    new AxisEngine(serviceContext.getEngineContext());
+                                engine.receive(response);
+
+                                resenvelope = response.getEnvelope();
+                                AsyncResult asyncResult = new AsyncResult();
+                                asyncResult.setResult(resenvelope);
+                                callback.onComplete(asyncResult);
+                            } else {
+                                throw new AxisFault("Blocking invocation always expect a response");
+                            }
                         } catch (AxisFault e) {
                             callback.reportError(e);
                         }
@@ -251,6 +244,7 @@
                 };
                 (new Thread(newThread)).start();
             }
+            msgctx.getTransportOut().getSender().cleanUp();
 
         } catch (OMException e) {
             throw AxisFault.makeFault(e);
@@ -288,10 +282,13 @@
         String listenerTransport,
         boolean useSeparateListener)
         throws AxisFault {
+        this.senderTransport = senderTransport;
+        this.listenerTransport = listenerTransport;
 
         if (useSeparateListener
             || (senderTransport.equals(listenerTransport)
-                && Constants.TRANSPORT_HTTP.equals(senderTransport))) {
+                && (Constants.TRANSPORT_HTTP.equals(senderTransport)
+                    || Constants.TRANSPORT_TCP.equals(senderTransport)))) {
 
             this.useSeparateListener = useSeparateListener;
         } else {
@@ -299,8 +296,67 @@
         }
 
         if (useSeparateListener == true) {
-            ListenerManager.makeSureStarted(listenerTransport,serviceContext.getEngineContext());
+            ListenerManager.makeSureStarted(listenerTransport, serviceContext.getEngineContext());
+        }
+    }
+
+    private SOAPEnvelope checkReturnChannel(MessageContext response) throws AxisFault {
+        SOAPEnvelope resenvelope = null;
+        try {
+            //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
+            if (Constants.TRANSPORT_HTTP.equals(listenerTransport)) {
+                HTTPTransportReceiver receiver = new HTTPTransportReceiver();
+                resenvelope =
+                    receiver.checkForResponse(response, serviceContext.getEngineContext());
+            } else if (Constants.TRANSPORT_TCP.equals(listenerTransport)) {
+                Reader in = (Reader) response.getProperty(MessageContext.TRANSPORT_READER);
+                if(in != null){
+                    XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
+                    StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader);
+                    resenvelope = (SOAPEnvelope) builder.getDocumentElement();
+                }else{
+                    throw new AxisFault("Sync invocation expect a proeprty "+ MessageContext.TRANSPORT_READER + " set ");
+                }
+            }
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        } catch (FactoryConfigurationError e) {
+            throw new AxisFault(e);
+        }
+        return resenvelope;
+    }
+
+    private void checkTransport(MessageContext msgctx) throws AxisFault {
+        if (senderTransport == null) {
+            senderTransport = inferTransport(to);
+        }
+        if (listenerTransport == null) {
+            listenerTransport = senderTransport;
+        }
+
+        if (msgctx.getTransportIn() == null) {
+            final TransportInDescription transportIn =
+                serviceContext.getEngineContext().getEngineConfig().getTransportIn(
+                    new QName(senderTransport));
+            if (transportIn != null) {
+                msgctx.setTransportIn(transportIn);
+            } else {
+                throw new AxisFault("Unknown transport " + listenerTransport);
+            }
+
+        }
+        if (msgctx.getTransportOut() == null) {
+            final TransportOutDescription transportOut =
+                serviceContext.getEngineContext().getEngineConfig().getTransportOut(
+                    new QName(listenerTransport));
+            if (transportOut != null) {
+                msgctx.setTransportOut(transportOut);
+            } else {
+                throw new AxisFault("Unknown transport " + senderTransport);
+            }
+
         }
+
     }
 
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Stub.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Stub.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Stub.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/Stub.java Fri May 20 04:11:07 2005
@@ -16,21 +16,16 @@
 
 package org.apache.axis.clientapi;
 
-import javax.xml.namespace.QName;
-
-import org.apache.axis.context.ConfigurationContextFactory;
+import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.context.ConfigurationContext;
-import org.apache.axis.context.ServiceContext;
 import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
 import org.apache.axis.deployment.DeploymentException;
-import org.apache.axis.engine.AxisFault;
 import org.apache.axis.description.ServiceDescription;
-import org.apache.axis.description.OperationDescription;
-import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.addressing.AddressingConstants;
-import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.engine.AxisFault;
 import org.apache.axis.om.OMAbstractFactory;
 import org.apache.axis.om.OMElement;
+import org.apache.axis.soap.SOAPEnvelope;
 
 /**
  * @author chathura@opensource.lk

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportSender.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportSender.java Fri May 20 04:11:07 2005
@@ -15,10 +15,12 @@
  */
 package org.apache.axis.transport;
 
+import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.Handler;
 
 /**
  * Interface TransportSender
  */
 public interface TransportSender extends Handler {
+    public void cleanUp() throws AxisFault;
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java Fri May 20 04:11:07 2005
@@ -88,7 +88,9 @@
      * @param msgContext
      * @throws AxisFault
      */
-    public void invoke(MessageContext msgContext,ConfigurationContext engineContext) throws AxisFault{
+    public SOAPEnvelope checkForResponse(MessageContext msgContext,ConfigurationContext engineContext) throws AxisFault{
+        SOAPEnvelope soapEnvelope = null;
+        
         Reader in = (Reader) msgContext.getProperty(MessageContext.TRANSPORT_READER);
         if (in != null) {
             boolean serverSide = msgContext.isServerSide();
@@ -112,20 +114,19 @@
                     msgContext.setProperty(
                         MessageContext.TRANSPORT_SUCCEED,
                         HTTPConstants.RESPONSE_ACK_CODE_VAL);
-                    return;
+                    return soapEnvelope;
                 }
 
                 // TODO take care of other HTTP Headers
             }
-            AxisEngine axisEngine = new AxisEngine(engineContext);
+
             try {
                 XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
                 StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader);
-                msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
+                return (SOAPEnvelope) builder.getDocumentElement();
             } catch (Exception e) {
                 throw new AxisFault(e.getMessage(), e);
             }
-            axisEngine.receive(msgContext);
         } else {
             throw new AxisFault("Input reader not found");
         }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java Fri May 20 04:11:07 2005
@@ -37,28 +37,27 @@
      */
     private Socket socket;
     private ByteArrayOutputStream outputStream;
-//    /**
-//     * Method obtainOutputStream
-//     *
-//     * @param msgContext
-//     * @return
-//     * @throws AxisFault
-//     */
-//    protected Writer obtainWriter(MessageContext msgContext) throws AxisFault {
-//        if (!msgContext.isServerSide()) {
-//            //create a new byte buffer output stream
-//            outputStream = new ByteArrayOutputStream();
-//            out = new OutputStreamWriter(outputStream);
-//        } else {
-//            out = (Writer) msgContext.getProperty(MessageContext.TRANSPORT_WRITER);
-//        }
-//        if (out == null) {
-//            throw new AxisFault("can not find the suffient information to find endpoint");
-//        } else {
-//            return out;
-//        }
-//    }
-
+    //    /**
+    //     * Method obtainOutputStream
+    //     *
+    //     * @param msgContext
+    //     * @return
+    //     * @throws AxisFault
+    //     */
+    //    protected Writer obtainWriter(MessageContext msgContext) throws AxisFault {
+    //        if (!msgContext.isServerSide()) {
+    //            //create a new byte buffer output stream
+    //            outputStream = new ByteArrayOutputStream();
+    //            out = new OutputStreamWriter(outputStream);
+    //        } else {
+    //            out = (Writer) msgContext.getProperty(MessageContext.TRANSPORT_WRITER);
+    //        }
+    //        if (out == null) {
+    //            throw new AxisFault("can not find the suffient information to find endpoint");
+    //        } else {
+    //            return out;
+    //        }
+    //    }
 
     /**
      * Method writeTransportHeaders
@@ -95,42 +94,40 @@
 
     public void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)
         throws AxisFault {
-            EndpointReference toURL = msgContext.getTo();
-            if (toURL != null) {
-                try {
-                    URL url = new URL(toURL.getAddress());
-                    SocketAddress add =
-                        new InetSocketAddress(
-                            url.getHost(),
-                            url.getPort() == -1 ? 80 : url.getPort());
-                    socket = new Socket();
-                    socket.connect(add);
-                    OutputStream outS = socket.getOutputStream();
-                    byte[] bytes = outputStream.toByteArray();
-
-                    Writer realOut = new OutputStreamWriter(outS);
-                    //write header to the out put stream
-                    writeTransportHeaders(realOut, url, msgContext, bytes.length);
-                    realOut.flush();
-                    //write the content to the real output stream
-                    outS.write(bytes);
-                    outS.flush();
-
-                    msgContext.setProperty(
-                        MessageContext.TRANSPORT_READER,
-                        new InputStreamReader(socket.getInputStream()));
-                    msgContext.setProperty(HTTPConstants.SOCKET, socket);
-
-                    socket.shutdownOutput();
-
-                } catch (MalformedURLException e) {
-                    throw new AxisFault(e.getMessage(), e);
-                } catch (IOException e) {
-                    throw new AxisFault(e.getMessage(), e);
-                }
-            } else {
-                throw new AxisFault("to EPR must be specified");
+        EndpointReference toURL = msgContext.getTo();
+        if (toURL != null) {
+            try {
+                URL url = new URL(toURL.getAddress());
+                SocketAddress add =
+                    new InetSocketAddress(url.getHost(), url.getPort() == -1 ? 80 : url.getPort());
+                socket = new Socket();
+                socket.connect(add);
+                OutputStream outS = socket.getOutputStream();
+                byte[] bytes = outputStream.toByteArray();
+
+                Writer realOut = new OutputStreamWriter(outS);
+                //write header to the out put stream
+                writeTransportHeaders(realOut, url, msgContext, bytes.length);
+                realOut.flush();
+                //write the content to the real output stream
+                outS.write(bytes);
+                outS.flush();
+
+                msgContext.setProperty(
+                    MessageContext.TRANSPORT_READER,
+                    new InputStreamReader(socket.getInputStream()));
+                msgContext.setProperty(HTTPConstants.SOCKET, socket);
+
+                socket.shutdownOutput();
+
+            } catch (MalformedURLException e) {
+                throw new AxisFault(e.getMessage(), e);
+            } catch (IOException e) {
+                throw new AxisFault(e.getMessage(), e);
             }
+        } else {
+            throw new AxisFault("to EPR must be specified");
+        }
     }
 
     protected Writer openTheConnection(EndpointReference epr) {
@@ -140,17 +137,33 @@
 
     public void startSendWithOutputStreamFromIncomingConnection(
         MessageContext msgContext,
-        Writer writer)throws AxisFault {
-            try {
-                writer.write(new String(HTTPConstants.HTTP).toCharArray());
-                writer.write(new String(HTTPConstants.OK).toCharArray());
-                writer.write("\n\n".toCharArray());
-            } catch (IOException e) {
-                throw new AxisFault(e);
-            }
+        Writer writer)
+        throws AxisFault {
+        try {
+            writer.write(new String(HTTPConstants.HTTP).toCharArray());
+            writer.write(new String(HTTPConstants.OK).toCharArray());
+            writer.write("\n\n".toCharArray());
+        } catch (IOException e) {
+            throw new AxisFault(e);
+        }
     }
 
     public void startSendWithToAddress(MessageContext msgContext, Writer writer) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.transport.TransportSender#cleanUp()
+     */
+    public void cleanUp() throws AxisFault {
+        try {
+            if (socket != null) {
+                socket.close();
+                socket = null;
+            }
+
+        } catch (IOException e) {
+        }
+
     }
 
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java Fri May 20 04:11:07 2005
@@ -22,7 +22,9 @@
 import org.apache.axis.context.ConfigurationContextFactory;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.description.TransportOutDescription;
+import org.apache.axis.engine.AxisEngine;
 import org.apache.axis.engine.AxisFault;
+import org.apache.axis.soap.SOAPEnvelope;
 import org.apache.axis.transport.TransportListener;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -146,7 +148,10 @@
                         msgContext.setProperty(MessageContext.TRANSPORT_WRITER, out);
                         msgContext.setProperty(MessageContext.TRANSPORT_READER, in);
                         HTTPTransportReceiver reciver = new HTTPTransportReceiver();
-                        reciver.invoke(msgContext, configurationContext);
+                        msgContext.setEnvelope(reciver.checkForResponse(msgContext, configurationContext));
+                        
+                        AxisEngine engine = new AxisEngine(configurationContext);
+                        engine.receive(msgContext);
 
                         if (msgContext.getReplyTo() != null
                             && !AddressingConstants.EPR_ANONYMOUS_URL.equals(

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailConstants.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailConstants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/MailConstants.java Fri May 20 04:11:07 2005
@@ -22,4 +22,13 @@
     public final static String POP3_PASSWORD = "transport.mail.pop3.password";
 
     public final static String HEADER_SOAP_ACTION = "transport.mail.soapaction";
+    
+    public final static String CONTENT_TYPE = "transport.mail.contenttype";
+    
+    public final static String CONTENT_LOCAION = "transport.mail.contentlocation";
+    
+    
+    public final static String HOST = "host";
+    public final static String USER = "user";
+    public final static String PASSWORD = "password";
 }

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=171100&r1=171099&r2=171100&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 Fri May 20 04:11:07 2005
@@ -16,108 +16,103 @@
 
 package org.apache.axis.transport.mail;
 
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.util.Properties;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.MimeMessage;
+
 import org.apache.axis.addressing.EndpointReference;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.transport.AbstractTransportSender;
 
-import java.io.Writer;
-import java.net.Socket;
-
 public class MailTransportSender extends AbstractTransportSender {
-    protected Writer out;
+    private String host;
+    private String user;
+    private String password;
+    private String smtpPort = "25";
 
-    private Socket socket;
+    private PipedInputStream in;
 
     public MailTransportSender() {
 
     }
 
- 
-
-    protected Writer obtainOutputStream(MessageContext msgContext,
-            EndpointReference epr) throws AxisFault {
+    public void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)
+        throws AxisFault {
         throw new UnsupportedOperationException();
+
     }
 
-     
-    protected void startSending(MessageContext msgContext) throws AxisFault {
-        try {
-            Writer writer = (Writer) msgContext
-                    .getProperty(MessageContext.TRANSPORT_WRITER);
-            startSending(msgContext, writer);
-        } catch (Exception e) {
-            throw new AxisFault(e.getMessage());
-        }
+    public void startSendWithToAddress(MessageContext msgContext, Writer writer) throws AxisFault {
+        throw new UnsupportedOperationException();
+
     }
 
-    protected void startSending(MessageContext msgContext, Writer writer) throws AxisFault {
+    protected Writer openTheConnection(EndpointReference epr) throws AxisFault {
+
         try {
-            writer.write("Content-Type: text/plain; charset=us-ascii\n");
-            writer.write("Content-Transfer-Encoding: 7bit\n");
-            writer
-                    .write("Accept: application/soap+xml, application/dime, multipart/related, text\n");
-            //writer.write("MIME-Version: 1.0\n");
-            writer.write("User-Agent: Axis2 M1\n");
-            writer.write("Cache-Control: no-cache\n");
-            writer.write("Pragma: no-cache\n");
-            writer.write("Subject: Re:"
-                    + msgContext.getProperty(MailConstants.SUBJECT) + "\n\n");
-        } catch (Exception e) {
-            throw new AxisFault(e.getMessage());
+
+            in = new PipedInputStream();
+            PipedOutputStream out = new PipedOutputStream(in);
+
+            return new OutputStreamWriter(out);
+        } catch (IOException e) {
+            throw new AxisFault(e);
         }
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.axis.transport.AbstractTransportSender#finalizeSendWithOutputStreamFromIncomingConnection(org.apache.axis.context.MessageContext, java.io.Writer)
-     */
-    public void finalizeSendWithOutputStreamFromIncomingConnection(
-        MessageContext msgContext,
-        Writer writer)
-        throws AxisFault {
-            throw new UnsupportedOperationException();
 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.axis.transport.AbstractTransportSender#finalizeSendWithToAddress(org.apache.axis.context.MessageContext, org.apache.axis.addressing.EndpointReference, java.io.Writer)
-     */
-    public void finalizeSendWithToAddress(
+    //Output Stream based cases are not supported 
+    public void startSendWithOutputStreamFromIncomingConnection(
         MessageContext msgContext,
         Writer writer)
         throws AxisFault {
-            throw new UnsupportedOperationException();
-
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.axis.transport.AbstractTransportSender#openTheConnection(org.apache.axis.addressing.EndpointReference)
-     */
-    protected Writer openTheConnection(EndpointReference epr) throws AxisFault {
         throw new UnsupportedOperationException();
-    }
 
-    /* (non-Javadoc)
-     * @see org.apache.axis.transport.AbstractTransportSender#startSendWithOutputStreamFromIncomingConnection(org.apache.axis.context.MessageContext, java.io.Writer)
-     */
-    public void startSendWithOutputStreamFromIncomingConnection(
+    }
+    public void finalizeSendWithOutputStreamFromIncomingConnection(
         MessageContext msgContext,
         Writer writer)
         throws AxisFault {
-            throw new UnsupportedOperationException();
-
+        try {
+            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);
+
+            MimeMessage msg = new MimeMessage(session, in);
+            String action = msgContext.getWSAAction();
+            if (action != null) {
+                msg.setHeader("transport.mail.soapaction", action);
+            }
+
+            msg.addRecipients(Message.RecipientType.TO, msgContext.getTo().getAddress());
+            msg.setSubject(msgContext.getTo().getAddress());
+            Transport.send(msg);
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
+        }
     }
-
     /* (non-Javadoc)
-     * @see org.apache.axis.transport.AbstractTransportSender#startSendWithToAddress(org.apache.axis.context.MessageContext, org.apache.axis.addressing.EndpointReference, java.io.Writer)
+     * @see org.apache.axis.transport.TransportSender#cleanUp()
      */
-    public void startSendWithToAddress(
-        MessageContext msgContext,
-        Writer writer)
-        throws AxisFault {
-            throw new UnsupportedOperationException();
+    public void cleanUp() throws AxisFault {
+        // TODO Auto-generated method stub
 
     }
 
 }
-

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=171100&r1=171099&r2=171100&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 Fri May 20 04:11:07 2005
@@ -16,6 +16,17 @@
 
 package org.apache.axis.transport.mail;
 
+import java.io.ByteArrayInputStream;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.axis.Constants;
 import org.apache.axis.addressing.AddressingConstants;
 import org.apache.axis.addressing.EndpointReference;
@@ -28,41 +39,17 @@
 import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.commons.net.smtp.SMTPClient;
-import org.apache.commons.net.smtp.SMTPReply;
-
-import javax.mail.Message;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.Writer;
-import java.util.Properties;
 
 public class MailWorker implements Runnable {
     protected static Log log = LogFactory.getLog(MailWorker.class.getName());
 
     private String contentType = "text/xml";
 
-    // Server
-    private SimpleMailListner server;
-
-    private SMTPClient client = null;
-
     private ConfigurationContext reg = null;
 
     // Current message
     private MimeMessage mimeMessage;
 
-    //Processed responce CT 08-Feb-2005
-    private MimeMessage outputMimeMessage;
-
-    // Axis specific constants
-    private static String transportName = "mail";
-
     private Properties prop = new Properties();
 
     private Session session = Session.getDefaultInstance(prop, null);
@@ -73,9 +60,7 @@
      * @param server
      * @param mimeMessage
      */
-    public MailWorker(SimpleMailListner server, MimeMessage mimeMessage,
-                      ConfigurationContext reg) {
-        this.server = server;
+    public MailWorker(MimeMessage mimeMessage, ConfigurationContext reg) {
         this.mimeMessage = mimeMessage;
         this.reg = reg;
     }
@@ -85,83 +70,46 @@
      */
     public void run() {
         // create an Axis server
-        AxisEngine engine = SimpleMailListner.getAxisEngine();
+        AxisEngine engine = new AxisEngine(reg);
         MessageContext msgContext = null;
         // create and initialize a message context
         try {
-            msgContext = new MessageContext(null,
-                    reg.getEngineConfig().getTransportIn(new QName(Constants.TRANSPORT_HTTP)),
-                    reg.getEngineConfig().getTransportOut(new QName(Constants.TRANSPORT_HTTP)),reg);
+            msgContext =
+                new MessageContext(
+                    null,
+                    reg.getEngineConfig().getTransportIn(new QName(Constants.TRANSPORT_MAIL)),
+                    reg.getEngineConfig().getTransportOut(new QName(Constants.TRANSPORT_MAIL)),
+                    reg);
             msgContext.setServerSide(true);
-        } catch (AxisFault af) {
-            log.error("Error occured while creating the message context", af);
-        }
 
-        Message requestMsg = null;
+            msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType());
+            msgContext.setWSAAction(getMailHeader(MailConstants.HEADER_SOAP_ACTION));
 
-        // buffers for the headers we care about
-        StringBuffer soapAction = new StringBuffer();
-        StringBuffer fileName = new StringBuffer();
-        StringBuffer contentType = new StringBuffer();
-        StringBuffer contentLocation = new StringBuffer();
-
-        Message responseMsg = null;
-
-        // prepare request (do as much as possible while waiting for the
-        // next connection).
- 
-        //msgContext.setResponseMessage(null);
-        //msgContext.reset();
-        // msgContext.setTransport(new AxisTransport(transportName)); There is
-        // no way to set the transport. CT 07-Feb-2005.
+            String to = mimeMessage.getSubject();
+            if (to != null) {
+                msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, to));
+            }
 
-        responseMsg = null;
+            String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
+            if (replyTo != null) {
+                msgContext.setReplyTo(
+                    new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
+            }
 
-        try {
-            // parse all headers into hashtable
-            parseHeaders(mimeMessage, contentType, contentLocation,
-                    soapAction);
-
-            String soapActionString = soapAction.toString();
-            if (soapActionString != null) {
-                //msgContext.setUseSOAPAction(true); Not present CT
-                // 07-Feb-2005
-                msgContext.setWSAAction(
-                        soapActionString);
+            String sendFrom = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
+            if (sendFrom != null) {
+                msgContext.setFrom(new EndpointReference(AddressingConstants.WSA_FROM, sendFrom));
             }
 
-            System.out
-                    .println("This is the data that is to be processed  \n "
-                    + mimeMessage.getContent().toString() + "\n");
-
-            ByteArrayInputStream bais = new ByteArrayInputStream(mimeMessage.getContent().toString().getBytes());
-            XMLStreamReader reader = XMLInputFactory.newInstance()
-                    .createXMLStreamReader(bais);
+            // add the SOAPEnvelope
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(mimeMessage.getContent().toString().getBytes());
+            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
             StAXBuilder builder = new StAXSOAPModelBuilder(reader);
-
-            msgContext.setEnvelope((SOAPEnvelope) builder
-                    .getDocumentElement());
-
-            //A writer is created and sent to the engine so that the engine
-            // can write straight to the writer
-            String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0])
-                    .getAddress();
-            String sendFrom = ((InternetAddress) mimeMessage
-                    .getAllRecipients()[0]).getAddress();
-            String subject = mimeMessage.getSubject();
-            msgContext.setProperty(MailConstants.FROM_ADDRESS, sendFrom);
-            msgContext.setProperty(MailConstants.TO_ADDRESS, replyTo);
-            msgContext.setProperty(MailConstants.SUBJECT, subject);
-            Writer wr = getMailWriter(server.getHost(), msgContext);
-
-            msgContext.setProperty(MessageContext.TRANSPORT_WRITER, wr);
-            msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, replyTo));
+            msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
 
             // invoke the Axis engine
             engine.receive(msgContext);
-
-            sendMessage(wr);
-
         } catch (Exception e) {
             e.printStackTrace();
             AxisFault af;
@@ -169,8 +117,7 @@
                 af = (AxisFault) e;
                 //log.debug(Messages.getMessage("serverFault00"), af);
                 // CT 07-Feb-2005
-                log.debug("Error occured while trying to process the mail.",
-                        af);
+                log.debug("Error occured while trying to process the mail.", af);
             } else {
                 af = AxisFault.makeFault(e);
             }
@@ -185,71 +132,18 @@
          */
     }
 
-    private Writer getMailWriter(String smtpHost, MessageContext msgContext)
-            throws Exception {
-        client = new SMTPClient();
-        client.connect(smtpHost);
-
-        // After connection attempt, you should check the reply code to verify
-        // success.
-        int reply = client.getReplyCode();
-        if (!SMTPReply.isPositiveCompletion(reply)) {
-            client.disconnect();
-            AxisFault fault = new AxisFault("SMTP"
-                    + "( SMTP server refused connection )"); //Issue #2 CT
-            // 07-Feb-2005.
-            throw fault;
-        }
-
-        client.login(smtpHost);
-        reply = client.getReplyCode();
-        if (!SMTPReply.isPositiveCompletion(reply)) {
-            client.disconnect();
-            AxisFault fault = new AxisFault("SMTP"
-                    + "( SMTP server refused connection )");
-            throw fault;
+    private String getMailHeader(String headerName) throws AxisFault {
+        try {
+            String values[] = mimeMessage.getHeader(headerName);
+            if (values != null) {
+                return values[0];
+            } else {
+                return null;
+            }
+        } catch (MessagingException e) {
+            throw new AxisFault(e);
         }
-        client.setSender((String) msgContext
-                .getProperty(MailConstants.FROM_ADDRESS));
-        client.addRecipient((String) msgContext
-                .getProperty(MailConstants.TO_ADDRESS));
-        Writer writer = client.sendMessageData();
 
-        return writer;
     }
 
-    private void sendMessage(Writer writer) throws Exception {
-        writer.flush();
-        writer.close();
-
-        System.out.print(client.getReplyString());
-        if (!client.completePendingCommand()) {
-            System.out.print(client.getReplyString());
-            AxisFault fault = new AxisFault("SMTP" + "( Failed to send email )");
-            throw fault;
-        }
-        client.logout();
-        client.disconnect();
-    }
-
-    /**
-     * Read all mime headers, returning the value of Content-Length and
-     * SOAPAction.
-     *
-     * @param mimeMessage     InputStream to read from
-     * @param contentType     The content type.
-     * @param contentLocation The content location
-     * @param soapAction      StringBuffer to return the soapAction into
-     */
-    private void parseHeaders(MimeMessage mimeMessage,
-                              StringBuffer contentType, StringBuffer contentLocation,
-                              StringBuffer soapAction) throws Exception {
-        contentType.append(mimeMessage.getContentType());
-        contentLocation.append(mimeMessage.getContentID());
-        String values[] = mimeMessage
-                .getHeader(MailConstants.HEADER_SOAP_ACTION);
-        if (values != null)
-            soapAction.append(values[0]);
-        System.out.println("Calling soap action " + soapAction);
-    }
 }

Added: 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=171100&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/mail/SimpleMailListener.java Fri May 20 04:11:07 2005
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2001-2004 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.transport.mail;
+
+import java.util.Properties;
+
+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.context.ConfigurationContext;
+import org.apache.axis.context.ConfigurationContextFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.net.pop3.POP3Client;
+
+/**
+ * This is a simple implementation of an SMTP/POP3 server for processing SOAP
+ * requests via Apache's xml-axis. This is not intended for production use. Its
+ * intended uses are for demos, debugging, and performance profiling.
+ * 
+ * @author Davanum Srinivas <di...@yahoo.com>
+ * @author Rob Jellinghaus (robj@unrealities.com)
+ * 
+ * @author Chamil Thanthrimudalige <ch...@gmail.com>Changes done to make the
+ *         Class work inside Axis 2.
+ */
+
+/*
+ * TODO ISSUES -- 1. Message.getMessage -- All messages are hardcoded in the
+ * code till a replacement or a working verion of this is put into Axis 2. When
+ * internationalization work is done this can be fixed. CT 15-Feb-2005
+ *  
+ */
+
+public class SimpleMailListener implements Runnable {
+
+    protected static Log log = LogFactory.getLog(SimpleMailListener.class.getName());
+
+    private String host;
+
+    private int port;
+
+    private String userid;
+
+    private String password;
+
+    private ConfigurationContext er = null;
+
+    public SimpleMailListener(String host, int port, String userid, String password, String dir) {
+        this.host = host;
+        this.port = port;
+        this.userid = userid;
+        this.password = password;
+        try {
+            ConfigurationContextFactory builder = new ConfigurationContextFactory();
+            er = builder.buildEngineContext(dir);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        try {
+            System.out.println("Sleeping for a bit to let the engine start up.");
+            Thread.sleep(2000);
+        } catch (InterruptedException e1) {
+            log.debug(e1.getMessage(), e1);
+        }
+    }
+
+    public SimpleMailListener(
+        String host,
+        int port,
+        String userid,
+        String password,
+        ConfigurationContext er) {
+        this.host = host;
+        this.port = port;
+        this.userid = userid;
+        this.password = password;
+        this.er = er;
+    }
+
+    // Are we doing threads?
+    private static boolean doThreads = true;
+
+    public void setDoThreads(boolean value) {
+        doThreads = value;
+    }
+
+    public boolean getDoThreads() {
+        return doThreads;
+    }
+
+    // are we stopped?
+    // latch to true if stop() is called
+    private boolean stopped = false;
+
+    /**
+     * Accept requests from a given TCP port and send them through the Axis
+     * engine for processing.
+     */
+    public void run() {
+        // log.info(Message.getMessage("start00", "SimpleMailListner", host + ":" +
+        // port)); TODO Issue #1 CT 07-Feb-2005.
+        // Accept and process requests from the socket
+        if (!stopped) {
+            String logMessage =
+                "Mail listner is being setup to listen to the address "
+                    + userid
+                    + "@"
+                    + host
+                    + " On port "
+                    + port;
+            System.out.println(logMessage);
+            log.info(logMessage);
+        }
+        while (!stopped) {
+            try {
+                PasswordAuthentication authentication =
+                    new PasswordAuthentication(userid, password);
+                Properties props = new Properties();
+                props.put("mail.user", userid);
+                props.put("mail.host", host);
+                props.put("mail.store.protocol", "pop3");
+                props.put("mail.transport.protocol", "smtp");
+                Session session = Session.getInstance(props);
+                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, er);
+                        if (doThreads) {
+                            Thread thread = new Thread(worker);
+                            thread.setDaemon(true);
+                            thread.start();
+                        } else {
+                            worker.run();
+                        }
+                    }
+                    msg.setFlag(Flags.Flag.DELETED, true);
+                }
+                inbox.close(true);
+                store.close();
+            } catch (Exception e) {
+                //log.debug(Messages.getMessage("exception00"), e); TODO Issue
+                // #1 CT 07-Feb-2005.
+                log.debug("An error occured when running the mail listner." + e.getMessage(), e);
+                System.out.println(
+                    "An error occured when running the mail listner." + e.getMessage());
+                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.");
+        System.out.println("Mail listner has been stoped.");
+        //log.info(Messages.getMessage("quit00", "SimpleMailListner")); TODO Issue #1
+        // CT 07-Feb-2005.
+
+    }
+
+    /**
+     * 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.
+     * 
+     * @param daemon
+     *            a boolean indicating if the thread should be a daemon.
+     */
+    public void start(boolean daemon) throws Exception {
+        if (doThreads) {
+            Thread thread = new Thread(this);
+            thread.setDaemon(daemon);
+            thread.start();
+        } else {
+            run();
+        }
+    }
+
+    /**
+     * Start this server as a NON-daemon.
+     */
+    public void start() throws Exception {
+        start(false);
+    }
+
+    /**
+     * Stop this server.
+     * 
+     * This will interrupt any pending accept().
+     */
+    public void stop() throws Exception {
+        /*
+         * Close the server socket cleanly, but avoid fresh accepts while the
+         * socket is closing.
+         */
+        stopped = true;
+        //log.info(Messages.getMessage("quit00", "SimpleMailListner")); TODO Issue #1
+        // CT 07-Feb-2005.
+        log.info("Quiting the mail listner");
+    }
+
+    /**
+     * Server process.
+     */
+    public static void main(String args[]) {
+        boolean optDoThreads = true;
+        String optHostName = "localhost";
+        boolean optUseCustomPort = false;
+        int optCustomPortToUse = 0;
+        String optDir = "/home/chamil/temp";
+        String optUserName = "server";
+        String optPassword = "server";
+        System.out.println("Starting the mail listner");
+        // Options object is not used for now. Hard coded values will be used.
+        // TODO have to meke this a bit more generic. CT 07-Feb-2005.
+        //Options opts = null;
+
+        /*
+         * try { opts = new Options(args); } catch (MalformedURLException e) {
+         * log.error(Messages.getMessage("malformedURLException00"), e); return; }
+         */
+        try {
+            doThreads = optDoThreads; //(opts.isFlagSet('t') > 0);
+            String host = optHostName; //opts.getHost();
+            int port = ((optUseCustomPort) ? optCustomPortToUse : 110);
+            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
+            // CT 07-Feb-2005.
+            log.error(
+                "An error occured in the main method of SimpleMailListner. TODO Detailed error message needs to be inserted here.");
+            return;
+        }
+
+    }
+}
\ No newline at end of file

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPServer.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPServer.java Fri May 20 04:11:07 2005
@@ -100,11 +100,12 @@
                     new MessageContext(
                         null,
                         configContext.getEngineConfig().getTransportIn(
-                            new QName(Constants.TRANSPORT_HTTP)),
+                            new QName(Constants.TRANSPORT_TCP)),
                         transportOut,
                         configContext);
                 msgContext.setServerSide(true);
-                msgContext.setProperty(MessageContext.TRANSPORT_WRITER, new OutputStreamWriter(socket.getOutputStream()));
+                msgContext.setProperty(MessageContext.TRANSPORT_WRITER, out);
+                msgContext.setProperty(MessageContext.TRANSPORT_READER, in);
                 
                 AxisEngine engine = new AxisEngine(configContext);
                 try {
@@ -117,12 +118,16 @@
                 engine.receive(msgContext);
             } catch (Throwable e) {
                 log.error(e);
+                e.printStackTrace();
             } finally{
                try {
-                     socket.close();
-                     if(!started){
-                         serversocket.close();
-                     }
+                   if(socket != null){
+                       socket.close();                   
+                       if(!started){
+                           serversocket.close();
+                       }
+                   }
+
                 } catch (IOException e1) {
                    log.error(e1);
                 }
@@ -150,7 +155,12 @@
      * @see org.apache.axis.transport.TransportListener#stop()
      */
     public void stop() throws AxisFault {
-        started = false;
+        try {
+            this.serversocket.close();        
+            started = false;
+        } catch (IOException e) {
+            throw new AxisFault(e);
+        }
     }
 
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPTransportSender.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/tcp/TCPTransportSender.java Fri May 20 04:11:07 2005
@@ -64,7 +64,8 @@
     public void finalizeSendWithToAddress(MessageContext msgContext, Writer writer)
         throws AxisFault {
         try {
-            socket.close();
+            socket.shutdownOutput();
+            msgContext.setProperty(MessageContext.TRANSPORT_READER, new InputStreamReader(socket.getInputStream()));
         } catch (IOException e) {
             throw new AxisFault(e);
         }
@@ -97,6 +98,18 @@
     }
 
     public void startSendWithToAddress(MessageContext msgContext, Writer writer) {
+    }
+
+    public void cleanUp() throws AxisFault {
+        try {
+            if(socket != null){
+                socket.close();
+                socket = null;
+            }
+            
+        } catch (IOException e) {
+        }
+
     }
 
 }

Modified: webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/SimpleMailListnerTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/SimpleMailListnerTest.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/SimpleMailListnerTest.java (original)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/SimpleMailListnerTest.java Fri May 20 04:11:07 2005
@@ -15,10 +15,11 @@
  */
 package org.apache.axis.transport;
 import junit.framework.TestCase;
-import org.apache.axis.transport.mail.SimpleMailListner;
+
+import org.apache.axis.transport.mail.SimpleMailListener;
 
 public class SimpleMailListnerTest extends TestCase {
-    private SimpleMailListner sas;
+    private SimpleMailListener sas;
     public SimpleMailListnerTest(String testName) {
         super(testName);
     }

Modified: webservices/axis/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/project.xml?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis/trunk/java/modules/samples/project.xml Fri May 20 04:11:07 2005
@@ -93,6 +93,22 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+           <groupId>commons-net</groupId>
+           <artifactId>commons-net</artifactId>
+           <version>1.3.0</version>
+           <properties>
+               <module>true</module>
+           </properties>
+       </dependency>
+	 <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-javamail</artifactId>
+            <version>1.3.1-rc3</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 
     <!-- build information for the project -->
@@ -107,6 +123,7 @@
         <exclude>**/*Abstract*.java</exclude>
 	    <exclude>**/*Util*.java</exclude>
 		<exclude>**/*InteropStubTest.java</exclude>
+		<exclude>**/*TCPEchoRawXMLTest.java</exclude>
       </excludes>
      <includes>
         <include>**/*Test.java</include>

Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java?rev=171100&r1=171099&r2=171100&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLOnTwoChannelsTest.java Fri May 20 04:11:07 2005
@@ -109,27 +109,27 @@
     }
 
     public void testEchoXMLCompleteASync() throws Exception {
-        DeploymentEngine deploymentEngine = new DeploymentEngine();
-        File file = new File("target/test-resources/repository-client/modules/addressing.mar");
-        //File file = new File("modules/samples/target/test-resources/repository-client/modules/addressing.mar");
-
-        assertTrue(file.exists());
-        ModuleDescription moduleDesc = deploymentEngine.buildModule(file);
-
-        ConfigurationContextFactory efac = new ConfigurationContextFactory();
-        ConfigurationContext sysContext = efac.buildClientEngineContext(null);
-        new ConfigurationContext(new AxisConfigurationImpl());
-        sysContext.getEngineConfig().addMdoule(moduleDesc);
-        sysContext.getEngineConfig().engageModule(moduleDesc.getName());
+//        DeploymentEngine deploymentEngine = new DeploymentEngine();
+//        File file = new File(UtilServer.TESTING_REPOSITORY + "/addressing.mar");
+//        assertTrue(file.exists());
+//        ModuleDescription moduleDesc = deploymentEngine.buildModule(file);
+//
+//        ConfigurationContextFactory efac = new ConfigurationContextFactory();
+//        ConfigurationContext sysContext = efac.buildClientEngineContext(null);
+//        new ConfigurationContext(new AxisConfigurationImpl());
+//        sysContext.getEngineConfig().addMdoule(moduleDesc);
+//        sysContext.getEngineConfig().engageModule(moduleDesc.getName());
         ServiceDescription service =
             Utils.createSimpleService(
                 serviceName,
                 org.apache.axis.engine.Echo.class.getName(),
                 operationName);
-        sysContext.getEngineConfig().addService(service);
-        Utils.resolvePhases(sysContext.getEngineConfig(), service);
-        ServiceContext serviceContext = sysContext.createServiceContext(service.getName());
-
+//        sysContext.getEngineConfig().addService(service);
+//        Utils.resolvePhases(sysContext.getEngineConfig(), service);
+//        ServiceContext serviceContext = sysContext.createServiceContext(service.getName());
+        ServiceContext serviceContext = UtilServer.createAdressedEnabledClientSide(service);
+        
+        
         OMFactory fac = OMAbstractFactory.getOMFactory();
 
         OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/TCPEchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/TCPEchoRawXMLTest.java?rev=171100&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/TCPEchoRawXMLTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/TCPEchoRawXMLTest.java Fri May 20 04:11:07 2005
@@ -0,0 +1,154 @@
+/*
+ * 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;
+
+
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+
+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.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.integration.UtilServer;
+import org.apache.axis.integration.UtilsTCPServer;
+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.SOAPFactory;
+import org.apache.axis.transport.http.SimpleHTTPServer;
+import org.apache.axis.util.Utils;
+
+public class TCPEchoRawXMLTest extends TestCase {
+    private EndpointReference targetEPR =
+            new EndpointReference(AddressingConstants.WSA_TO,
+                    "http://127.0.0.1:"
+            + (UtilServer.TESTING_PORT+1)
+            + "/axis/services/EchoXMLService/echoOMElement");
+    private QName serviceName = new QName("EchoXMLService");
+    private QName operationName = new QName("echoOMElement");
+    private QName transportName = new QName("http://localhost/my", "NullTransport");
+
+    private MessageContext mc;
+    private SimpleHTTPServer sas;
+    private ServiceDescription service;
+    private ServiceContext serviceContext;
+    
+    private boolean finish = false;
+
+    public TCPEchoRawXMLTest() {
+        super(TCPEchoRawXMLTest.class.getName());
+    }
+
+    public TCPEchoRawXMLTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        UtilsTCPServer.start();
+        
+        
+        //create and deploy the service
+        service =
+                Utils.createSimpleService(serviceName,
+                        org.apache.axis.engine.Echo.class.getName(),
+                        operationName);
+        UtilsTCPServer.deployService(service);
+        
+        ServiceDescription service =
+                   Utils.createSimpleService(
+                       serviceName,
+                       org.apache.axis.engine.Echo.class.getName(),
+                       operationName);
+               serviceContext = UtilServer.createAdressedEnabledClientSide(service);
+    }
+
+    protected void tearDown() throws Exception {
+        UtilsTCPServer.stop();
+    }
+
+    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 testEchoXMLASync() throws Exception {
+                OMElement payload = createEnvelope();
+
+        org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call();
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_TCP, Constants.TRANSPORT_TCP, false);
+
+        Callback callback = new Callback() {
+            public void onComplete(AsyncResult result) {
+                try {
+                    result.getResponseEnvelope().serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
+                } catch (XMLStreamException e) {
+                    reportError(e);
+                } finally {
+                    finish = true;
+                }
+            }
+
+            public void reportError(Exception e) {
+                e.printStackTrace();
+                finish = true;
+            }
+        };
+
+        call.invokeNonBlocking(operationName.getLocalPart(), payload, callback);
+        int index = 0;
+        while (!finish) {
+            Thread.sleep(1000);
+            index++;
+            if(index > 10 ){
+                throw new AxisFault("Server is shutdown as the Async response take too longs time");
+            }
+        }
+    }
+
+    public void testEchoXMLSync() throws Exception {
+        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+        OMElement payload = createEnvelope();
+
+        org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call();
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_TCP, Constants.TRANSPORT_TCP, false);
+
+        OMElement result =
+                (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+        result.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
+    }
+}

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=171100&r1=171099&r2=171100&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 Fri May 20 04:11:07 2005
@@ -13,48 +13,49 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 package org.apache.axis.integration;
 
+import java.io.File;
+import java.net.ServerSocket;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
 import org.apache.axis.context.ConfigurationContext;
 import org.apache.axis.context.ConfigurationContextFactory;
 import org.apache.axis.context.ServiceContext;
+import org.apache.axis.deployment.DeploymentEngine;
+import org.apache.axis.description.ModuleDescription;
 import org.apache.axis.description.ServiceDescription;
-import org.apache.axis.engine.AxisConfiguration;
+import org.apache.axis.engine.AxisConfigurationImpl;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.transport.http.SimpleHTTPServer;
 import org.apache.axis.util.Utils;
 
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.net.ServerSocket;
-
 public class UtilServer {
     private static int count = 0;
     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 synchronized void deployService(ServiceDescription service)
-            throws AxisFault {
-        reciver.getSystemContext().getEngineConfig().addService(service);        
-        Utils.resolvePhases(reciver.getSystemContext().getEngineConfig(),service);
+    public static synchronized void deployService(ServiceDescription service) throws AxisFault {
+        reciver.getSystemContext().getEngineConfig().addService(service);
+        Utils.resolvePhases(reciver.getSystemContext().getEngineConfig(), service);
     }
 
-    public static synchronized void unDeployService(QName service)
-            throws AxisFault {
+    public static synchronized void unDeployService(QName service) throws AxisFault {
         reciver.getSystemContext().getEngineConfig().removeService(service);
     }
 
     public static synchronized void start() throws Exception {
         if (count == 0) {
             ConfigurationContextFactory erfac = new ConfigurationContextFactory();
-            
-            //File file = new File("modules/samples/target/test-resources/samples");
-            File file = new File("target/test-resources/samples");
-            if(!file.exists()){
+            File file = new File(TESTING_REPOSITORY);
+            if (!file.exists()) {
                 throw new Exception("repository directory does not exists");
             }
             ConfigurationContext er = erfac.buildEngineContext(file.getAbsolutePath());
@@ -63,14 +64,10 @@
             } catch (InterruptedException e1) {
                 throw new AxisFault("Thread interuptted", e1);
             }
-            
-            
-
-            
 
             ServerSocket serverSoc = null;
             serverSoc = new ServerSocket(Constants.TESTING_PORT);
-            reciver = new SimpleHTTPServer(er,serverSoc);
+            reciver = new SimpleHTTPServer(er, serverSoc);
             Thread thread = new Thread(reciver);
             thread.setDaemon(true);
 
@@ -93,8 +90,29 @@
             count--;
         }
     }
-    
-    public static ConfigurationContext getConfigurationContext(){
+
+    public static ConfigurationContext getConfigurationContext() {
         return reciver.getSystemContext();
     }
+
+    public static ServiceContext createAdressedEnabledClientSide(ServiceDescription service)
+        throws AxisFault {
+        DeploymentEngine deploymentEngine = new DeploymentEngine();
+        File file = new File(UtilServer.TESTING_REPOSITORY + "/modules/addressing.mar");
+        TestCase.assertTrue(file.exists());
+        ModuleDescription moduleDesc = deploymentEngine.buildModule(file);
+
+        ConfigurationContextFactory efac = new ConfigurationContextFactory();
+        ConfigurationContext sysContext = efac.buildClientEngineContext(null);
+        new ConfigurationContext(new AxisConfigurationImpl());
+        sysContext.getEngineConfig().addMdoule(moduleDesc);
+        sysContext.getEngineConfig().engageModule(moduleDesc.getName());
+
+        sysContext.getEngineConfig().addService(service);
+        //Utils.resolvePhases(sysContext.getEngineConfig(), service);
+        ServiceContext serviceContext = sysContext.createServiceContext(service.getName());
+        return serviceContext;
+
+    }
+
 }

Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilsTCPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilsTCPServer.java?rev=171100&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilsTCPServer.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilsTCPServer.java Fri May 20 04:11:07 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.integration;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.ConfigurationContextFactory;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.transport.tcp.TCPServer;
+
+public class UtilsTCPServer {
+    private static int count = 0;
+    private static TCPServer reciver;
+
+    private static ConfigurationContext configurationContext;
+    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 synchronized void deployService(ServiceDescription service) throws AxisFault {
+        configurationContext.getEngineConfig().addService(service);
+
+    }
+
+    public static synchronized void unDeployService(QName service) throws AxisFault {
+        configurationContext.getEngineConfig().removeService(service);
+    }
+
+    public static synchronized void start() throws Exception {
+        if (count == 0) {
+
+            //start tcp server
+
+            ConfigurationContextFactory erfac = new ConfigurationContextFactory();
+            File file = new File(TESTING_REPOSITORY);
+            if (!file.exists()) {
+                throw new Exception("repository directory does not exists");
+            }
+            configurationContext = erfac.buildEngineContext(file.getAbsolutePath());
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e1) {
+                throw new AxisFault("Thread interuptted", e1);
+            }
+
+            reciver = new TCPServer(UtilServer.TESTING_PORT, configurationContext);
+            reciver.start();
+
+        }
+        count++;
+    }
+
+    public static synchronized void stop() {
+        try {
+            if (count == 1) {
+                reciver.stop();
+                count = 0;
+                System.out.print("Server stopped .....");
+            } else {
+                count--;
+            }
+        } catch (AxisFault e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    public static ConfigurationContext getConfigurationContext() {
+        return configurationContext;
+    }
+}