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/26 17:26:31 UTC

svn commit: r201866 [1/2] - in /webservices/axis/trunk/java: modules/core/src/org/apache/axis/ modules/core/src/org/apache/axis/clientapi/ modules/core/src/org/apache/axis/context/ modules/core/src/org/apache/axis/engine/ modules/core/src/org/apache/ax...

Author: hemapani
Date: Sun Jun 26 08:26:29 2005
New Revision: 201866

URL: http://svn.apache.org/viewcvs?rev=201866&view=rev
Log:
1)make everything works on the in and out put streams now ready for MTOM to be integrated
2) Incoperate the chuncking support written by Gayan
3) Documentation updates

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedInputStream.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedOutputStream.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPOutputStream.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawXMLChunckedTest.java
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/chuncking-enabled-axis2.xml
    webservices/axis/trunk/java/xdocs/http-transport.html
    webservices/axis/trunk/java/xdocs/images/faq/
    webservices/axis/trunk/java/xdocs/images/faq/1.jpg   (with props)
    webservices/axis/trunk/java/xdocs/mail-transport.html
    webservices/axis/trunk/java/xdocs/rest-ws.html
    webservices/axis/trunk/java/xdocs/tcp-transport.html
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
    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/ListenerManager.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/TwoChannelBasedSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/ConfigurationContextFactory.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfiguration.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.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/HTTPConstants.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/local/LocalTransportSender.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/tcp/TCPTransportSender.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/HTTPTrasportHeaderParsingTest.java
    webservices/axis/trunk/java/modules/samples/maven.xml
    webservices/axis/trunk/java/modules/samples/test/org/apache/axis/integration/UtilServer.java
    webservices/axis/trunk/java/xdocs/faq.html
    webservices/axis/trunk/java/xdocs/userguide.html

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java Sun Jun 26 08:26:29 2005
@@ -167,7 +167,8 @@
     public static interface SOAP {
         public static final String SOAP_12_CONTENT_TYPE = "application/soap+xml";
         public static final String SOAP_11_CONTENT_TYPE = "text/xml";
-        public static final String MTOM_CONTENT_TYPE = "text/xml";
+        //TODO
+        public static final String MTOM_CONTENT_TYPE = "multipart/related";
     }
 
     public static interface Configuration {
@@ -181,8 +182,12 @@
     public static final String CONTAINER_MANAGED = "ContainerManaged";
     public static final String RESPONSE_WRITTEN = "CONTENT_WRITTEN";
     
-    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_PATH = "target/test-resources/"; 
+    //public static final String TESTING_PATH = "modules/samples/target/test-resources/";
+   
+   public static final String TESTING_REPOSITORY = TESTING_PATH+ "samples";
+   
+   
     
     
     public static interface REST_WITH_GET{

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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -65,27 +65,27 @@
 
         engine.send(msgctx);
 
-        MessageContext response =
-            new MessageContext(msgctx.getSystemContext(),
-                msgctx.getSessionContext(),
-                msgctx.getTransportIn(),
-                msgctx.getTransportOut());
-        response.setProperty(
-            MessageContext.TRANSPORT_IN,
-            msgctx.getProperty(MessageContext.TRANSPORT_IN));
-        response.setServerSide(false);
-        response.setOperationContext(msgctx.getOperationContext());
-        response.setServiceContext(msgctx.getServiceContext());
-
-        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 (resenvelope!= null && resenvelope.getBody().hasFault()) {
-                throw new AxisFault(resenvelope.getBody().getFault().getException());
-            }
-        }
+//        MessageContext response =
+//            new MessageContext(msgctx.getSystemContext(),
+//                msgctx.getSessionContext(),
+//                msgctx.getTransportIn(),
+//                msgctx.getTransportOut());
+//        response.setProperty(
+//            MessageContext.TRANSPORT_IN,
+//            msgctx.getProperty(MessageContext.TRANSPORT_IN));
+//        response.setServerSide(false);
+//        response.setOperationContext(msgctx.getOperationContext());
+//        response.setServiceContext(msgctx.getServiceContext());
+//
+//        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 (resenvelope!= 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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -330,37 +330,37 @@
         }
     }
 
-    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.checkForMessage(response, serviceContext.getEngineContext());
-            } else if (Constants.TRANSPORT_TCP.equals(listenerTransport)) {
-                InputStream inStream = (InputStream) response.getProperty(MessageContext.TRANSPORT_IN);
-                response.setProperty(MessageContext.TRANSPORT_IN,null);
-                Reader in = new InputStreamReader(inStream);
-
-                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_IN
-                            + " set ");
-                }
-            }
-        } catch (XMLStreamException e) {
-            throw new AxisFault(e);
-        } catch (FactoryConfigurationError e) {
-            throw new AxisFault(e);
-        }
-        return resenvelope;
-    }
+//    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.handleHTTPRequest(response, serviceContext.getEngineContext());
+//            } else if (Constants.TRANSPORT_TCP.equals(listenerTransport)) {
+//                InputStream inStream = (InputStream) response.getProperty(MessageContext.TRANSPORT_IN);
+//                response.setProperty(MessageContext.TRANSPORT_IN,null);
+//                Reader in = new InputStreamReader(inStream);
+//
+//                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_IN
+//                            + " 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) {
@@ -399,7 +399,7 @@
     }
     
     public void close() throws AxisFault{
-        senderTransport.getSender().cleanUp();
+        //senderTransport.getSender().cleanUp();
         ListenerManager.stop(listenerTransport.getName().getLocalPart());
      }
 

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/ListenerManager.java Sun Jun 26 08:26:29 2005
@@ -49,7 +49,7 @@
             TransportInDescription tranportIn =
                 configurationContext.getAxisConfiguration().getTransportIn(new QName(transport));
             TransportListener listener = tranportIn.getReciever();
-            listener.init(configurationContext, tranportIn);
+//            listener.init(configurationContext, tranportIn);
             listener.start();
             tsState = new TransportListnerState(listener);
             listeners.put(transport,tsState);

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/TwoChannelBasedSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/TwoChannelBasedSender.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/TwoChannelBasedSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/TwoChannelBasedSender.java Sun Jun 26 08:26:29 2005
@@ -32,6 +32,7 @@
 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.TransportUtils;
 import org.apache.axis.transport.http.HTTPTransportReceiver;
 
 
@@ -56,30 +57,30 @@
         response.setServiceContext(msgctx.getServiceContext());
 
         
-        SOAPEnvelope resenvelope = null;
-                try {
-                    //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
-                    if (Constants.TRANSPORT_HTTP.equals(transportIn.getName().getLocalPart())) {
-                        HTTPTransportReceiver receiver = new HTTPTransportReceiver();
-                        resenvelope =
-                            receiver.checkForMessage(response,msgctx.getSystemContext());
-                    } else if (Constants.TRANSPORT_TCP.equals(transportIn.getName().getLocalPart())) {
-                        InputStream inStream = (InputStream) response.getProperty(MessageContext.TRANSPORT_IN);
-                        response.setProperty(MessageContext.TRANSPORT_IN,null);
-                        Reader in = new InputStreamReader(inStream);
-                        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_IN + " set ");
-                        }
-                    }
-                } catch (XMLStreamException e) {
-                    throw new AxisFault(e);
-                } catch (FactoryConfigurationError e) {
-                    throw new AxisFault(e);
-                }
+        SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(response);
+//                try {
+//                    //TODO Fix this we support only the HTTP Sync cases, so we hardcode this
+//                    if (Constants.TRANSPORT_HTTP.equals(transportIn.getName().getLocalPart())) {
+//                        HTTPTransportReceiver receiver = new HTTPTransportReceiver();
+//                        resenvelope =
+//                            receiver.checkForMessage(response,msgctx.getSystemContext());
+//                    } else if (Constants.TRANSPORT_TCP.equals(transportIn.getName().getLocalPart())) {
+//                        InputStream inStream = (InputStream) response.getProperty(MessageContext.TRANSPORT_IN);
+//                        response.setProperty(MessageContext.TRANSPORT_IN,null);
+//                        Reader in = new InputStreamReader(inStream);
+//                        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_IN + " set ");
+//                        }
+//                    }
+//                } catch (XMLStreamException e) {
+//                    throw new AxisFault(e);
+//                } catch (FactoryConfigurationError e) {
+//                    throw new AxisFault(e);
+//                }
                 
 
 

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/ConfigurationContextFactory.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/ConfigurationContextFactory.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/ConfigurationContextFactory.java Sun Jun 26 08:26:29 2005
@@ -11,12 +11,16 @@
 import org.apache.axis.deployment.DeploymentException;
 import org.apache.axis.description.ModuleDescription;
 import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.description.TransportInDescription;
+import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.engine.AxisConfiguration;
 import org.apache.axis.engine.AxisConfigurationImpl;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.modules.Module;
 import org.apache.axis.phaseresolver.PhaseException;
 import org.apache.axis.phaseresolver.PhaseResolver;
+import org.apache.axis.transport.TransportListener;
+import org.apache.axis.transport.TransportSender;
 
 /**
  * Created by IntelliJ IDEA.
@@ -26,13 +30,15 @@
  */
 public class ConfigurationContextFactory {
 
-    public ConfigurationContext buildConfigurationContext(String RepositaryName) throws DeploymentException {
+    public ConfigurationContext buildConfigurationContext(String RepositaryName)
+        throws DeploymentException {
         ConfigurationContext configurationContext = null;
         try {
-            DeploymentEngine deploymentEngine = new DeploymentEngine(RepositaryName);
+            DeploymentEngine deploymentEngine =
+                new DeploymentEngine(RepositaryName);
             AxisConfiguration configuration = deploymentEngine.load();
             PhaseResolver phaseResolver = new PhaseResolver(configuration);
-            configurationContext = new ConfigurationContext(configuration) ;
+            configurationContext = new ConfigurationContext(configuration);
             phaseResolver.buildTranspotsChains();
             initModules(configurationContext);
         } catch (AxisFault axisFault) {
@@ -41,14 +47,17 @@
         return configurationContext;
     }
 
-    public ConfigurationContext buildClientConfigurationContext(String axis2home) throws DeploymentException {
+    public ConfigurationContext buildClientConfigurationContext(String axis2home)
+        throws DeploymentException {
         ConfigurationContext engineContext = null;
         try {
-            AxisConfiguration configuration = new DeploymentEngine().loadClient(axis2home);
+            AxisConfiguration configuration =
+                new DeploymentEngine().loadClient(axis2home);
             PhaseResolver phaseResolver = new PhaseResolver(configuration);
-            engineContext = new ConfigurationContext(configuration) ;
+            engineContext = new ConfigurationContext(configuration);
             phaseResolver.buildTranspotsChains();
             initModules(engineContext);
+            initTransports(engineContext);
         } catch (AxisFault axisFault) {
             throw new DeploymentException(axisFault.getMessage());
         }
@@ -63,12 +72,16 @@
      * @throws DeploymentException
      */
 
-   private void initModules(ConfigurationContext context) throws DeploymentException {
+    private void initModules(ConfigurationContext context)
+        throws DeploymentException {
         try {
-            HashMap modules = ((AxisConfigurationImpl) context.getAxisConfiguration()).getModules();
+            HashMap modules =
+                ((AxisConfigurationImpl) context.getAxisConfiguration())
+                    .getModules();
             Collection col = modules.values();
             for (Iterator iterator = col.iterator(); iterator.hasNext();) {
-                ModuleDescription axismodule = (ModuleDescription) iterator.next();
+                ModuleDescription axismodule =
+                    (ModuleDescription) iterator.next();
                 Module module = axismodule.getModule();
                 if (module != null) {
                     module.init(context.getAxisConfiguration());
@@ -79,14 +92,20 @@
         }
     }
 
-    public static void createChains(ServiceDescription service, AxisConfiguration configurationContextVal , ArrayList modules) throws PhaseException {
+    public static void createChains(
+        ServiceDescription service,
+        AxisConfiguration configurationContextVal,
+        ArrayList modules)
+        throws PhaseException {
         try {
-            PhaseResolver reolve = new PhaseResolver(configurationContextVal, service);
+            PhaseResolver reolve =
+                new PhaseResolver(configurationContextVal, service);
             reolve.buildchains();
             for (int i = 0; i < modules.size(); i++) {
                 QName qName = (QName) modules.get(i);
-                ModuleDescription moduledecs = configurationContextVal.getModule(qName);
-                reolve.engageModuleToService(service,moduledecs);
+                ModuleDescription moduledecs =
+                    configurationContextVal.getModule(qName);
+                reolve.engageModuleToService(service, moduledecs);
             }
         } catch (PhaseException e) {
             throw new PhaseException(e.getMessage());
@@ -94,4 +113,34 @@
             throw new PhaseException(axisFault.getMessage());
         }
     }
+
+    public void initTransports(ConfigurationContext configContext)
+        throws AxisFault {
+        AxisConfiguration axisConf = configContext.getAxisConfiguration();
+        
+        //Initzialize Transport Ins
+        HashMap transportIns = axisConf.getTransportsIn();
+        Iterator values = transportIns.values().iterator();
+        while (values.hasNext()) {
+            TransportInDescription transportIn =
+                (TransportInDescription) values.next();
+            TransportListener listener = transportIn.getReciever();
+            if (listener != null) {
+                listener.init(configContext, transportIn);
+            }
+        }
+        //Initzialize Transport Outs
+        HashMap transportOuts = axisConf.getTransportsOut();
+        values = transportOuts.values().iterator();
+        while (values.hasNext()) {
+            TransportOutDescription transportOut =
+                (TransportOutDescription) values.next();
+            TransportSender sender = transportOut.getSender();
+            if (sender != null) {
+                sender.init(configContext, transportOut);
+            }
+        }
+
+    }
+
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfiguration.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfiguration.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfiguration.java Sun Jun 26 08:26:29 2005
@@ -97,13 +97,6 @@
       */
      public void engageModule(QName moduleref) throws AxisFault ;
 
-    /**
-     * Method getTransports
-     *
-     * @return
-     * @throws AxisFault
-     */
-    public HashMap getTransports() throws AxisFault;
 
     /**
      *  This returns 

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisConfigurationImpl.java Sun Jun 26 08:26:29 2005
@@ -46,10 +46,7 @@
      */
     private final HashMap services = new HashMap();
 
-    /**
-     * Field transports
-     */
-    private final HashMap transports = new HashMap();
+
 
     private final HashMap transportsIn = new HashMap();
 
@@ -221,22 +218,13 @@
     }
 
     public HashMap getTransportsIn() {
-        return transports;
+        return transportsIn;
     }
 
     public HashMap getTransportsOut() {
         return transportsOut;
     }
 
-    /**
-     * Method getTransports
-     *
-     * @return
-     * @throws AxisFault
-     */
-    public HashMap getTransports() throws AxisFault {
-        return transports;
-    }
 
     public void setInPhases(ArrayList inPhases) {
         this.inPhases = inPhases;

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/AbstractTransportSender.java Sun Jun 26 08:26:29 2005
@@ -19,13 +19,14 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axis.Constants;
 import org.apache.axis.addressing.AddressingConstants;
 import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.ConfigurationContext;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.description.HandlerDescription;
+import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.handlers.AbstractHandler;
 import org.apache.axis.om.OMElement;
@@ -57,6 +58,10 @@
     public AbstractTransportSender() {
         init(new HandlerDescription(NAME));
     }
+    
+    public void init(ConfigurationContext confContext,TransportOutDescription transportOut)throws AxisFault{
+    
+    }
 
     /**
      * Method invoke
@@ -83,21 +88,27 @@
         }
 
         if (epr != null) {
-            out = openTheConnection(epr);
-            startSendWithToAddress(msgContext, out);
+            out = openTheConnection(epr,msgContext);
+            OutputStream newOut = startSendWithToAddress(msgContext, out);
+            if(newOut != null){
+                out = newOut;
+            }
             writeMessage(msgContext, out);
-            finalizeSendWithToAddress(msgContext);
+            finalizeSendWithToAddress(msgContext,out);
         } else {
             out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
             if (out != null) {
                 startSendWithOutputStreamFromIncomingConnection(msgContext, out);
                 writeMessage(msgContext, out);
-                finalizeSendWithOutputStreamFromIncomingConnection(msgContext);
+                finalizeSendWithOutputStreamFromIncomingConnection(msgContext,out);
             } else {
                 throw new AxisFault("Both the TO and Property MessageContext.TRANSPORT_WRITER is Null, No where to send");
             }
         }
-        msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+        //TODO fix this, we do not set the value if the operation context is not avalible
+        if(msgContext.getOperationContext()!= null){
+            msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);        
+        }
     }
 
     public void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
@@ -115,7 +126,6 @@
                 outputMessage.serialize(omOutput);
                 omOutput.flush();
                 out.flush();
-
             } catch (Exception e) {
                 throw new AxisFault("Stream error", e);
             }
@@ -124,20 +134,20 @@
         }
     }
 
-    public abstract void startSendWithToAddress(MessageContext msgContext, OutputStream out)
+    public abstract OutputStream startSendWithToAddress(MessageContext msgContext, OutputStream out)
             throws AxisFault;
 
-    public abstract void finalizeSendWithToAddress(MessageContext msgContext)
+    public abstract void finalizeSendWithToAddress(MessageContext msgContext,OutputStream out)
             throws AxisFault;
 
 
-    public abstract void startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
+    public abstract OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
                                                                          OutputStream out)
             throws AxisFault;
 
-    public abstract void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext)
+    public abstract void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,OutputStream out)
             throws AxisFault;
 
 
-    protected abstract OutputStream openTheConnection(EndpointReference epr) throws AxisFault;
+    protected abstract OutputStream openTheConnection(EndpointReference epr,MessageContext msgctx) throws AxisFault;
 }

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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -15,6 +15,9 @@
  */
 package org.apache.axis.transport;
 
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.Handler;
 
@@ -22,5 +25,6 @@
  * Interface TransportSender
  */
 public interface TransportSender extends Handler {
-    public void cleanUp() throws AxisFault;
+    public void cleanUp(MessageContext msgContext) throws AxisFault;
+    public void init(ConfigurationContext confContext,TransportOutDescription transportOut)throws AxisFault;
 }

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java?rev=201866&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java Sun Jun 26 08:26:29 2005
@@ -0,0 +1,81 @@
+/*
+ * 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.transport;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis.Constants;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.impl.llom.builder.StAXBuilder;
+import org.apache.axis.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.soap.impl.llom.soap11.SOAP11Factory;
+
+
+public class TransportUtils {
+    public static SOAPEnvelope createSOAPMessage(MessageContext msgContext)
+        throws AxisFault {
+
+        InputStream inStream =
+            (InputStream) msgContext.getProperty(MessageContext.TRANSPORT_IN);
+        msgContext.setProperty(MessageContext.TRANSPORT_IN, null);
+        return createSOAPMessage(msgContext, inStream);
+    }
+
+    public static SOAPEnvelope createSOAPMessage(
+        MessageContext msgContext,
+        InputStream inStream)
+        throws AxisFault {
+        try {
+            //Check for the REST behaviour, if you desire rest beahaviour
+            //put a <parameter name="doREST" value="true"/> at the server.xml/client.xml file
+            Object doREST =
+                msgContext.getProperty(Constants.Configuration.DO_REST);
+            Reader reader = new InputStreamReader(inStream);
+            
+            char[] chars = new char[1024];
+            int read = 100;
+            
+            XMLStreamReader xmlreader =
+                XMLInputFactory.newInstance().createXMLStreamReader(reader);
+                
+            StAXBuilder builder = null;
+            SOAPEnvelope envelope = null;
+            if (doREST != null && "true".equals(doREST)) {
+                SOAPFactory soapFactory = new SOAP11Factory();
+                builder = new StAXOMBuilder(xmlreader);
+                builder.setOmbuilderFactory(soapFactory);
+                envelope = soapFactory.getDefaultEnvelope();
+                envelope.getBody().addChild(builder.getDocumentElement());
+            } else {
+                builder = new StAXSOAPModelBuilder(xmlreader);
+                envelope = (SOAPEnvelope) builder.getDocumentElement();
+            }
+            return envelope;
+        } catch (Exception e) {
+            throw new AxisFault(e.getMessage(), e);
+        }
+    }
+
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedInputStream.java?rev=201866&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedInputStream.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedInputStream.java Sun Jun 26 08:26:29 2005
@@ -0,0 +1,183 @@
+/*
+ * 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.http;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ *
+ * @author Rick Rineholt 
+ */
+
+public class ChunkedInputStream extends java.io.FilterInputStream {
+    protected long chunkSize = 0l;
+    protected volatile boolean closed = false;
+    private static final int maxCharLong = (Long.toHexString(Long.MAX_VALUE))
+      .toString().length();
+    private ChunkedInputStream () {
+        super(null);
+    }
+
+    public ChunkedInputStream (InputStream is) {
+        super(is);
+    }
+
+    public int read()
+        throws IOException {
+        byte[] d = new byte[1];
+        int rc = read(d, 0, 1);
+
+        return rc > 0 ? (d[0] & 0xFF) : rc;
+    }
+
+    public int read(byte[] b)
+        throws IOException {
+        return read(b, 0, b.length);
+    }
+
+    public synchronized int read(byte[] b,
+        int off,
+        int len)
+        throws IOException {
+        if (closed) return -1;
+        int cs = (int) Math.min(Integer.MAX_VALUE, chunkSize);
+        int totalread = 0;
+        int bytesread = 0; 
+
+        try {
+            do {
+                if (chunkSize < 1L) {
+                    if (0l == getChunked()) {
+                        if (totalread == 0) return -1;
+                        else return totalread;
+                    }
+                }
+                bytesread = in.read(b, off + totalread, Math.min(len - totalread,
+                                (int) Math.min(chunkSize, Integer.MAX_VALUE)));
+                if (bytesread > 0) {
+                    totalread += bytesread;
+                    chunkSize -= bytesread;
+                }
+            }
+            while (len - totalread > 0 && bytesread > -1);
+        } catch (IOException e) {
+            closed = true;
+            throw e;
+        }
+        return  totalread;
+    }
+
+    public long skip(final long n)
+        throws IOException {
+        if (closed) return 0;
+        long skipped = 0l;
+        byte[] b = new byte[1024];
+        int bread = -1;
+
+        do {
+            bread = read(b, 0, b.length);
+            if (bread > 0) skipped += bread;
+        }
+        while (bread != -1 && skipped < n);
+        return skipped;
+    }
+
+    public int available()
+        throws IOException {
+        if (closed) return 0;
+        int rc = (int) Math.min(chunkSize, Integer.MAX_VALUE);
+
+        return  Math.min(rc, in.available());
+    }
+              
+    protected long getChunked()throws IOException {
+        //StringBuffer buf= new StringBuffer(1024);
+        byte[]buf = new byte[maxCharLong + 2];
+        int bufsz = 0;
+ 
+        chunkSize = -1L; 
+        int c = -1;
+
+        do {
+            c = in.read();
+            if (c > -1) {
+                if (c != '\r' && c != '\n' && c != ' ' && c != '\t') {
+                    buf[bufsz++] = ((byte) c);
+                }
+            }
+        }
+        while (c > -1 && (c != '\n' || bufsz == 0) && bufsz < buf.length);
+        if (c < 0) {
+            closed = true;
+        }
+        String sbuf = new String(buf, 0, bufsz);
+
+        if (bufsz > maxCharLong) {
+            closed = true;
+            throw new IOException("Chunked input stream failed to receive valid chunk size:" + sbuf);
+        }
+        try {
+            chunkSize = Long.parseLong(sbuf, 16);
+        } catch (NumberFormatException ne) {
+            closed = true;
+            throw new IOException("'" + sbuf + "' " + ne.getMessage());
+        }
+        if (chunkSize < 1L) closed = true;                  
+        if (chunkSize != 0L && c < 0) {
+            //If chunk size is zero try and be tolerant that there maybe no cr or lf at the end.
+            throw new IOException("HTTP Chunked stream closed in middle of chunk.");
+        }
+        if (chunkSize < 0L) throw new IOException("HTTP Chunk size received " +
+            chunkSize + " is less than zero.");
+        return chunkSize;                  
+    }
+
+    public void close() throws IOException {
+   
+        synchronized (this) {
+            if (closed) return;
+            closed = true;
+        }
+
+        byte[] b = new byte[1024];
+        int bread = -1;
+
+        do {
+            bread = read(b, 0, b.length);
+        }
+        while (bread != -1);
+    }
+
+    /*
+     public void mark(int readlimit)
+     {
+     
+     }
+     */
+
+    public void reset()
+        throws IOException {
+        throw new IOException("Don't support marked streams");
+    }
+
+    public boolean markSupported() {
+        return false;
+    }
+
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedOutputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedOutputStream.java?rev=201866&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedOutputStream.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/ChunkedOutputStream.java Sun Jun 26 08:26:29 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.http;
+
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+
+/**
+ *
+ * @author Rick Rineholt 
+ */
+public class ChunkedOutputStream extends FilterOutputStream {
+
+    boolean eos = false;
+
+    private ChunkedOutputStream() {
+        super(null);
+    }
+
+    public ChunkedOutputStream(OutputStream os) {
+        super(os);
+    }
+
+    public void write(int b)
+        throws IOException {
+        write(new byte[] {(byte) b}, 0, 1);
+    }
+
+    public void write(byte[] b)
+            
+        throws IOException {
+        write(b, 0, b.length);
+    }
+
+    static final byte[] crlf = "\r\n".getBytes();
+
+    public void write(byte[] b,
+        int off,
+        int len)
+        throws IOException {
+        if (len == 0) return;
+           
+        out.write((Integer.toHexString(len)).getBytes());
+        out.write(crlf);
+        out.write(b, off, len);
+        out.write(crlf);
+    }
+
+    /*
+     public void flush()
+     throws IOException {
+     out.flush();
+     }
+     */
+
+    public void eos()throws IOException {
+        synchronized (this) {
+            if (eos) return;
+            eos = true;
+        }
+        out.write("0\r\n\r\n".getBytes());
+        out.flush();
+    }
+    
+    public void close()
+        throws IOException {
+        eos();
+        out.close();
+    }
+
+}

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPConstants.java?rev=201866&r1=201865&r2=201866&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPConstants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPConstants.java Sun Jun 26 08:26:29 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.axis.transport.http;
 
+import java.io.UnsupportedEncodingException;
+
 /**
  * HTTP protocol and message context constants.
  */
@@ -382,5 +384,30 @@
      * Field HTTP_REQ_TYPE
      */
     public static final String HTTP_REQ_TYPE = "HTTP_REQ_TYPE";
+    
+
+       /**
+        * Default content encoding chatset
+        */
+         public static final String HTTP_ELEMENT_CHARSET = "US-ASCII";
+
+    /**
+       * Method getBytes
+       * @param data
+       * @return
+       */
+       public static byte[] getBytes(final String data) {
+          if (data == null) {
+              throw new IllegalArgumentException("Parameter may not be null");
+          }
+
+          try {
+              return data.getBytes(HTTP_ELEMENT_CHARSET);
+          } catch (UnsupportedEncodingException e){
+
+          }
+              return data.getBytes();
+          }
+
     
 }

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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -17,9 +17,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.Reader;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -27,9 +25,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-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;
@@ -38,12 +33,8 @@
 import org.apache.axis.description.OperationDescription;
 import org.apache.axis.description.ServiceDescription;
 import org.apache.axis.engine.AxisFault;
-import org.apache.axis.om.impl.llom.builder.StAXBuilder;
-import org.apache.axis.om.impl.llom.builder.StAXOMBuilder;
 import org.apache.axis.soap.SOAPEnvelope;
-import org.apache.axis.soap.SOAPFactory;
-import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.axis.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis.transport.TransportUtils;
 import org.apache.axis.util.Utils;
 
 /**
@@ -78,7 +69,7 @@
     /**
      * Field buf
      */
-    private char[] buf = new char[1024];
+    private byte[] buf = new byte[1024];
 
     /**
      * Field index
@@ -95,41 +86,41 @@
      */
     private boolean done = false;
 
+
     /**
      * Method invoke
      *
      * @param msgContext
      * @throws AxisFault
      */
-    public SOAPEnvelope checkForMessage(
-        MessageContext msgContext,
-        ConfigurationContext engineContext)
+    public SOAPEnvelope handleHTTPRequest(
+        MessageContext msgContext,InputStream inStream, Map map)
         throws AxisFault {
         SOAPEnvelope soapEnvelope = null;
 
-        InputStream inStream = (InputStream) msgContext.getProperty(MessageContext.TRANSPORT_IN);
-        msgContext.setProperty(MessageContext.TRANSPORT_IN, null);
-        Reader in = new InputStreamReader(inStream);
-
-        if (in != null) {
-            boolean serverSide = msgContext.isServerSide();
-            Map map = parseTheHeaders(in, serverSide);
 
-            msgContext.setWSAAction((String) map.get(HTTPConstants.HEADER_SOAP_ACTION));
+
+            msgContext.setWSAAction(
+                (String) map.get(HTTPConstants.HEADER_SOAP_ACTION));
             Utils.configureMessageContextForHTTP(
                 (String) map.get(HTTPConstants.HEADER_CONTENT_TYPE),
                 msgContext.getWSAAction(),
                 msgContext);
 
             String requestURI = (String) map.get(HTTPConstants.REQUEST_URI);
-            msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, requestURI));
+            msgContext.setTo(
+                new EndpointReference(AddressingConstants.WSA_TO, requestURI));
 
-            if (HTTPConstants.RESPONSE_ACK_CODE_VAL.equals(map.get(HTTPConstants.RESPONSE_CODE))) {
+            if (HTTPConstants
+                .RESPONSE_ACK_CODE_VAL
+                .equals(map.get(HTTPConstants.RESPONSE_CODE))) {
                 msgContext.setProperty(
                     MessageContext.TRANSPORT_SUCCEED,
                     HTTPConstants.RESPONSE_ACK_CODE_VAL);
                 return null;
-            } else if (HTTPConstants.HEADER_GET.equals(map.get(HTTPConstants.HTTP_REQ_TYPE))) {
+            } else if (
+                HTTPConstants.HEADER_GET.equals(
+                    map.get(HTTPConstants.HTTP_REQ_TYPE))) {
                 SOAPEnvelope envelope =
                     HTTPTransportUtils.createEnvelopeFromGetRequest(
                         requestURI,
@@ -141,109 +132,17 @@
                         msgContext.getSystemContext());
                     return null;
                 } else {
-                    msgContext.setProperty(Constants.Configuration.DO_REST, Constants.VALUE_TRUE);
+                    msgContext.setProperty(
+                        Constants.Configuration.DO_REST,
+                        Constants.VALUE_TRUE);
                     return envelope;
                 }
 
             } else {
-                //getServiceLookUp(requestURI)));
-
-                // TODO see is it a Service request e.g. WSDL, list ....
-                // TODO take care of the other HTTPHeaders
-                try {
-                    //Check for the REST behaviour, if you desire rest beahaviour
-                    //put a <parameter name="doREST" value="true"/> at the server.xml/client.xml file
-                    Object doREST = msgContext.getProperty(Constants.Configuration.DO_REST);
-                    XMLStreamReader xmlreader =
-                        XMLInputFactory.newInstance().createXMLStreamReader(in);
-                    StAXBuilder builder = null;
-                    SOAPEnvelope envelope = null;
-                    if (doREST != null && "true".equals(doREST)) {
-                        SOAPFactory soapFactory = new SOAP11Factory();
-                        builder = new StAXOMBuilder(xmlreader);
-                        builder.setOmbuilderFactory(soapFactory);
-                        envelope = soapFactory.getDefaultEnvelope();
-                        envelope.getBody().addChild(builder.getDocumentElement());
-                    } else {
-                        builder = new StAXSOAPModelBuilder(xmlreader);
-                        envelope = (SOAPEnvelope) builder.getDocumentElement();
-                    }
-                    return envelope;
-                } catch (Exception e) {
-                    throw new AxisFault(e.getMessage(), e);
-                }
-
+                return TransportUtils.createSOAPMessage(msgContext,inStream);
             }
-        } else {
-            throw new AxisFault("Input reader not found");
-        }
     }
 
-    /**
-     * This is to be called when we are certain that the message being processed is a SOAP message
-     * @param msgContext
-     * @param engineContext
-     * @param parsedHeaders
-     * @return
-     * @throws AxisFault
-     */
-    public SOAPEnvelope checkForMessage(
-        MessageContext msgContext,
-        ConfigurationContext engineContext,
-        Map parsedHeaders)
-        throws AxisFault {
-
-        SOAPEnvelope soapEnvelope = null;
-        InputStream inStream = (InputStream) msgContext.getProperty(MessageContext.TRANSPORT_IN);
-        msgContext.setProperty(MessageContext.TRANSPORT_IN, null);
-        Reader in = new InputStreamReader(inStream);
-
-        if (in != null) {
-            if (HTTPConstants
-                .RESPONSE_ACK_CODE_VAL
-                .equals(parsedHeaders.get(HTTPConstants.RESPONSE_CODE))) {
-                msgContext.setProperty(
-                    MessageContext.TRANSPORT_SUCCEED,
-                    HTTPConstants.RESPONSE_ACK_CODE_VAL);
-                return soapEnvelope;
-            }
-            msgContext.setWSAAction((String) parsedHeaders.get(HTTPConstants.HEADER_SOAP_ACTION));
-            Utils.configureMessageContextForHTTP(
-                (String) parsedHeaders.get(HTTPConstants.HEADER_CONTENT_TYPE),
-                msgContext.getWSAAction(),
-                msgContext);
-
-            String requestURI = (String) parsedHeaders.get(HTTPConstants.REQUEST_URI);
-            msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, requestURI));
-            //getServiceLookUp(requestURI)));
-
-            // TODO see is it a Service request e.g. WSDL, list ....
-            // TODO take care of the other HTTPHeaders
-            try {
-                //Check for the REST behaviour, if you desire rest beahaviour
-                //put a <parameter name="doREST" value="true"/> at the server.xml/client.xml file
-                Object doREST = msgContext.getProperty(Constants.Configuration.DO_REST);
-                XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
-                StAXBuilder builder = null;
-                SOAPEnvelope envelope = null;
-                if (doREST != null && "true".equals(doREST)) {
-                    SOAPFactory soapFactory = new SOAP11Factory();
-                    builder = new StAXOMBuilder(xmlreader);
-                    builder.setOmbuilderFactory(soapFactory);
-                    envelope = soapFactory.getDefaultEnvelope();
-                    envelope.getBody().addChild(builder.getDocumentElement());
-                } else {
-                    builder = new StAXSOAPModelBuilder(xmlreader);
-                    envelope = (SOAPEnvelope) builder.getDocumentElement();
-                }
-                return envelope;
-            } catch (Exception e) {
-                throw new AxisFault(e.getMessage(), e);
-            }
-        } else {
-            throw new AxisFault("Input reader not found");
-        }
-    }
 
     /**
      * parses following two styles of HTTP stuff
@@ -268,7 +167,8 @@
      * @return
      * @throws AxisFault
      */
-    public HashMap parseTheHeaders(Reader reader, boolean serverSide) throws AxisFault {
+    public HashMap parseTheHeaders(InputStream in, boolean serverSide)
+        throws AxisFault {
         HashMap map = new HashMap();
         try {
             StringBuffer str = new StringBuffer();
@@ -276,14 +176,22 @@
             String key = null;
             String value = null;
             int start = 0;
-            length = readLine(reader, buf);
+            length = readLine(in, buf);
             if (serverSide) {
-                if ((buf[0] == 'P') && (buf[1] == 'O') && (buf[2] == 'S') && (buf[3] == 'T')) {
-                    map.put(HTTPConstants.HTTP_REQ_TYPE, HTTPConstants.HEADER_POST);
+                if ((buf[0] == 'P')
+                    && (buf[1] == 'O')
+                    && (buf[2] == 'S')
+                    && (buf[3] == 'T')) {
+                    map.put(
+                        HTTPConstants.HTTP_REQ_TYPE,
+                        HTTPConstants.HEADER_POST);
                     index = 5;
 
-                } else if ((buf[0] == 'G') && (buf[1] == 'E') && (buf[2] == 'T')) {
-                    map.put(HTTPConstants.HTTP_REQ_TYPE, HTTPConstants.HEADER_GET);
+                } else if (
+                    (buf[0] == 'G') && (buf[1] == 'E') && (buf[2] == 'T')) {
+                    map.put(
+                        HTTPConstants.HTTP_REQ_TYPE,
+                        HTTPConstants.HEADER_GET);
                     index = 4;
 
                 } else {
@@ -310,7 +218,7 @@
             }
             state = BEFORE_SEPERATOR;
             while (!done) {
-                length = readLine(reader, buf);
+                length = readLine(in, buf);
                 if (length <= 0) {
                     throw new AxisFault("Premature end of steam");
                 }
@@ -325,7 +233,7 @@
                                     i++; // ignore next space
                                 }
                             } else {
-                                str.append(buf[i]);
+                                str.append((char) buf[i]);
                             }
                             break;
                         case AFTER_SEPERATOR :
@@ -335,7 +243,7 @@
                                 str = new StringBuffer();
                                 i = length;
                             } else {
-                                str.append(buf[i]);
+                                str.append((char) buf[i]);
                             }
                             break;
 
@@ -351,7 +259,8 @@
                             // case END:
                             // break;
                         default :
-                            throw new AxisFault("Error Occured Unknown state " + state);
+                            throw new AxisFault(
+                                "Error Occured Unknown state " + state);
                     }
                 }
                 state = BEFORE_SEPERATOR;
@@ -477,7 +386,7 @@
         StringBuffer str = new StringBuffer();
         try {
             while ((buf[index] != terminal) && (index < length)) {
-                str.append(buf[index]);
+                str.append((char) buf[index]);
                 index++;
             }
             index++;
@@ -497,7 +406,8 @@
          * @return
          * @throws java.io.IOException
          */
-    protected int readLine(Reader is, char[] b) throws java.io.IOException {
+    protected int readLine(InputStream is, byte[] b)
+        throws java.io.IOException {
         int count = 0, c;
 
         // System.out.println("inside here");
@@ -509,7 +419,7 @@
         int off = 0;
         while (c != -1) {
             if ((c != '\n') && (c != '\r')) {
-                b[off++] = (char) c;
+                b[off++] = (byte) c;
                 count++;
                 c = is.read();
             } else {
@@ -535,7 +445,7 @@
             }
         }
         if (c == -1) {
-            throw new AxisFault("Every line should ends with the \n, unexpected End of stream");
+            throw new AxisFault("Every line should ends with the \\n, unexpected End of stream");
         } else {
             return (count > 0) ? count : -1;
         }
@@ -549,7 +459,6 @@
         try {
             out.write(this.getServicesHTML(configurationContext).getBytes());
             out.flush();
-            out.close();
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -563,7 +472,8 @@
      */
     private String getServicesHTML(ConfigurationContext configurationContext) {
         String temp = "";
-        Map services = configurationContext.getAxisConfiguration().getServices();
+        Map services =
+            configurationContext.getAxisConfiguration().getServices();
         Hashtable erroneousServices =
             configurationContext.getAxisConfiguration().getFaulytServices();
         boolean status = false;
@@ -581,10 +491,14 @@
                 temp += "<h3>" + axisService.getName().getLocalPart() + "</h3>";
                 if (operationsList.size() > 0) {
                     temp += "Available operations <ul>";
-                    for (Iterator iterator1 = operationsList.iterator(); iterator1.hasNext();) {
+                    for (Iterator iterator1 = operationsList.iterator();
+                        iterator1.hasNext();
+                        ) {
                         OperationDescription axisOperation =
                             (OperationDescription) iterator1.next();
-                        temp += "<li>" + axisOperation.getName().getLocalPart() + "</li>";
+                        temp += "<li>"
+                            + axisOperation.getName().getLocalPart()
+                            + "</li>";
                     }
                     temp += "</ul>";
                 } else {
@@ -599,8 +513,11 @@
             status = true;
             Enumeration faultyservices = erroneousServices.keys();
             while (faultyservices.hasMoreElements()) {
-                String faultyserviceName = (String) faultyservices.nextElement();
-                temp += "<h3><font color=\"blue\">" + faultyserviceName + "</font></h3>";
+                String faultyserviceName =
+                    (String) faultyservices.nextElement();
+                temp += "<h3><font color=\"blue\">"
+                    + faultyserviceName
+                    + "</font></h3>";
             }
         }
 

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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -15,131 +15,283 @@
 */
 package org.apache.axis.transport.http;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.URL;
+import java.util.Map;
+
 import org.apache.axis.Constants;
 import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.ConfigurationContext;
 import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.Parameter;
+import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.transport.AbstractTransportSender;
 
-import java.io.*;
-import java.net.*;
-
 /**
  * Class HTTPTransportSender
  */
 public class HTTPTransportSender extends AbstractTransportSender {
-    /**
-     * Field out
-     */
-    protected Writer out;
+    private boolean chuncked = false;
+    private boolean doMTOM = false;
+    private String httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
+    public static final String TRANSPORT_SENDER_INFO = "TRANSPORT_SENDER_INFO";
 
-    /**
-     * Field socket
-     */
-    private Socket socket;
-    private ByteArrayOutputStream outputStream;
- 
     protected void writeTransportHeaders(
-        Writer out,
+        OutputStream out,
         URL url,
         MessageContext msgContext,
         int contentLength)
-        throws IOException {
-        Object soapAction = msgContext.getWSAAction();
-        String soapActionString = soapAction == null ? "" : soapAction.toString();
-        StringBuffer buf = new StringBuffer();
-        buf.append("POST ").append(url.getFile()).append(" HTTP/1.0\n");
-        buf.append("Content-Type: text/xml; charset=utf-8\n");
-        buf.append("Accept: application/soap+xml, application/dime, multipart/related, text/*\n");
-        buf.append("Host: ").append(url.getHost()).append("\n");
-        buf.append("Cache-Control: no-cache\n");
-        buf.append("Pragma: no-cache\n");
-        buf.append("Content-Length: " + contentLength + "\n");
-        if (!this.doREST) {
-            buf.append("SOAPAction: \"" + soapActionString + "\"\n");
+        throws AxisFault {
+        try {
+            Object soapAction = msgContext.getWSAAction();
+            String soapActionString =
+                soapAction == null ? "" : soapAction.toString();
+            StringBuffer buf = new StringBuffer();
+            buf.append(HTTPConstants.HEADER_POST).append(" ");
+            buf.append(url.getFile()).append(" ").append(httpVersion).append("\n");
+            if(doMTOM){
+                //TODO fix this for MTOM
+                buf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": ").append("multipart/related").append("\n");
+            }else{
+                buf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": text/xml; charset=utf-8\n");
+            }
+            
+            buf.append(HTTPConstants.HEADER_ACCEPT).append(": application/soap+xml, application/dime, multipart/related, text/*\n");
+            buf.append(HTTPConstants.HEADER_HOST).append(": ").append(url.getHost()).append("\n");
+            buf.append(HTTPConstants.HEADER_CACHE_CONTROL).append(": no-cache\n");
+            buf.append(HTTPConstants.HEADER_PRAGMA).append(": no-cache\n");
+            if (chuncked) {
+                buf
+                    .append(HTTPConstants.HEADER_TRANSFER_ENCODING)
+                    .append(": ")
+                    .append(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)
+                    .append("\n");
+            } else {
+                buf.append(HTTPConstants.HEADER_CONTENT_LENGTH).append(": " + contentLength + "\n");
+            }
+            if (!this.doREST) {
+                buf.append("SOAPAction: \"" + soapActionString + "\"\n");
+            }
+            buf.append("\n");
+            out.write(buf.toString().getBytes());
+        } catch (IOException e) {
+            throw new AxisFault(e);
         }
-        buf.append("\n");
-        out.write(buf.toString());
     }
 
     public void finalizeSendWithOutputStreamFromIncomingConnection(
-        MessageContext msgContext) {
+        MessageContext msgContext,
+        OutputStream out) {
     }
 
-    public void finalizeSendWithToAddress(MessageContext msgContext)
+    private OutputStream openSocket(MessageContext msgContext)
         throws AxisFault {
+        TransportSenderInfo transportInfo =
+            (TransportSenderInfo) msgContext.getProperty(TRANSPORT_SENDER_INFO);
+
         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();
+                    new InetSocketAddress(
+                        url.getHost(),
+                        url.getPort() == -1 ? 80 : url.getPort());
+                Socket socket = new Socket();
                 socket.connect(add);
-                OutputStream outS = socket.getOutputStream();
-                byte[] bytes = outputStream.toByteArray();
+                transportInfo.url = url;
+                transportInfo.in = socket.getInputStream();
+                transportInfo.out = socket.getOutputStream();
+                transportInfo.socket = socket;
+                return transportInfo.out;
+            } 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");
+        }
+    }
+
+    public void finalizeSendWithToAddress(
+        MessageContext msgContext,
+        OutputStream out)
+        throws AxisFault {
+        try {
+            TransportSenderInfo transportInfo =
+                (TransportSenderInfo) msgContext.getProperty(
+                    TRANSPORT_SENDER_INFO);
+            InputStream in = null;
+            if (chuncked) {
+                ((ChunkedOutputStream) out).eos();
+            } else {
+                openSocket(msgContext);
+                OutputStream outS = transportInfo.out;
+                in = transportInfo.in;
+                byte[] bytes = transportInfo.outputStream.toByteArray();
 
-                Writer realOut = new OutputStreamWriter(outS);
                 //write header to the out put stream
-                writeTransportHeaders(realOut, url, msgContext, bytes.length);
-                realOut.flush();
+                writeTransportHeaders(
+                    outS,
+                    transportInfo.url,
+                    msgContext,
+                    bytes.length);
+                outS.flush();
                 //write the content to the real output stream
                 outS.write(bytes);
-                outS.flush();
+            }
 
-                msgContext.setProperty(
-                    MessageContext.TRANSPORT_IN,socket.getInputStream());
-                msgContext.setProperty(HTTPConstants.SOCKET, socket);
+            transportInfo.socket.shutdownOutput();
+            HTTPTransportReceiver tr = new HTTPTransportReceiver();
+            Map map = tr.parseTheHeaders(transportInfo.in, false);
+            if (!HTTPConstants
+                .RESPONSE_ACK_CODE_VAL
+                .equals(map.get(HTTPConstants.RESPONSE_CODE))) {
+                String transferEncoding =
+                    (String) map.get(HTTPConstants.HEADER_TRANSFER_ENCODING);
+                if (transferEncoding != null
+                    && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
+                        transferEncoding)) {
+                    in = new ChunkedInputStream(transportInfo.in);
+                }
+                msgContext.setProperty(MessageContext.TRANSPORT_IN, in);
+            }
+        } catch (AxisFault e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
 
-                socket.shutdownOutput();
+    }
 
-            } catch (MalformedURLException e) {
-                throw new AxisFault(e.getMessage(), e);
-            } catch (IOException e) {
-                throw new AxisFault(e.getMessage(), e);
-            }
+    protected OutputStream openTheConnection(
+        EndpointReference epr,
+        MessageContext msgctx)
+        throws AxisFault {
+        msgctx.setProperty(TRANSPORT_SENDER_INFO, new TransportSenderInfo());
+        if (chuncked) {
+            return openSocket(msgctx);
         } else {
-            throw new AxisFault("to EPR must be specified");
+            TransportSenderInfo transportInfo =
+                (TransportSenderInfo) msgctx.getProperty(TRANSPORT_SENDER_INFO);
+            transportInfo.outputStream = new ByteArrayOutputStream();
+            return transportInfo.outputStream;
         }
     }
 
-    protected OutputStream openTheConnection(EndpointReference epr) {
-        outputStream = new ByteArrayOutputStream();
-        return outputStream;
+    public OutputStream startSendWithOutputStreamFromIncomingConnection(
+        MessageContext msgContext,
+        OutputStream out)
+        throws AxisFault {
+        //        Object contianerManaged =
+        //            msgContext.getProperty(Constants.CONTAINER_MANAGED);
+        //        if (contianerManaged == null
+        //            || !Constants.VALUE_TRUE.equals(contianerManaged)) {
+        //            try {
+        //                out.write(new String(HTTPConstants.HTTP).getBytes());
+        //                out.write(new String(HTTPConstants.OK).getBytes());
+        //                out.write("\n\n".getBytes());
+        //            } catch (IOException e) {
+        //                throw new AxisFault(e);
+        //            }
+        //        }
+        return out;
     }
 
-    public void startSendWithOutputStreamFromIncomingConnection(
+    public OutputStream startSendWithToAddress(
         MessageContext msgContext,
-    OutputStream out)
+        OutputStream out)
         throws AxisFault {
-        Object contianerManaged = msgContext.getProperty(Constants.CONTAINER_MANAGED);
-        if (contianerManaged == null || !Constants.VALUE_TRUE.equals(contianerManaged)) {
-            try {
-                out.write(new String(HTTPConstants.HTTP).getBytes());
-                out.write(new String(HTTPConstants.OK).getBytes());
-                out.write("\n\n".getBytes());
-            } catch (IOException e) {
-                throw new AxisFault(e);
+        try {
+            Object value = msgContext.getProperty(Constants.Configuration.DO_MTOM);
+            if(Constants.VALUE_TRUE.equals(value)){
+                doMTOM = true;
+            }
+            
+            if (chuncked) {
+                TransportSenderInfo transportInfo =
+                    (TransportSenderInfo) msgContext.getProperty(
+                        TRANSPORT_SENDER_INFO);
+                writeTransportHeaders(out, transportInfo.url, msgContext, -1);
+                out.flush();
+                return new ChunkedOutputStream(out);
+            } else {
+                return out;
             }
+        } catch (IOException e) {
+            throw new AxisFault(e);
         }
-    }
 
-    public void startSendWithToAddress(MessageContext msgContext,OutputStream out) {
     }
 
     /* (non-Javadoc)
      * @see org.apache.axis.transport.TransportSender#cleanUp()
      */
-    public void cleanUp() throws AxisFault {
+    public void cleanUp(MessageContext msgContext) throws AxisFault {
+        TransportSenderInfo transportInfo =
+            (TransportSenderInfo) msgContext.getProperty(TRANSPORT_SENDER_INFO);
         try {
-            if (socket != null) {
-                socket.close();
-                socket = null;
+            if (transportInfo.socket != null) {
+                transportInfo.socket.close();
             }
 
         } catch (IOException e) {
         }
 
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.transport.TransportSender#init(org.apache.axis.context.ConfigurationContext, org.apache.axis.description.TransportOutDescription)
+     */
+    public void init(
+        ConfigurationContext confContext,
+        TransportOutDescription transportOut)
+        throws AxisFault {
+        //<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.0</parameter> or 
+        //<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter> is checked
+        Parameter version =
+            transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
+        if (version != null) {
+            if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
+                this.httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
+                Parameter transferEncoding =
+                    transportOut.getParameter(
+                        HTTPConstants.HEADER_TRANSFER_ENCODING);
+                if (transferEncoding != null
+                    && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
+                        transferEncoding.getValue())) {
+                    this.chuncked = true;
+                }
+            } else if (
+                HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
+                //TODO HTTP1.0 specific parameters
+            } else {
+                throw new AxisFault(
+                    "Parameter "
+                        + HTTPConstants.PROTOCOL_VERSION
+                        + " Can have values only HTTP/1.0 or HTTP/1.1");
+            }
+        }
+
+    }
+
+    private class TransportSenderInfo {
+        public InputStream in;
+        public OutputStream out;
+        public ByteArrayOutputStream outputStream;
+        public URL url;
+        public Socket socket;
     }
 
 }

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPOutputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPOutputStream.java?rev=201866&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPOutputStream.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPOutputStream.java Sun Jun 26 08:26:29 2005
@@ -0,0 +1,112 @@
+/*
+ * 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.http;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.axis.engine.AxisFault;
+
+public class SimpleHTTPOutputStream extends FilterOutputStream {
+    private boolean written = false;
+    private boolean chuncked = false;
+    
+    public SimpleHTTPOutputStream(
+        OutputStream out,boolean chuncked)
+        throws AxisFault {
+        super(out);
+        this.chuncked = chuncked;
+    }
+
+    public void write(byte[] b) throws IOException {
+        if(!written){
+            writeHeader();
+        }
+        out.write(b);
+    }
+
+    /**
+     * @param b
+     * @param off
+     * @param len
+     * @throws java.io.IOException
+     */
+    public void write(byte[] b, int off, int len) throws IOException {
+        if(!written){
+            writeHeader();
+        }
+        out.write(b, off, len);
+    }
+
+    /**
+     * @param b
+     * @throws java.io.IOException
+     */
+    public void write(int b) throws IOException {
+        if(!written){
+            writeHeader();
+        }
+        out.write(b);
+    }
+
+    public void writeHeader() throws IOException{
+        StringBuffer buf = new StringBuffer();
+        if(chuncked){
+            buf.append(new String(HTTPConstants.HEADER_PROTOCOL_11)).append(" ");
+            buf.append(new String(HTTPConstants.OK)).append("\n");
+            buf.append(HTTPConstants.HEADER_TRANSFER_ENCODING).append(": ");
+            buf.append(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED).append("\n");
+            buf.append("\n");
+        }else{
+            buf.append(new String(HTTPConstants.HTTP));
+            buf.append(new String(HTTPConstants.OK)).append("\n");
+            buf.append("\n");
+        }
+        out.write(buf.toString().getBytes());
+        written = true;
+        if(chuncked){
+            out.flush();
+            out =  new ChunkedOutputStream(out);
+        }
+        
+    }
+
+    public void finalize() throws IOException {
+        if (!written) {
+            out.write(new String(HTTPConstants.NOCONTENT).getBytes());
+            written = true;
+        } else{
+            out.flush();
+        }
+        if(chuncked){
+            ((ChunkedOutputStream)out).eos();
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see java.io.OutputStream#close()
+     */
+    public void close() throws IOException {
+        if(!written){
+            finalize();
+        }
+        super.close();
+    }
+
+}

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=201866&r1=201865&r2=201866&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 Sun Jun 26 08:26:29 2005
@@ -18,9 +18,9 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -76,6 +76,9 @@
      * latch to true if stop() is called
      */
     private boolean stopped = false;
+    
+    private boolean chuncked = false;
+    private int port;
 
     public SimpleHTTPServer() {
     }
@@ -157,20 +160,24 @@
 
                         // We do not have any Addressing Headers to put
                         // let us put the information about incoming transport
-                        OutputStream out = socket.getOutputStream();
-                        msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
-                        msgContext.setProperty(MessageContext.TRANSPORT_IN, inStream);
                         HTTPTransportReceiver reciver = new HTTPTransportReceiver();
+                        Map map = reciver.parseTheHeaders(inStream, true);
+                        
+                        SimpleHTTPOutputStream out;
+                        String transferEncoding = (String)map.get(HTTPConstants.HEADER_TRANSFER_ENCODING);
+                        if(transferEncoding != null 
+                            && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(transferEncoding)){
+                                inStream = new ChunkedInputStream(inStream);
+                                out = new SimpleHTTPOutputStream(socket.getOutputStream(),true);
+                            }else{
+                                out = new SimpleHTTPOutputStream(socket.getOutputStream(),false);
+                            }
 
-                        /*
-                         * If the request is a GET request then  
-                         * process the request and send out HTML
-                         * if not get the soap message and process it
-                         */
+                        //OutputStream out = socket.getOutputStream();
+                        msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
 
-                        //Handle POST Request
                         SOAPEnvelope envelope =
-                            reciver.checkForMessage(msgContext, configurationContext);
+                            reciver.handleHTTPRequest(msgContext,inStream,map);
 
                         if (envelope != null) {
                             msgContext.setEnvelope(envelope);
@@ -178,16 +185,16 @@
                             AxisEngine engine = new AxisEngine(configurationContext);
                             engine.receive(msgContext);
 
-                            Object contextWritten =
-                                msgContext.getProperty(Constants.RESPONSE_WRITTEN);
-                            if (contextWritten == null
-                                || !Constants.VALUE_TRUE.equals(contextWritten)) {
-                                out.write(new String(HTTPConstants.NOCONTENT).getBytes());
-                                out.close();
-                            }
+//                            Object contextWritten =
+//                                msgContext.getProperty(Constants.RESPONSE_WRITTEN);
+//                            if (contextWritten == null
+//                                || !Constants.VALUE_TRUE.equals(contextWritten)) {
+//                                out.write(new String(HTTPConstants.NOCONTENT).getBytes());
+//                                out.close();
+//                            }
 
                         }
-
+                        out.finalize();
                     }
                 } catch (Throwable e) {
                     log.error(e);
@@ -232,6 +239,10 @@
      * @throws Exception
      */
     public void start() throws AxisFault {
+        if(serverSocket == null){
+            serverSocket = ListenerManager.openSocket(port);
+        }
+        
         Thread newThread = new Thread(this);
         newThread.start();
     }
@@ -329,8 +340,7 @@
         this.configurationContext = axisConf;
         Parameter param = transprtIn.getParameter(PARAM_PORT);
         if (param != null) {
-            int port = Integer.parseInt((String) param.getValue());
-            serverSocket = ListenerManager.openSocket(port);
+            this.port = Integer.parseInt((String) param.getValue());
         }
     }