Author: keith
Date: Mon Dec 22 01:54:44 2008
New Revision: 27604
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=27604

Log:
Fixing carbon-1365. When proxy services are created we can show a WSDL only if 
its provided. We cannot generate a WSDL for proxy services


Modified:
   
branches/synapse/1.2.wso2v1/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java

Modified: 
branches/synapse/1.2.wso2v1/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java?rev=27604&r1=27603&r2=27604&view=diff
==============================================================================
--- 
branches/synapse/1.2.wso2v1/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java
   (original)
+++ 
branches/synapse/1.2.wso2v1/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java
   Mon Dec 22 01:54:44 2008
@@ -36,6 +36,7 @@
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
@@ -373,6 +374,11 @@
             AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
                 getServices().get(serviceName);
             if (service != null) {
+                if (!isWSDLProvidedForProxyService(service)) {
+                    handleBrowserException("No WSDL was provided for the 
Service " + serviceName +
+                            ". A WSDL cannot be generated.", null);
+                    return;
+                }
                 try {
                     ByteArrayOutputStream baos = new ByteArrayOutputStream();
                     service.printWSDL(baos, getIpAddress());
@@ -391,6 +397,11 @@
             AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
                 getServices().get(serviceName);
             if (service != null) {
+                if (!isWSDLProvidedForProxyService(service)) {
+                    handleBrowserException("No WSDL was provided for the 
Service " + serviceName +
+                            ". A WSDL cannot be generated.", null);
+                    return;
+                }
                 try {
                     ByteArrayOutputStream baos = new ByteArrayOutputStream();
                     service.printWSDL2(baos, getIpAddress());
@@ -542,11 +553,11 @@
             } catch (IOException ignore) {}
         }
 
-        if (conn != null) {
-            try {
-                conn.shutdown();
-            } catch (IOException ignore) {}
-        }
+//        if (conn != null) {
+//            try {
+//                conn.shutdown();
+//            } catch (IOException ignore) {}
+//        }
     }
 
     private void handleException(String msg, Exception e) {
@@ -705,4 +716,16 @@
         resultBuf.append("</body></html>");
         return resultBuf.toString();
     }
+
+    private boolean isWSDLProvidedForProxyService(AxisService service) {
+        boolean isWSDLProvided = false;
+        String parameterValue = (String) 
service.getParameterValue("serviceType");
+        if ("proxy".equals(parameterValue)) {
+            if (service.getParameterValue(WSDLConstants.WSDL_4_J_DEFINITION) 
!= null ||
+                    
service.getParameterValue(WSDLConstants.WSDL_20_DESCRIPTION) != null) {
+                isWSDLProvided = true;
+            }
+        }
+        return isWSDLProvided;
+    }
 }

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to