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 2007/10/15 22:51:32 UTC

svn commit: r584913 - in /webservices/axis2/trunk/java/modules/kernel: conf/ src/org/apache/axis2/ src/org/apache/axis2/description/ src/org/apache/axis2/util/

Author: nadiramra
Date: Mon Oct 15 13:51:29 2007
New Revision: 584913

URL: http://svn.apache.org/viewvc?rev=584913&view=rev
Log:
AXIS2-3090 - ability to disable SOAP 1.2 bindings in auto-generated WSDL files.

Modified:
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java

Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?rev=584913&r1=584912&r2=584913&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Mon Oct 15 13:51:29 2007
@@ -78,6 +78,9 @@
 
     <!-- Following parameter will completely disable REST handling in Axis2-->
     <parameter name="disableREST" locked="true">false</parameter>
+    
+    <!-- Following parameter will suppress generation of SOAP 1.2 bindings in auto-generated WSDL files -->
+    <parameter name="disableSOAP12" locked="true">false</parameter>
 
     <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
     <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?rev=584913&r1=584912&r2=584913&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Mon Oct 15 13:51:29 2007
@@ -292,7 +292,8 @@
         public static final String DRILL_DOWN_TO_ROOT_CAUSE_FOR_FAULT_REASON =
                 "drillDownToRootCauseForFaultReason";
 
-        public static final String DISABLE_REST = "disableREST";
+        public static final String DISABLE_REST   = "disableREST";
+        public static final String DISABLE_SOAP12 = "disableSOAP12";
 
         // this will contain the keys of all the properties that will be in the message context
         public static final String TRANSPORT_URL = "TransportURL";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=584913&r1=584912&r2=584913&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Mon Oct 15 13:51:29 2007
@@ -147,6 +147,7 @@
         namespaceMap.put(prefix, axisService.getTargetNamespace());
         tns = ele.declareNamespace(axisService.getTargetNamespace(), prefix);
 
+        // axis2.xml indicated no HTTP binding?
         boolean disableREST = false;
         Parameter disableRESTParameter =
                 axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
@@ -154,6 +155,15 @@
                 JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
             disableREST = true;
         }
+        
+        // axis2.xml indicated no SOAP 1.2 binding?
+        boolean disableSOAP12 = false;
+        Parameter disableSOAP12Parameter =
+        axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+        if (disableSOAP12Parameter != null &&
+                JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+            disableSOAP12 = true;
+        }
 
         // adding documentation element
         // <documentation>&lt;b&gt;NEW!&lt;/b&gt; This method accepts an ISBN
@@ -189,12 +199,14 @@
         generateMessages(fac, ele);
         generatePortType(fac, ele);
         generateSOAP11Binding(fac, ele);
-        generateSOAP12Binding(fac, ele);
+        if (!disableSOAP12) {
+            generateSOAP12Binding(fac, ele);
+        }
         if (!disableREST) {
             generateHTTPBinding(fac, ele);
         }
 
-        generateService(fac, ele, disableREST);
+        generateService(fac, ele, disableREST, disableSOAP12);
         addPoliciesToDefinitionElement(policiesInDefinitions.values()
                 .iterator(), definition);
 
@@ -439,15 +451,18 @@
      * @param fac the active OMFactory
      * @param defintions the WSDL &lt;definitions&gt; element under which to put the service
      * @param disableREST if false, generate REST binding, if true, don't
+     * @param disableSOAP12 if false, generate SOAP 1.2 binding, if true, don't
      * @throws Exception if there's a problem
      */
-    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST)
+    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST, boolean disableSOAP12)
             throws Exception {
         OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
         defintions.addChild(service);
         service.addAttribute(ATTRIBUTE_NAME, axisService.getName(), null);
         generateSOAP11Ports(fac, service);
-        generateSOAP12Ports(fac, service);
+        if (!disableSOAP12) {
+            generateSOAP12Ports(fac, service);
+        }
 
         addPolicyAsExtElement(PolicyInclude.SERVICE_POLICY, axisService
                 .getPolicyInclude(), service);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=584913&r1=584912&r2=584913&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Mon Oct 15 13:51:29 2007
@@ -25,6 +25,7 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.util.XMLUtils;
 import org.apache.axis2.util.WSDLSerializationUtil;
 import org.apache.axis2.util.JavaUtils;
@@ -184,6 +185,7 @@
         // Add the interface element
         descriptionElement.addChild(getInterfaceElement(wsdl, tns, wsdlx, omFactory, interfaceName));
 
+        // axis2.xml indicated no HTTP binding?
         boolean disableREST = false;
         Parameter disableRESTParameter =
                 axisService.getParameter(Constants.Configuration.DISABLE_REST);
@@ -192,6 +194,15 @@
             disableREST = true;
         }
 
+        // axis2.xml indicated no SOAP 1.2 binding?
+        boolean disableSOAP12 = false;
+        Parameter disableSOAP12Parameter =
+        axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+        if (disableSOAP12Parameter != null &&
+                JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+            disableSOAP12 = true;
+        }        
+        
         // Check whether the axisService has any endpoints. If they exists serialize them else
         // generate default endpoint elements.
         Set bindings = new HashSet();
@@ -212,11 +223,22 @@
                 AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
                 AxisBinding axisBinding = axisEndpoint.getBinding();
                 String type = axisBinding.getType();
+                
+                // If HTTP binding is disabled, do not add.
                 if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
                     if (disableREST) {
                         continue;
                     }
                 }
+                
+                // If SOAP 1.2 binding is disabled, do not add.
+                String propertySOAPVersion = (String)axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
+                if (propertySOAPVersion != null) {
+                    if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
+                        continue;
+                    }
+                }
+                
                 bindings.add(axisBinding);
                 for (int i = 0; i < eprs.length; i++) {
                     String epr = eprs[i];
@@ -260,9 +282,11 @@
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
                                                                 tns));
+            if (!disableSOAP12) {
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl, wsoap,
                                                                 tns));
+            }
             if (!disableREST) {
                 descriptionElement.addChild(
                         WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
@@ -271,7 +295,7 @@
             }
             descriptionElement
                     .addChild(WSDLSerializationUtil.generateServiceElement(omFactory, wsdl, tns,
-                                                                           axisService, disableREST, eprs));
+                                                                           axisService, disableREST, disableSOAP12, eprs));
         }
 
         return descriptionElement;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java?rev=584913&r1=584912&r2=584913&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java Mon Oct 15 13:51:29 2007
@@ -281,14 +281,15 @@
      * @param tns - The targetnamespace
      * @param axisService - The AxisService
      * @param disableREST only generate REST endpoint if this is false
+     * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
      * @return - The generated service element
      * @throws AxisFault - Thrown in case an exception occurs
      */
     public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
                                                    OMNamespace tns, AxisService axisService,
-                                                   boolean disableREST)
+                                                   boolean disableREST, boolean disableSOAP12)
             throws AxisFault {
-        return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, null);
+        return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, disableSOAP12, null);
     }
     
     /**
@@ -298,12 +299,13 @@
      * @param tns - The targetnamespace
      * @param axisService - The AxisService
      * @param disableREST only generate REST endpoint if this is false
+     * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
      * @return - The generated service element
      * @throws AxisFault - Thrown in case an exception occurs
      */
     public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
                                                    OMNamespace tns, AxisService axisService,
-                                                   boolean disableREST, String[] eprs)
+                                                   boolean disableREST, boolean disableSOAP12, String[] eprs)
             throws AxisFault {
         if(eprs == null){
             eprs = axisService.getEPRs();
@@ -324,6 +326,7 @@
             if (epr.startsWith("https://")) {
                 name = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
             }
+            
             OMElement soap11EndpointElement =
                     omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
             soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
@@ -336,18 +339,23 @@
             soap11EndpointElement.addAttribute(
                     omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
             serviceElement.addChild(soap11EndpointElement);
-            OMElement soap12EndpointElement =
-                    omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
-            soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
-                    WSDL2Constants.ATTRIBUTE_NAME, null,
-                    name + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
-            soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
-                    WSDL2Constants.BINDING_LOCAL_NAME, null,
-                    tns.getPrefix() + ":" + axisService.getName() +
-                            Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
-            soap12EndpointElement.addAttribute(
-                    omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
-            serviceElement.addChild(soap12EndpointElement);
+            
+            OMElement soap12EndpointElement = null;
+            if (!disableSOAP12) {
+                soap12EndpointElement =
+                        omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+                soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
+                        WSDL2Constants.ATTRIBUTE_NAME, null,
+                        name + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
+                soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
+                        WSDL2Constants.BINDING_LOCAL_NAME, null,
+                        tns.getPrefix() + ":" + axisService.getName() +
+                                Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
+                soap12EndpointElement.addAttribute(
+                        omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
+                serviceElement.addChild(soap12EndpointElement);
+            }
+            
             OMElement httpEndpointElement = null;
             if (!disableREST) {
                 httpEndpointElement =
@@ -363,13 +371,16 @@
                         omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
                 serviceElement.addChild(httpEndpointElement);
             }
+            
             if (epr.startsWith("https://")) {
                 OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
                 soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTPS");
                 soap11EndpointElement.addChild(soap11Documentation);
-                OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
-                soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTPS");
-                soap12EndpointElement.addChild(soap12Documentation);
+                if (!disableSOAP12) {
+                    OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+                    soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTPS");
+                    soap12EndpointElement.addChild(soap12Documentation);
+                }
                 if (!disableREST) {
                     OMElement httpDocumentation =
                             omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
@@ -380,9 +391,11 @@
                 OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
                 soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTP");
                 soap11EndpointElement.addChild(soap11Documentation);
-                OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
-                soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTP");
-                soap12EndpointElement.addChild(soap12Documentation);
+                if (!disableSOAP12) {
+                    OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+                    soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTP");
+                    soap12EndpointElement.addChild(soap12Documentation);
+                }
                 if (!disableREST) {
                     OMElement httpDocumentation =
                             omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);



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