axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kei...@apache.org
Subject svn commit: r552506 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: description/AxisService2WSDL11.java description/AxisService2WSDL20.java util/WSDLSerializationUtil.java
Date Mon, 02 Jul 2007 14:35:45 GMT
Author: keithc
Date: Mon Jul  2 07:35:44 2007
New Revision: 552506

URL: http://svn.apache.org/viewvc?view=rev&rev=552506
Log:
Fixing AXIS2-2734. Disabling http binding and endpoint generation in WSDL when REST is disabled.


Modified:
    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/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?view=diff&rev=552506&r1=552505&r2=552506
==============================================================================
--- 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 Jul  2 07:35:44 2007
@@ -31,6 +31,7 @@
 import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.util.XMLUtils;
 import org.apache.axis2.util.WSDLSerializationUtil;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
@@ -142,6 +143,14 @@
         namespaceMap.put(prefix, axisService.getTargetNamespace());
         tns = ele.declareNamespace(axisService.getTargetNamespace(), prefix);
 
+        boolean disableREST = false;
+        Parameter disableRESTParameter =
+                axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+        if (disableRESTParameter != null &&
+                JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+            disableREST = true;
+        }
+
         // adding documentation element
         // <documentation>&lt;b&gt;NEW!&lt;/b&gt; This method accepts
an ISBN
         // string and returns &lt;b&gt;Amazon.co.uk&lt;/b&gt; Sales Rank
for
@@ -177,9 +186,11 @@
         generatePortType(fac, ele);
         generateSOAP11Binding(fac, ele);
         generateSOAP12Binding(fac, ele);
-        generateHTTPBinding(fac, ele);
+        if (!disableREST) {
+            generateHTTPBinding(fac, ele);
+        }
 
-        generateService(fac, ele);
+        generateService(fac, ele, disableREST);
         addPoliciesToDefinitionElement(policiesInDefinitions.values()
                 .iterator(), definition);
 
@@ -406,7 +417,7 @@
     /**
      * Generate the service
      */
-    public void generateService(OMFactory fac, OMElement defintions)
+    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST)
             throws Exception {
         OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
         defintions.addChild(service);
@@ -416,7 +427,9 @@
 
         addPolicyAsExtElement(PolicyInclude.SERVICE_POLICY, axisService
                 .getPolicyInclude(), service, fac);
+        if (!disableREST) {
             generateHTTPPorts(fac, service);
+        }
         }
 
     private void generateSOAP11Ports(OMFactory fac, OMElement 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?view=diff&rev=552506&r1=552505&r2=552506
==============================================================================
--- 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 Jul  2 07:35:44 2007
@@ -27,7 +27,9 @@
 import org.apache.axiom.om.OMText;
 import org.apache.axis2.util.XMLUtils;
 import org.apache.axis2.util.WSDLSerializationUtil;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchema;
 
@@ -179,6 +181,14 @@
         // Add the interface element
         descriptionElement.addChild(getInterfaceElement(wsdl, tns, wsdlx, omFactory, interfaceName));
 
+        boolean disableREST = false;
+        Parameter disableRESTParameter =
+                axisService.getParameter(Constants.Configuration.DISABLE_REST);
+        if (disableRESTParameter != null &&
+                JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+            disableREST = true;
+        }
+
         // Check whether the axisService has any endpoints. If they exists serialize them
else
         // generate default endpoint elements.
         Set bindings = new HashSet();
@@ -197,7 +207,14 @@
                 // https then we have two endpoints populated so we should serialize them
instead
                 // of updating the endpoints.
                 AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
-                bindings.add(axisEndpoint.getBinding());
+                AxisBinding axisBinding = axisEndpoint.getBinding();
+                String type = axisBinding.getType();
+                if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
+                    if (disableREST) {
+                        continue;
+                    }
+                }
+                bindings.add(axisBinding);
                 for (int i = 0; i < eprs.length; i++) {
                     String epr = eprs[i];
                     OMElement endpointElement = axisEndpoint.toWSDL20(wsdl, tns, whttp, epr);
@@ -243,12 +260,15 @@
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl,
wsoap,
                                                                 tns));
-            descriptionElement.addChild(
-                    WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
whttp,
-                                                              tns));
+            if (!disableREST) {
+                descriptionElement.addChild(
+                        WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService,
wsdl,
+                                                                  whttp,
+                                                                  tns));
+            }
             descriptionElement
                     .addChild(WSDLSerializationUtil.generateServiceElement(omFactory, wsdl,
tns,
-                                                                           axisService));
+                                                                           axisService, disableREST));
         }
 
         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?view=diff&rev=552506&r1=552505&r2=552506
==============================================================================
--- 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 Jul  2 07:35:44 2007
@@ -272,7 +272,7 @@
      * @throws AxisFault - Thrown in case an exception occurs
      */
     public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
OMNamespace tns,
-                                                   AxisService axisService)
+                                                   AxisService axisService, boolean disableREST)
             throws AxisFault {
         String[] eprs = axisService.getEPRs();
         if (eprs == null) {
@@ -315,17 +315,21 @@
             soap12EndpointElement.addAttribute(
                     omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
             serviceElement.addChild(soap12EndpointElement);
-            OMElement httpEndpointElement =
-                    omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
-            httpEndpointElement.addAttribute(omFactory.createOMAttribute(
-                    WSDL2Constants.ATTRIBUTE_NAME, null,
-                    name + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
-            httpEndpointElement.addAttribute(omFactory.createOMAttribute(
-                    WSDL2Constants.BINDING_LOCAL_NAME, null,
-                    tns.getPrefix() + ":" + axisService.getName() + Java2WSDLConstants.HTTP_BINDING));
-            httpEndpointElement.addAttribute(
-                    omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
-            serviceElement.addChild(httpEndpointElement);
+            OMElement httpEndpointElement = null;
+            if (!disableREST) {
+                httpEndpointElement =
+                        omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+                httpEndpointElement.addAttribute(omFactory.createOMAttribute(
+                        WSDL2Constants.ATTRIBUTE_NAME, null,
+                        name + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
+                httpEndpointElement.addAttribute(omFactory.createOMAttribute(
+                        WSDL2Constants.BINDING_LOCAL_NAME, null,
+                        tns.getPrefix() + ":" + axisService.getName() + Java2WSDLConstants
+                                .HTTP_BINDING));
+                httpEndpointElement.addAttribute(
+                        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");
@@ -333,9 +337,12 @@
                 OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION,
wsdl);
                 soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over
a HTTPS");
                 soap12EndpointElement.addChild(soap12Documentation);
-                OMElement httpDocumentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION,
wsdl);
-                httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTPS");
-                httpEndpointElement.addChild(httpDocumentation);
+                if (!disableREST) {
+                    OMElement httpDocumentation =
+                            omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+                    httpDocumentation.setText("This endpoint exposes a HTTP binding over
a HTTPS");
+                    httpEndpointElement.addChild(httpDocumentation);
+                }
             } else if (epr.startsWith("http://")) {
                 OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION,
wsdl);
                 soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over
a HTTP");
@@ -343,9 +350,12 @@
                 OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION,
wsdl);
                 soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over
a HTTP");
                 soap12EndpointElement.addChild(soap12Documentation);
-                OMElement httpDocumentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION,
wsdl);
-                httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTP");
-                httpEndpointElement.addChild(httpDocumentation);
+                if (!disableREST) {
+                    OMElement httpDocumentation =
+                            omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+                    httpDocumentation.setText("This endpoint exposes a HTTP binding over
a HTTP");
+                    httpEndpointElement.addChild(httpDocumentation);
+                }
             }
         }
         return serviceElement;



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


Mime
View raw message