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 ke...@apache.org on 2007/02/05 09:21:19 UTC

svn commit: r503585 [7/9] - in /webservices/axis2/trunk/java: etc/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/ modules/adb-codegen/src/org/apache/axis2/schema/template/ modules/adb/ modules/addressing/ modules/addressing/src/o...

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java Mon Feb  5 00:21:12 2007
@@ -18,9 +18,16 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.deployment.util.PhasesInfo;
 import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.description.*;
+import org.apache.axis2.deployment.util.PhasesInfo;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.ModuleConfiguration;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.phaseresolver.PhaseResolver;
 import org.apache.axis2.transport.MessageFormatter;
@@ -33,7 +40,13 @@
 import javax.xml.namespace.QName;
 import java.net.URL;
 import java.security.PrivilegedAction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Class AxisConfiguration
@@ -70,7 +83,7 @@
 
     private URL axis2Repository = null;
 
-    private HashMap allservices = new HashMap();
+    private HashMap allServices = new HashMap();
 
     /**
      * Stores the module specified in the server.xml at the document parsing time.
@@ -139,13 +152,13 @@
         observersList = new ArrayList();
         inPhasesUptoAndIncludingPostDispatch = new ArrayList();
         systemClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController.doPrivileged(new PrivilegedAction() {
-          public Object run() {
-            return Thread.currentThread().getContextClassLoader();      
-          }
+            public Object run() {
+                return Thread.currentThread().getContextClassLoader();
+            }
         });
-        serviceClassLoader = systemClassLoader; 
+        serviceClassLoader = systemClassLoader;
         moduleClassLoader = systemClassLoader;
-        
+
         this.phasesinfo = new PhasesInfo();
         targetResolvers = new ArrayList();
     }
@@ -246,8 +259,8 @@
 
     /**
      * This method will check whethere for a given service , can we ganerate
-     * valid wsdl or not. So if user derop a wsdl we print that out , else if
-     * all the operation uses RPC message recivers we will generate wsdl
+     * valid wsdl or not. So if user drop a wsdl we print that out , else if
+     * all the operation uses RPC message receivers we will generate wsdl
      *
      * @param axisService
      */
@@ -283,26 +296,28 @@
     public synchronized void addServiceGroup(AxisServiceGroup axisServiceGroup)
             throws AxisFault {
         notifyObservers(AxisEvent.SERVICE_DEPLOY, axisServiceGroup);
-        Iterator services = axisServiceGroup.getServices();
         axisServiceGroup.setParent(this);
-        AxisService description;
+        AxisService axisService;
+
+        Iterator services = axisServiceGroup.getServices();
         while (services.hasNext()) {
-            description = (AxisService) services.next();
-            if (allservices.get(description.getName()) != null) {
+            axisService = (AxisService) services.next();
+            String serviceName = axisService.getName();
+            if (allServices.get(serviceName) != null) {
                 throw new AxisFault(Messages.getMessage(
-                        "twoservicecannothavesamename", description.getName()));
+                        "twoservicecannothavesamename", axisService.getName()));
             }
-            if (description.getSchematargetNamespace() == null) {
-                description
+            if (axisService.getSchematargetNamespace() == null) {
+                axisService
                         .setSchematargetNamespace(Java2WSDLConstants.AXIS2_XSD);
             }
-            isWSDLEnable(description);
+            isWSDLEnable(axisService);
         }
         services = axisServiceGroup.getServices();
         while (services.hasNext()) {
-            description = (AxisService) services.next();
-            if (description.isUseDefaultChains()) {
-                Iterator operations = description.getOperations();
+            axisService = (AxisService) services.next();
+            if (axisService.isUseDefaultChains()) {
+                Iterator operations = axisService.getOperations();
                 while (operations.hasNext()) {
                     AxisOperation operation = (AxisOperation) operations.next();
                     phasesinfo.setOperationPhases(operation);
@@ -316,10 +331,28 @@
         }
         services = axisServiceGroup.getServices();
         while (services.hasNext()) {
-            description = (AxisService) services.next();
-            allservices.put(description.getName(), description);
-            if (!description.isClientSide()) {
-                notifyObservers(AxisEvent.SERVICE_DEPLOY, description);
+            axisService = (AxisService) services.next();
+
+            Map endpoints = axisService.getEndpoints();
+            String serviceName = axisService.getName();
+
+            if (endpoints.isEmpty()) {
+                allServices.put(serviceName, axisService);
+            } else if (endpoints.size() == 1) {
+                // if we have one endpoint, just process it. This is special case as this will be the case
+                // most of the time
+                allServices.put(serviceName, axisService);
+                allServices.put(serviceName + "." + axisService.getEndpointName(), axisService);
+            } else {
+                Iterator endpointNameIter = endpoints.keySet().iterator();
+                while (endpointNameIter.hasNext()) {
+                    String endpointName = (String) endpointNameIter.next();
+                    allServices.put(serviceName + "." + endpointName, axisService);
+                }
+            }
+
+            if (!axisService.isClientSide()) {
+                notifyObservers(AxisEvent.SERVICE_DEPLOY, axisService);
             }
         }
         // serviceGroups.put(axisServiceGroup.getServiceGroupName(),
@@ -336,7 +369,7 @@
         Iterator services = axisServiceGroup.getServices();
         while (services.hasNext()) {
             AxisService axisService = (AxisService) services.next();
-            allservices.remove(axisService.getName());
+            allServices.remove(axisService.getName());
             if (!axisService.isClientSide()) {
                 notifyObservers(AxisEvent.SERVICE_REMOVE, axisService);
             }
@@ -523,7 +556,7 @@
      * @throws AxisFault
      */
     public synchronized void removeService(String name) throws AxisFault {
-        AxisService service = (AxisService) allservices.remove(name);
+        AxisService service = (AxisService) allServices.remove(name);
 
         if (service != null) {
             log.debug(Messages.getMessage("serviceremoved", name));
@@ -668,7 +701,7 @@
      * @return Returns AxisService.
      */
     public AxisService getService(String name) throws AxisFault {
-        AxisService axisService = (AxisService) allservices.get(name);
+        AxisService axisService = (AxisService) allServices.get(name);
         if (axisService != null) {
             if (axisService.isActive()) {
                 return axisService;
@@ -688,7 +721,7 @@
      * @return AxisService
      */
     public AxisService getServiceForActivation(String serviceName) {
-        AxisService axisService = (AxisService) allservices.get(serviceName);
+        AxisService axisService = (AxisService) allServices.get(serviceName);
         if (axisService != null) {
             return axisService;
         } else {
@@ -723,11 +756,11 @@
             while (servics.hasNext()) {
                 AxisService axisService = (AxisService) servics.next();
 
-                allservices.put(axisService.getName(), axisService);
+                allServices.put(axisService.getName(), axisService);
             }
         }
 
-        return allservices;
+        return allServices;
     }
 
     // the class loder which become the top most parent of all the modules and
@@ -835,7 +868,7 @@
     }
 
     public void stopService(String serviceName) throws AxisFault {
-        AxisService service = (AxisService) allservices.get(serviceName);
+        AxisService service = (AxisService) allServices.get(serviceName);
         if (service == null) {
             throw new AxisFault(Messages.getMessage("servicenamenotvalid",
                     serviceName));
@@ -845,7 +878,7 @@
     }
 
     public void startService(String serviceName) throws AxisFault {
-        AxisService service = (AxisService) allservices.get(serviceName);
+        AxisService service = (AxisService) allServices.get(serviceName);
         if (service == null) {
             throw new AxisFault(Messages.getMessage("servicenamenotvalid",
                     serviceName));

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java Mon Feb  5 00:21:12 2007
@@ -128,7 +128,6 @@
      * method is called twice, it implies that sending the error handling has failed, in which case
      * the method logs the error and exists.
      * @deprecated (post 1.1 branch)
-     * @see org.apache.axis2.util.MessageContextBuilder.createFaultMessageContext()
      */
     public MessageContext createFaultMessageContext(MessageContext processingContext, Throwable e)
             throws AxisFault {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java Mon Feb  5 00:21:12 2007
@@ -7,7 +7,7 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.RequestResponseTransport;
-import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004_Constants;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -68,24 +68,27 @@
         }
         
         //TODO: The same thing should probably happen for a IN-OUT if addressing is enabled and the replyTo/faultTo are not anonymous 
-        if (msgContext.getAxisOperation().getMessageExchangePattern().equals(WSDL20_2004Constants.MEP_URI_IN_ONLY))
-        {
-          Object requestResponseTransport = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
-          if (requestResponseTransport != null)
-          {
-            ((RequestResponseTransport)requestResponseTransport).acknowledgeMessage(msgContext);
-          }
-        }else if (msgContext.getAxisOperation().getMessageExchangePattern().equals(WSDL20_2004Constants.MEP_URI_IN_OUT))
-        {   // OR, if 2 way operation but the response is intended to not use the response channel of a 2-way transport
+        if (msgContext.getAxisOperation().getMessageExchangePattern()
+                .equals(WSDL20_2004_Constants.MEP_URI_IN_ONLY)) {
+            Object requestResponseTransport =
+                    msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+            if (requestResponseTransport != null) {
+                ((RequestResponseTransport) requestResponseTransport)
+                        .acknowledgeMessage(msgContext);
+            }
+        } else if (msgContext.getAxisOperation().getMessageExchangePattern()
+                .equals(WSDL20_2004_Constants.MEP_URI_IN_OUT)) {   // OR, if 2 way operation but the response is intended to not use the response channel of a 2-way transport
             // then we don't need to keep the transport waiting.
-            Object requestResponseTransport = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
-            if (requestResponseTransport != null)
-            {
-                if(AddressingHelper.isReplyRedirected(msgContext) && AddressingHelper.isFaultRedirected(msgContext)){
-                    ((RequestResponseTransport)requestResponseTransport).acknowledgeMessage(msgContext);
+            Object requestResponseTransport =
+                    msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+            if (requestResponseTransport != null) {
+                if (AddressingHelper.isReplyRedirected(msgContext) &&
+                        AddressingHelper.isFaultRedirected(msgContext)) {
+                    ((RequestResponseTransport) requestResponseTransport)
+                            .acknowledgeMessage(msgContext);
                 }
             }
-          }
+        }
 
 
         ArrayList operationChain = msgContext.getAxisOperation().getRemainingPhasesInFlow();

Copied: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java (from r501333, webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java?view=diff&rev=503585&p1=webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java&r1=501333&p2=webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java&r2=503585
==============================================================================
--- webservices/axis2/branches/java/WSDL_2_0/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/HTTPLocationBasedDispatcher.java Mon Feb  5 00:21:12 2007
@@ -66,16 +66,15 @@
                 String httpLocation = parseRequestURL(uri);
 
                 if (httpLocation != null) {
-                    AxisEndpoint axisEndpoint = axisService.getEndpoint((String) messageContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME));
+                    AxisEndpoint axisEndpoint = axisService.getEndpoint((String) messageContext
+                            .getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME));
                     if (axisEndpoint != null) {
-                        Map httpLocationTable = (Map) axisEndpoint.getBinding().getProperty(WSDL2Constants.HTTP_LOCATION_TABLE);
+                        Map httpLocationTable = (Map) axisEndpoint.getBinding()
+                                .getProperty(WSDL2Constants.HTTP_LOCATION_TABLE);
                         if (httpLocationTable != null) {
-                            AxisOperation axisOperation = getOperationFromHTTPLocation(httpLocation, httpLocationTable);
-                            if (axisOperation != null) {
-                                AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint.getBinding().getChild(axisOperation.getName());
-                                messageContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
-                                return axisOperation;
-                            }
+                            AxisOperation axisOperation =
+                                    getOperationFromHTTPLocation(httpLocation, httpLocationTable);
+                            return axisOperation;
                         }
                     }
                 } else {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIBasedDispatcher.java Mon Feb  5 00:21:12 2007
@@ -24,10 +24,13 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.util.Map;
+
 /**
  * Dispatches the service based on the information from the target endpoint URL.
  */
@@ -56,29 +59,52 @@
         EndpointReference toEPR = messageContext.getTo();
 
         if (toEPR != null) {
-            if(isDebugEnabled){
-            log.debug(messageContext.getLogIDString()+" Checking for Service using target endpoint address : " + toEPR.getAddress());
+            if (isDebugEnabled) {
+                log.debug(messageContext.getLogIDString() +
+                        " Checking for Service using target endpoint address : " +
+                        toEPR.getAddress());
             }
             String filePart = toEPR.getAddress();
             //REVIEW: (nagy) Parsing the RequestURI will also give us the operationName if present, so we could conceivably store it in the MessageContext, but doing so and retrieving it is probably no faster than simply reparsing the URI
             ConfigurationContext configurationContext = messageContext.getConfigurationContext();
             String[] values = Utils.parseRequestURLForServiceAndOperation(filePart,
-                    configurationContext.getServiceContextPath());
+                                                                          configurationContext.getServiceContextPath());
 
             if ((values.length >= 1) && (values[0] != null)) {
                 AxisConfiguration registry =
                         configurationContext.getAxisConfiguration();
 
-                return registry.getService(values[0]);
+                AxisService axisService = registry.getService(values[0]);
+
+                // If the axisService is not null we get the binding that the request came to add
+                // add it as a property to the messageContext
+                if (axisService != null) {
+                    Map endpoints = axisService.getEndpoints();
+                    if (endpoints != null) {
+                        if (endpoints.size() == 1) {
+                            messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+                                                       endpoints.get(
+                                                               axisService.getEndpointName()));
+                        } else {
+                            String endpointName = values[0].substring(values[0].indexOf(".") + 1);
+                            messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+                                                       endpoints.get(endpointName));
+                        }
+                    }
+                }
+
+                return axisService;
             } else {
-                if(isDebugEnabled){
-                log.debug(messageContext.getLogIDString()+" Attempted to check for Service using target endpoint URI, but the service fragment was missing");
+                if (isDebugEnabled) {
+                    log.debug(messageContext.getLogIDString() +
+                            " Attempted to check for Service using target endpoint URI, but the service fragment was missing");
                 }
                 return null;
             }
         } else {
-            if(isDebugEnabled){
-            log.debug(messageContext.getLogIDString()+" Attempted to check for Service using null target endpoint URI");
+            if (isDebugEnabled) {
+                log.debug(messageContext.getLogIDString() +
+                        " Attempted to check for Service using null target endpoint URI");
             }
             return null;
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/RequestURIOperationDispatcher.java Mon Feb  5 00:21:12 2007
@@ -18,16 +18,21 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * Dispatches the operation based on the information from the target endpoint URL.
@@ -53,7 +58,8 @@
             if ((values.length >= 2) && (values[1] != null)) {
                 QName operationName = new QName(values[1]);
                 log.debug(messageContext.getLogIDString()+" Checking for Operation using QName(target endpoint URI fragment) : " + operationName);
-                return service.getOperation(operationName);
+                AxisOperation axisOperation = service.getOperation(operationName);
+                return axisOperation;
             } else {
                 log.debug(messageContext.getLogIDString()+" Attempted to check for Operation using target endpoint URI, but the operation fragment was missing");
                 return null;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPActionBasedDispatcher.java Mon Feb  5 00:21:12 2007
@@ -18,10 +18,14 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -44,7 +48,8 @@
         String action = messageContext.getSoapAction();
 
         if(isDebugEnabled){
-        log.debug(messageContext.getLogIDString()+" Checking for Operation using SOAPAction : " + action);
+            log.debug(messageContext.getLogIDString() +
+                    " Checking for Operation using SOAPAction : " + action);
         }
         if (action != null) {
             AxisOperation op = service.getOperationBySOAPAction(action);
@@ -59,7 +64,7 @@
              */
             if ((op == null) && (action.lastIndexOf('/') != -1)) {
                 op = service.getOperation(new QName(action.substring(action.lastIndexOf('/'),
-                        action.length())));
+                                                                     action.length())));
             }
 
             return op;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPMessageBodyBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPMessageBodyBasedDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPMessageBodyBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/SOAPMessageBodyBasedDispatcher.java Mon Feb  5 00:21:12 2007
@@ -20,11 +20,15 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/namespace/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/namespace/Constants.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/namespace/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/namespace/Constants.java Mon Feb  5 00:21:12 2007
@@ -275,6 +275,7 @@
     public static final QName XSD_ANYSIMPLETYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anySimpleType");
     public static final QName XSD_ANYTYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anyType");
     public static final QName XSD_ANY = new QName(URI_DEFAULT_SCHEMA_XSD, "any");
+    public static final QName AXIS2_NONE = new QName("http://org.apache.axis2", "none");
     public static final QName XSD_QNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "QName");
     public static final QName XSD_DATETIME = new QName(URI_DEFAULT_SCHEMA_XSD, "dateTime");
     public static final QName XSD_DATE = new QName(URI_DEFAULT_SCHEMA_XSD, "date");

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Mon Feb  5 00:21:12 2007
@@ -38,6 +38,7 @@
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Mon Feb  5 00:21:12 2007
@@ -16,18 +16,6 @@
 
 package org.apache.axis2.transport.http;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
@@ -37,6 +25,8 @@
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.WSDL20DefaultValueHolder;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Utils;
@@ -55,6 +45,20 @@
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
 
 public abstract class AbstractHTTPSender {
     protected static final String ANONYMOUS = "anonymous";
@@ -196,6 +200,7 @@
 
         client.getState().setProxyCredentials(AuthScope.ANY, proxyCred);
         config.setProxy(proxyHostName, proxyPort);
+        config.setHost(proxyHostName);
     }
 
     /**
@@ -288,7 +293,7 @@
     public abstract void send(MessageContext msgContext, OMElement dataout,
                               URL url,
                               String soapActionString)
-            throws MalformedURLException, AxisFault, IOException;
+            throws AxisFault, IOException;
 
     /**
      * getting host configuration to support standard http/s, proxy and NTLM support
@@ -360,7 +365,8 @@
 
                 Credentials creds;
 
-                agent.getParams().setAuthenticationPreemptive(authenticator.getPreemptiveAuthentication());
+                agent.getParams()
+                        .setAuthenticationPreemptive(authenticator.getPreemptiveAuthentication());
 
                 if (host != null) {
                     if (domain != null) {
@@ -532,12 +538,12 @@
             method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING,
                                     HTTPConstants.COMPRESSION_GZIP);
         }
+
         if (Utils.isExplicitlyTrue(msgContext, HTTPConstants.MC_GZIP_REQUEST)) {
             method.addRequestHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
                                     HTTPConstants.COMPRESSION_GZIP);
         }
 
-
         httpClient.executeMethod(config, method);
     }
 
@@ -588,5 +594,85 @@
         }
 
         return userAgentString;
+    }
+
+    protected String applyURITemplating(MessageContext messageContext, String query,
+                                        boolean detach) throws AxisFault {
+
+        OMElement firstElement;
+        if (detach) {
+            firstElement = messageContext.getEnvelope().getBody().getFirstElement();
+        } else {
+            firstElement =
+                    messageContext.getEnvelope().getBody().getFirstElement().cloneOMElement();
+        }
+
+
+        HTTPLocation httpLocation = new HTTPLocation(query);
+
+        String[] localNames = httpLocation.getLocalNames();
+        String[] values = new String[localNames.length];
+        int i;
+        for (i = 0; i < localNames.length; i++) {
+            String localName = localNames[i];
+
+            try {
+                values[i] = URLEncoder.encode(getOMElementValue(localName, firstElement), "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                log.error("Unable to encode Query String");
+                throw new AxisFault("Unable to encode Query String");
+            }
+        }
+
+
+        httpLocation.substitute(values);
+
+        return httpLocation.toString();
+    }
+
+    protected String appendQueryParameters(MessageContext messageContext, String query) {
+
+
+        OMElement firstElement;
+        String queryParameterSeparator = (String) messageContext
+                .getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+        // In case queryParameterSeparator is null we better use the default value 
+        if (queryParameterSeparator == null) {
+            queryParameterSeparator = WSDL20DefaultValueHolder
+                    .getDefaultValue(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
+        }
+        firstElement = messageContext.getEnvelope().getBody().getFirstElement();
+        ArrayList values = new ArrayList();
+        if (firstElement != null) {
+            Iterator iter = firstElement.getChildElements();
+            while (iter.hasNext()) {
+                OMElement element = (OMElement) iter.next();
+                values.add(element.getLocalName() + "=" + element.getText());
+            }
+        }
+        if (values.size() > 0) {
+            if (query == null) {
+
+                query = (String) values.get(0);
+            }
+
+            for (int i = 1; i < values.size(); i++) {
+                query = query + queryParameterSeparator + values.get(i);
+            }
+        }
+        return query;
+    }
+
+    private String getOMElementValue(String elementName, OMElement parentElement) {
+        OMElement httpURLParam = parentElement.getFirstChildWithName(new QName(elementName));
+
+        if (httpURLParam != null) {
+            httpURLParam.detach();
+            if (parentElement.getFirstOMChild() == null) {
+                parentElement.detach();
+            }
+        }
+        return httpURLParam.getText();
+
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Mon Feb  5 00:21:12 2007
@@ -18,9 +18,11 @@
 package org.apache.axis2.transport.http;
 
 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingHelper;
@@ -30,9 +32,12 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.SessionContext;
 import org.apache.axis2.deployment.WarBasedAxisConfigurator;
+import org.apache.axis2.description.AxisBindingMessage;
+import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.Handler.InvocationResponse;
@@ -42,7 +47,6 @@
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.axis2.util.JavaUtils;
-import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -52,7 +56,11 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.net.SocketException;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -93,7 +101,8 @@
         msgContext.setConfigurationContext(configContext);
         msgContext.setTransportIn(axisConfiguration.getTransportIn(new QName(Constants
                 .TRANSPORT_HTTP)));
-        msgContext.setTransportOut(axisConfiguration.getTransportOut(new QName(Constants.TRANSPORT_HTTP)));
+        msgContext.setTransportOut(
+                axisConfiguration.getTransportOut(new QName(Constants.TRANSPORT_HTTP)));
 
         msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                 new ServletBasedOutTransportInfo(resp));
@@ -180,9 +189,11 @@
         // 2. list services requests
         // 3. REST requests.
         if ((query != null) && (query.indexOf("wsdl2") >= 0 ||
-                query.indexOf("wsdl") >= 0 || query.indexOf("xsd") >= 0 || query.indexOf("policy") >= 0)) { // handling meta data exchange stuff
+                query.indexOf("wsdl") >= 0 || query.indexOf("xsd") >= 0 ||
+                query.indexOf("policy") >= 0)) { // handling meta data exchange stuff
             agent.processListService(req, resp);
-        } else if (requestURI.endsWith(LIST_SERVICES_SUFIX) || requestURI.endsWith(LIST_FAUKT_SERVICES_SUFIX)) { // handling list services request
+        } else if (requestURI.endsWith(LIST_SERVICES_SUFIX) ||
+                requestURI.endsWith(LIST_FAUKT_SERVICES_SUFIX)) { // handling list services request
             try {
                 agent.handle(req, resp);
             } catch (Exception e) {
@@ -190,16 +201,24 @@
             }
         } else if (!disableREST ) {
             MessageContext messageContext = null;
+            OutputStream out = resp.getOutputStream();
             try {
                 messageContext = createMessageContext(req, resp);
+                messageContext.setProperty(
+                        org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD,
+                        Constants.Configuration.HTTP_METHOD_GET);
                 new RESTUtil(configContext).processGetRequest(messageContext,
                         req,
                         resp);
-            } catch (Exception e) {
-                log.error(e);
+                Object contextWritten =
+                        messageContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN);
+                if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
+                    resp.setStatus(HttpServletResponse.SC_ACCEPTED);
+                }
+            } catch (AxisFault e) {
+                log.debug(e);
                 if (messageContext != null) {
-                    resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                    handleFault(messageContext, resp.getOutputStream(), new AxisFault(e));
+                    processAxisFault(messageContext, resp, out, e);
                 } else {
                     throw new ServletException(e);
                 }
@@ -234,14 +253,19 @@
         if (!disableREST && isRESTRequest(contentType, req)) {
             msgContext = createMessageContext(req, res);
             try {
+
                 new RESTUtil(configContext).processPostRequest(msgContext,
                         req,
                         res);
-            } catch (Exception e) {
-                log.error(e);
+                Object contextWritten =
+                        msgContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN);
+                if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
+                    res.setStatus(HttpServletResponse.SC_ACCEPTED);
+                }
+            } catch (AxisFault e) {
+                log.debug(e);
                 if (msgContext != null) {
-                    res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                    handleFault(msgContext, out, new AxisFault(e));
+                    processAxisFault(msgContext, res, out, e);
                 } else {
                     throw new ServletException(e);
                 }
@@ -268,20 +292,11 @@
                 if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
                     res.setStatus(HttpServletResponse.SC_ACCEPTED);
                 }
+
             } catch (AxisFault e) {
                 log.debug(e);
                 if (msgContext != null) {
-                    try {
-                        // If the fault is not going along the back channel we should be 202ing
-                        if (AddressingHelper.isFaultRedirected(msgContext)) {
-                            res.setStatus(HttpServletResponse.SC_ACCEPTED);
-                        } else {
-                            res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                        }
-                        handleFault(msgContext, out, e);
-                    } catch (AxisFault e2) {
-                        log.info(e2);
-                    }
+                    processAxisFault(msgContext, res, out, e);
                 } else {
                     throw new ServletException(e);
                 }
@@ -294,10 +309,23 @@
                             res.setStatus(HttpServletResponse.SC_ACCEPTED);
                         } else {
                             res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+                            AxisBindingOperation axisBindingOperation =
+                                    (AxisBindingOperation) msgContext
+                                            .getProperty(Constants.AXIS_BINDING_OPERATION);
+                            if (axisBindingOperation != null) {
+                                Integer code = (Integer) axisBindingOperation.getFault(
+                                        (String) msgContext.getProperty(Constants.FAULT_NAME))
+                                        .getProperty(WSDL2Constants.ATTR_WHTTP_CODE);
+                                if (code != null) {
+                                    res.setStatus(code.intValue());
+                                }
+                            }
                         }
                         handleFault(msgContext, out, new AxisFault(t.toString(), t));
                     } catch (AxisFault e2) {
                         log.info(e2);
+                        throw new ServletException(e2);
                     }
                 } else {
                     throw new ServletException(t);
@@ -309,7 +337,115 @@
                 ((StAXBuilder) msgContext.getEnvelope().getBuilder()).close();
             } catch (Exception e) {
                 log.debug(e);
+                throw new ServletException(e);
+            }
+        }
+    }
+
+    private void processAxisFault(MessageContext msgContext, HttpServletResponse res,
+                                  OutputStream out, AxisFault e) {
+        try {
+            // If the fault is not going along the back channel we should be 202ing
+            if (AddressingHelper.isFaultRedirected(msgContext)) {
+                res.setStatus(HttpServletResponse.SC_ACCEPTED);
+            } else {
+
+                res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+                AxisBindingOperation axisBindingOperation = (AxisBindingOperation) msgContext
+                        .getProperty(Constants.AXIS_BINDING_OPERATION);
+                if (axisBindingOperation != null) {
+                    AxisBindingMessage fault = axisBindingOperation
+                            .getFault((String) msgContext.getProperty(Constants.FAULT_NAME));
+                    if (fault != null) {
+                        Integer code = (Integer) fault.getProperty(WSDL2Constants.ATTR_WHTTP_CODE);
+                        if (code != null) {
+                            res.setStatus(code.intValue());
+                        }
+                    }
+                }
             }
+            handleFault(msgContext, out, e);
+        } catch (AxisFault e2) {
+            log.info(e2);
+        }
+    }
+
+    protected void doDelete(HttpServletRequest req,
+                            HttpServletResponse resp) throws ServletException, IOException {
+
+        initContextRoot(req);
+
+        // this method is also used to serve for the listServices request.
+
+        if (!disableREST) {
+            MessageContext messageContext = null;
+            OutputStream out = resp.getOutputStream();
+            try {
+                messageContext = createMessageContext(req, resp);
+                messageContext.setProperty(
+                        org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD,
+                        Constants.Configuration.HTTP_METHOD_DELETE);
+                new RESTUtil(configContext).processGetRequest(messageContext,
+                                                              req,
+                                                              resp);
+                Object contextWritten =
+                        messageContext.getOperationContext()
+                                .getProperty(Constants.RESPONSE_WRITTEN);
+                if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
+                    resp.setStatus(HttpServletResponse.SC_ACCEPTED);
+                }
+            } catch (AxisFault e) {
+                log.debug(e);
+                if (messageContext != null) {
+                    processAxisFault(messageContext, resp, out, e);
+                }
+            }
+        } else {
+            PrintWriter writer = new PrintWriter(resp.getOutputStream());
+            writer.println(
+                    "<html><body><h2>Please enable REST support in WEB-INF/conf/axis2.xml and WEB-INF/web.xml</h2></body></html>");
+            writer.flush();
+            resp.setStatus(HttpServletResponse.SC_ACCEPTED);
+        }
+    }
+
+    protected void doPut(HttpServletRequest req,
+                         HttpServletResponse resp) throws ServletException, IOException {
+
+        initContextRoot(req);
+
+        // this method is also used to serve for the listServices request.
+
+        if (!disableREST) {
+            MessageContext messageContext = null;
+            OutputStream out = resp.getOutputStream();
+            try {
+                messageContext = createMessageContext(req, resp);
+                messageContext.setProperty(
+                        org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD,
+                        Constants.Configuration.HTTP_METHOD_PUT);
+                new RESTUtil(configContext).processPostRequest(messageContext,
+                                                               req,
+                                                               resp);
+                Object contextWritten =
+                        messageContext.getOperationContext()
+                                .getProperty(Constants.RESPONSE_WRITTEN);
+                if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
+                    resp.setStatus(HttpServletResponse.SC_ACCEPTED);
+                }
+            } catch (AxisFault e) {
+                log.debug(e);
+                if (messageContext != null) {
+                    processAxisFault(messageContext, resp, out, e);
+                }
+            }
+        } else {
+            PrintWriter writer = new PrintWriter(resp.getOutputStream());
+            writer.println(
+                    "<html><body><h2>Please enable REST support in WEB-INF/conf/axis2.xml and WEB-INF/web.xml</h2></body></html>");
+            writer.flush();
+            resp.setStatus(HttpServletResponse.SC_ACCEPTED);
         }
     }
 
@@ -318,7 +454,29 @@
         msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
 
         AxisEngine engine = new AxisEngine(configContext);
-        MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext, e);
+        MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+
+        // SOAP 1.2 specification mentions that we should send HTTP code 400 in a fault if the
+        // fault code Sender
+        HttpServletResponse response =
+                (HttpServletResponse) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
+        if (response != null) {
+            SOAPFaultCode code = faultContext.getEnvelope().getBody().getFault().getCode();
+            OMElement valueElement = null;
+            if (code != null) {
+                valueElement = code.getFirstChildWithName(new QName(
+                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+                        SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
+            }
+
+            if (valueElement != null) {
+                if (valueElement.getText().trim().indexOf(SOAP12Constants.FAULT_CODE_SENDER) >
+                        -1) {
+                    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+                }
+            }
+        }
+
 
         engine.sendFault(faultContext);
     }
@@ -383,7 +541,8 @@
     protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
         try {
             ConfigurationContext configContext =
-                    ConfigurationContextFactory.createConfigurationContext(new WarBasedAxisConfigurator(config));
+                    ConfigurationContextFactory
+                            .createConfigurationContext(new WarBasedAxisConfigurator(config));
             configContext.setProperty(Constants.CONTAINER_MANAGED, Constants.VALUE_TRUE);
             return configContext;
         } catch (Exception e) {
@@ -533,17 +692,10 @@
      * @param request
      */
     private boolean isRESTRequest(String contentType, HttpServletRequest request) {
-        String soapActionHeader = request.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
-        if (contentType != null && contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
-            return false;
-        } else {
-            if (contentType != null && contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
-                return false;
-            } else {
-                return ((soapActionHeader == null) ||
-                        (contentType != null && contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1));
-            }
-        }
+        return ((contentType == null ||
+                contentType.indexOf(HTTPConstants.MEDIA_TYPE_APPLICATION_XML) > -1 ||
+                contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1 ||
+                contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA) > -1));
     }
 
     class ServletRequestResponseTransport implements RequestResponseTransport {
@@ -587,7 +739,6 @@
         public RequestResponseTransportStatus getStatus() {
             return status;
         }
-
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Mon Feb  5 00:21:12 2007
@@ -16,15 +16,6 @@
 
 package org.apache.axis2.transport.http;
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.MIMEOutputUtils;
@@ -33,7 +24,6 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.handlers.AbstractHandler;
@@ -42,14 +32,28 @@
 import org.apache.axis2.transport.TransportSender;
 import org.apache.axis2.transport.TransportUtils;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.zip.GZIPOutputStream;
+
 public class CommonsHTTPTransportSender extends AbstractHandler implements
 		TransportSender {
 
+
 	protected static final String PROXY_HOST_NAME = "proxy_host";
 
 	protected static final String PROXY_PORT = "proxy_port";
@@ -70,9 +74,6 @@
 
 	int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
 
-	public CommonsHTTPTransportSender() {
-	}
-
 	public void cleanup(MessageContext msgContext) throws AxisFault {
 		HttpMethod httpMethod = (HttpMethod) msgContext
 				.getProperty(HTTPConstants.HTTP_METHOD);
@@ -90,7 +91,6 @@
 		// checked
 		Parameter version = transportOut
 				.getParameter(HTTPConstants.PROTOCOL_VERSION);
-
 		if (version != null) {
 			if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
 				httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
@@ -184,12 +184,17 @@
 
 			/**
 			 * Figuringout the REST properties/parameters
-			 */
-			if (msgContext.isDoingREST()) {
-				dataOut = msgContext.getEnvelope().getBody().getFirstElement();
-			} else {
-				dataOut = msgContext.getEnvelope();
-			}
+             */
+            if (msgContext.isDoingREST()) {
+                if (msgContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
+                    dataOut = msgContext.getEnvelope().getBody().getFault().getDetail()
+                            .getFirstElement();
+                } else {
+                    dataOut = msgContext.getEnvelope().getBody().getFirstElement();
+                }
+            } else {
+                dataOut = msgContext.getEnvelope();
+            }
 
 			if (epr != null) {
 				if (!epr.hasNoneAddress()) {
@@ -203,7 +208,6 @@
 							"Both the TO and MessageContext.TRANSPORT_OUT property are Null, No where to send");
 				}
 			}
-
 			if (msgContext.getOperationContext() != null) {
 				msgContext.getOperationContext().setProperty(
 						Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
@@ -252,8 +256,6 @@
 			throw new AxisFault(Constants.OUT_TRANSPORT_INFO
 					+ " has not been set");
 		}
-		// }
-
 		format.setAutoCloseWriter(true);
 		if (!msgContext.isDoingREST()) {
 			MessageFormatter messageFormatter = TransportUtils
@@ -272,13 +274,43 @@
 						bufferedSOAPBody, out, msgContext.getAttachmentMap(),
 						format);
 			} else {
-				dataOut.serializeAndConsume(out, format);
-			}
+                ServletBasedOutTransportInfo servletBasedOutTransportInfo =
+                        (ServletBasedOutTransportInfo) transportInfo;
+                List customHheaders = (List) msgContext.getProperty(HTTPConstants.HTTP_HEADERS);
+                if (customHheaders != null) {
+                    Iterator iter = customHheaders.iterator();
+                    while (iter.hasNext()) {
+                        Header header = (Header) iter.next();
+                        if (header != null) {
+                            servletBasedOutTransportInfo
+                                    .addHeader(header.getName(), header.getValue());
+                        }
+                    }
+                }
+                Object gzip = msgContext.getOptions().getProperty(HTTPConstants.MC_GZIP_RESPONSE);
+                if (gzip != null && JavaUtils.isTrueExplicitly(gzip)) {
+                    servletBasedOutTransportInfo.addHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
+                                                           HTTPConstants.COMPRESSION_GZIP);
+                    GZIPOutputStream gzout = null;
+                    ByteArrayOutputStream compressed = new ByteArrayOutputStream();
+                    try {
+                        gzout = new GZIPOutputStream(compressed);
+                        dataOut.serializeAndConsume(gzout, format);
+                        gzout.flush();
+                        gzout.close();
+                        out.write(compressed.toByteArray());
+                    } catch (IOException e) {
+                        throw new AxisFault("Could not compress response");
+                    }
+                } else {
+                    dataOut.serializeAndConsume(out, format);
+                }
 		}
 
 	}
+    }
 
-	public void writeMessageWithCommons(MessageContext messageContext,
+    public void writeMessageWithCommons(MessageContext messageContext,
 			EndpointReference toEPR, OMElement dataout, OMOutputFormat format)
 			throws AxisFault {
 		try {
@@ -301,7 +333,6 @@
 				httpVersion = (String) messageContext
 						.getProperty(HTTPConstants.HTTP_PROTOCOL_VERSION);
 			}
-
 			// Following order needed to be preserved because,
 			// HTTP/1.0 does not support chunk encoding
 			sender.setChunked(chunked);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java Mon Feb  5 00:21:12 2007
@@ -30,8 +30,10 @@
             "application/x-www-form-urlencoded";
     public static final String MEDIA_TYPE_TEXT_XML = "text/xml";
     public static final String MEDIA_TYPE_MULTIPART_RELATED = "multipart/related";
+    public static final String MEDIA_TYPE_MULTIPART_FORM_DATA = "multipart/form-data";
     public static final String MEDIA_TYPE_APPLICATION_XML = "application/xml";
     public static final String MEDIA_TYPE_APPLICATION_SOAP_XML = "application/soap+xml";
+    public static final String MEDIA_TYPE_APPLICATION_ECHO_XML = "application/echo+xml";
 
     /**
      * Field REQUEST_URI
@@ -448,6 +450,11 @@
      * context property to true to have the request body gzip compressed.
      */
     public static final String MC_GZIP_REQUEST = "transport.http.gzipRequest";
+
+     /* by default the HTTP response body is not compressed. set this message
+     * context property to true to have the response body gzip compressed.
+     */
+    public static final String MC_GZIP_RESPONSE = "gzipResponse";
 
     /**
      * This will allow users to set any custom headers to the message context, which will be picked

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Mon Feb  5 00:21:12 2007
@@ -203,13 +203,15 @@
         try {
 
             Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+
             if (headers != null) {
                 if (HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING)) ||
                     HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING_LOWERCASE)))
                 {
                     in = new GZIPInputStream(in);
                 }
-            }
+                }
+
 
             // remove the starting and trailing " from the SOAP Action
             if ((soapActionHeader != null) && soapActionHeader.charAt(0) == '\"'



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org