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 na...@apache.org on 2008/07/21 06:59:00 UTC

svn commit: r678346 - in /webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2: deployment/util/Utils.java engine/DispatchPhase.java i18n/resource.properties

Author: nandana
Date: Sun Jul 20 21:58:59 2008
New Revision: 678346

URL: http://svn.apache.org/viewvc?rev=678346&view=rev
Log:
AXIS2-3920 fixing the issue in the branch 

Modified:
    webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
    webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/i18n/resource.properties

Modified: webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=678346&r1=678345&r2=678346&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Sun Jul 20 21:58:59 2008
@@ -93,6 +93,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Loader;
 import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
@@ -1101,11 +1102,20 @@
 						bindingCache);
 				axisService.addEndpoint(httpSoap12Endpoint.getName(),
 						httpSoap12Endpoint);
+				
+				
+                                boolean disableREST = false;
+                                Parameter disableRESTParameter = axisService
+                                                .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+                                if (disableRESTParameter != null
+                                                && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+                                        disableREST = true;
+                                }
 
 				/*
 				 * generating Http endpoint
 				 */
-				if ("http".equals(transportName)) {
+				if ("http".equals(transportName) && !disableREST) {
 					String httpEndpointName = serviceName + protocol
 							+ "Endpoint";
 					AxisEndpoint httpEndpoint = new AxisEndpoint();
@@ -1144,6 +1154,8 @@
 				String protocol = transportName.substring(0, 1).toUpperCase()
 						+ transportName.substring(1, transportName.length())
 								.toLowerCase();
+				
+				
 				/*
 				 * populates soap11 endpoint
 				 */
@@ -1175,11 +1187,20 @@
 				axisService.addEndpoint(httpSoap12Endpoint.getName(),
 						httpSoap12Endpoint);
 
+                                // axis2.xml or services.xml indicated no HTTP binding?
+                                boolean disableREST = false;
+                                Parameter disableRESTParameter = axisService
+                                                .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+                                if (disableRESTParameter != null
+                                                && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+                                        disableREST = true;
+                                }
+				
 				/*
 				 * generating Http endpoint
 				 */
-				if ("http".equals(transportName)
-						|| "https".equals(transportName)) {
+				if (("http".equals(transportName)
+						|| "https".equals(transportName)) && !disableREST) {
 					String httpEndpointName = serviceName + protocol
 							+ "Endpoint";
 					AxisEndpoint httpEndpoint = new AxisEndpoint();

Modified: webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java?rev=678346&r1=678345&r2=678346&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java (original)
+++ webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java Sun Jul 20 21:58:59 2008
@@ -34,6 +34,7 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.RequestResponseTransport;
@@ -93,6 +94,8 @@
         }
 
         validateTransport(msgContext);
+        
+        validateBindings(msgContext);
 
         loadContexts(service, msgContext);
 
@@ -218,6 +221,31 @@
         throw new AxisFault(Messages.getMessage("servicenotfoundforepr",
                                                 ((toEPR != null) ? toEPR.getAddress() : "")));
     }
+    
+    /**
+     * To check whether the incoming request has come in valid binding , we check whether service
+     * author has disabled any binding using parameters
+     * <code>org.apache.axis2.Constants.Configuration.DISABLE_REST</code>
+     * @param service msgctx the current MessageContext
+     * @throws AxisFault in case of error
+     */
+    private void validateBindings(MessageContext msgctx) throws AxisFault {
+        
+        AxisService service = msgctx.getAxisService();
+        
+        boolean disableREST = false;
+        Parameter disableRESTParameter = service
+                        .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+        if (disableRESTParameter != null
+                        && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+                disableREST = true;
+        }
+        
+        if (msgctx.isDoingREST() && disableREST) {
+            throw new AxisFault(Messages.getMessage("bindingDisabled","Http"));     
+        } 
+        
+    }
 
     private void fillContextsFromSessionContext(MessageContext msgContext) throws AxisFault {
         AxisService service = msgContext.getAxisService();

Modified: webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/i18n/resource.properties?rev=678346&r1=678345&r2=678346&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/i18n/resource.properties (original)
+++ webservices/axis2/branches/java/1_4/modules/kernel/src/org/apache/axis2/i18n/resource.properties Sun Jul 20 21:58:59 2008
@@ -266,6 +266,7 @@
 mustunderstandfailed2=Must Understand check failed for headers: {0}
 receivederrormessage=The system received an error message with the {0} ID. 
 servicenotfoundforepr=The service cannot be found for the endpoint reference (EPR) {0}
+bindingDisabled={0} binding is disabled for this service.
 operationnotfoundforepr=The endpoint reference (EPR) for the Operation not found is {0} and the WSA Action = {1}
 unabletofindservice=The requested service could not be found -- the operation has been stopped.
 invalidservicegrouoid=The {0} Service Group ID is not valid.