You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2008/03/26 21:35:09 UTC

svn commit: r641557 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/transport/http/HTTPWorker.java metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java

Author: dims
Date: Wed Mar 26 13:35:05 2008
New Revision: 641557

URL: http://svn.apache.org/viewvc?rev=641557&view=rev
Log:
get dynamic ?wsdl working under simple axis server

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=641557&r1=641556&r2=641557&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java Wed Mar 26 13:35:05 2008
@@ -44,6 +44,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -203,6 +205,26 @@
                             outstream.flush();
                             return;
                         } else {
+                            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                            int ret = service.printXSD(baos, schemaName);
+                            if(ret>0) {
+                                baos.flush();
+                                instream = new ByteArrayInputStream(baos.toByteArray());
+                                response.setStatus(HttpStatus.SC_OK);
+                                response.setContentType("text/xml");
+                                OutputStream outstream = response.getOutputStream();
+                                boolean checkLength = true;
+                                int length = Integer.MAX_VALUE;
+                                int nextValue = instream.read();
+                                if (checkLength) length--;
+                                while (-1 != nextValue && length >= 0) {
+                                    outstream.write(nextValue);
+                                    nextValue = instream.read();
+                                    if (checkLength) length--;
+                                }
+                                outstream.flush();
+                                return;
+                            }
                             // no schema available by that name  - send 404
                             response.sendError(HttpStatus.SC_NOT_FOUND, "Schema Not Found!");
                             return;

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java?rev=641557&r1=641556&r2=641557&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java Wed Mar 26 13:35:05 2008
@@ -22,6 +22,7 @@
 import com.sun.tools.ws.spi.WSToolsObjectFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.deployment.util.Utils;
 import org.apache.axis2.dataretrieval.SchemaSupplier;
 import org.apache.axis2.dataretrieval.WSDLSupplier;
 import org.apache.axis2.description.AxisService;
@@ -56,6 +57,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLDecoder;
@@ -123,22 +125,21 @@
         Parameter servletConfigParam = axisConfiguration
                 .getParameter(HTTPConstants.HTTP_SERVLETCONFIG);
 
-        if (servletConfigParam == null) {
-            throw new WebServiceException("Axis2 Can't find ServletConfigParameter");
-        }
-        Object obj = servletConfigParam.getValue();
-        ServletContext servletContext;
         String webBase = null;
-
-        if (obj instanceof ServletConfig) {
-            ServletConfig servletConfig = (ServletConfig) obj;
-            servletContext = servletConfig.getServletContext();
-            webBase = servletContext.getRealPath("/WEB-INF");
-        } else {
-            throw new WebServiceException("Axis2 Can't find ServletConfig");
+        if (servletConfigParam != null) {
+            Object obj = servletConfigParam.getValue();
+            ServletContext servletContext;
+    
+            if (obj instanceof ServletConfig) {
+                ServletConfig servletConfig = (ServletConfig) obj;
+                servletContext = servletConfig.getServletContext();
+                webBase = servletContext.getRealPath("/WEB-INF");
+            } 
         }
 
-        this.classPath = getDefaultClasspath(webBase);
+        if(classPath == null) {
+            this.classPath = getDefaultClasspath(webBase);
+        }
         if (log.isDebugEnabled()) {
             log.debug("For implementation class " + className +
                     " WsGen classpath: " +
@@ -456,7 +457,7 @@
      * @param msgContext
      * @return default classpath
      */
-    public static String getDefaultClasspath(String webBase) {
+    public String getDefaultClasspath(String webBase) {
         HashSet classpath = new HashSet();
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         fillClassPath(cl, classpath);
@@ -479,6 +480,17 @@
                 }
             } catch (Exception e) {
                 // Oh well.  No big deal.
+            }
+        }
+        
+        URL serviceArchive = axisService.getFileName();
+        if(serviceArchive != null) {
+            try {
+                classpath.add(Utils.toFile(serviceArchive).getCanonicalPath());
+            } catch (UnsupportedEncodingException e) {
+                log.error(e.getMessage(), e);
+            } catch (IOException e) {
+                log.error(e.getMessage(), e);
             }
         }
 



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