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 de...@apache.org on 2006/04/26 10:07:35 UTC

svn commit: r397138 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: deployment/repository/util/ deployment/resolver/ description/

Author: deepal
Date: Wed Apr 26 01:07:32 2006
New Revision: 397138

URL: http://svn.apache.org/viewcvs?rev=397138&view=rev
Log:
- fixing xsd imports problem when putting wsdl file inside META-INF

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=397138&r1=397137&r2=397138&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Wed Apr 26 01:07:32 2006
@@ -20,8 +20,8 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.deployment.*;
-import org.apache.axis2.deployment.resolver.AARFileBasedURIResolver;
 import org.apache.axis2.deployment.resolver.AARBasedWSDLLocator;
+import org.apache.axis2.deployment.resolver.AARFileBasedURIResolver;
 import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
@@ -83,7 +83,7 @@
                     axisConfig);
             return groupBuilder.populateServiceGroup(axisServiceGroup);
         }
-       throw new AxisFault("In valid services.xml found");
+        throw new AxisFault("In valid services.xml found");
     }
 
     /**
@@ -165,9 +165,6 @@
         }
     }
 
-    private AxisService processWSDLFile(InputStream in) throws DeploymentException {
-       return processWSDLFile(in,null);
-    }
     /**
      * Creats AxisService.
      *
@@ -175,18 +172,23 @@
      * @return Returns AxisService.
      * @throws DeploymentException
      */
-    private AxisService processWSDLFile(InputStream in,File serviceArchiveFile) throws DeploymentException {
+    private AxisService processWSDLFile(InputStream in, File serviceArchiveFile,
+                                        boolean isArchive) throws DeploymentException {
         try {
             WSDL2AxisServiceBuilder wsdl2AxisServiceBuilder =
                     new WSDL2AxisServiceBuilder(in, null, null);
-            if (serviceArchiveFile!=null){
+            if (serviceArchiveFile != null && isArchive) {
                 wsdl2AxisServiceBuilder.setCustomResolver(
-                    new AARFileBasedURIResolver(serviceArchiveFile));
+                        new AARFileBasedURIResolver(serviceArchiveFile));
                 wsdl2AxisServiceBuilder.setCustomWSLD4JResolver(
-                        new AARBasedWSDLLocator(serviceArchiveFile,in)
+                        new AARBasedWSDLLocator(serviceArchiveFile, in)
                 );
+            } else {
+                if (serviceArchiveFile != null) {
+                    wsdl2AxisServiceBuilder.setBaseUri(
+                            serviceArchiveFile.getParentFile().getAbsolutePath());
+                }
             }
-
             return wsdl2AxisServiceBuilder.populateService();
         } catch (AxisFault axisFault) {
             throw new DeploymentException(axisFault);
@@ -220,7 +222,7 @@
                     File file1 = files[i];
                     if (file1.getName().toLowerCase().endsWith(SUFFIX_WSDL)) {
                         InputStream in = new FileInputStream(file1);
-                        AxisService service = processWSDLFile(in);
+                        AxisService service = processWSDLFile(in, file1, false);
 
                         servicesMap.put(service.getName(), service);
                         try {
@@ -256,7 +258,7 @@
                         }
 
                         ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-                        AxisService service = processWSDLFile(in,serviceFile);
+                        AxisService service = processWSDLFile(in, serviceFile, true);
                         servicesMap.put(service.getName(), service);
                     }
                 }
@@ -310,7 +312,7 @@
             }
         } else {
             File file = new File(filename, MODULE_XML);
-            
+
             if (file.exists() || (file = new File(filename, MODULE_XML.toLowerCase())).exists()) {
                 InputStream in;
                 try {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java?rev=397138&r1=397137&r2=397138&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java Wed Apr 26 01:07:32 2006
@@ -1,17 +1,12 @@
 package org.apache.axis2.deployment.resolver;
 
-import org.xml.sax.InputSource;
 import org.apache.axis2.deployment.DeploymentConstants;
+import org.xml.sax.InputSource;
 
 import javax.wsdl.xml.WSDLLocator;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.ZipInputStream;
+import java.io.*;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -32,7 +27,7 @@
  * Custom WSDL locator to load schemas from zip archives
  * Need to provide the aarFile and the baseInputStream for
  * the base WSDL file
- *
+ * <p/>
  * The logic here is that we only care about the import location
  * all imports must be relative to the META-INF folder
  */
@@ -41,13 +36,12 @@
     private File aarFile;
     private InputStream baseInputStream;
 
-    public AARBasedWSDLLocator(File zipFile,InputStream baseInputStream) {
+    public AARBasedWSDLLocator(File zipFile, InputStream baseInputStream) {
         this.baseInputStream = baseInputStream;
         this.aarFile = zipFile;
     }
 
     /**
-     *
      * @return
      */
     public InputSource getBaseInputSource() {
@@ -55,7 +49,6 @@
     }
 
     /**
-     *
      * @param parentLocation
      * @param importLocation
      * @return
@@ -71,8 +64,9 @@
             int read;
             ByteArrayOutputStream out;
             while ((entry = zin.getNextEntry()) != null) {
-                String entryName = entry.getName().toLowerCase();
-                if (entryName.startsWith(DeploymentConstants.META_INF.toLowerCase())
+                String entryName = entry.getName();
+                if ((entryName.startsWith(DeploymentConstants.META_INF.toLowerCase())
+                        || entryName.startsWith(DeploymentConstants.META_INF))
                         && entryName.endsWith(importLocation)) {
                     //read the item into a byte array to allow the
                     //stream to be closed
@@ -86,12 +80,11 @@
             }
 
 
-
         } catch (IOException e) {
             throw new RuntimeException(e);
-        } finally{
+        } finally {
             try {
-                if (zin!=null) zin.close();
+                if (zin != null) zin.close();
             } catch (IOException e) {
                 //log this error
             }
@@ -103,6 +96,7 @@
     /**
      * As for the zip there is no point in returning
      * a base URI
+     *
      * @return
      */
     public String getBaseURI() {
@@ -112,6 +106,7 @@
 
     /**
      * returns the latest import
+     *
      * @return
      */
     public String getLatestImportURI() {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java?rev=397138&r1=397137&r2=397138&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java Wed Apr 26 01:07:32 2006
@@ -81,8 +81,9 @@
                 int read;
                 ByteArrayOutputStream out;
                 while ((entry = zin.getNextEntry()) != null) {
-                    String entryName = entry.getName().toLowerCase();
-                    if (entryName.startsWith(DeploymentConstants.META_INF.toLowerCase())
+                    String entryName = entry.getName();
+                    if ((entryName.startsWith(DeploymentConstants.META_INF.toLowerCase())
+                        || entryName.startsWith(DeploymentConstants.META_INF))
                             && entryName.endsWith(schemaLocation)) {
                         //read the item into a byte array to allow the
                         //stream to be closed

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java?rev=397138&r1=397137&r2=397138&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java Wed Apr 26 01:07:32 2006
@@ -135,6 +135,7 @@
     private URIResolver customResolver;
 
     private WSDLLocator customWSLD4JResolver;
+    private String baseUri = null;
 
 
     public WSDL2AxisServiceBuilder(InputStream in, QName serviceName,
@@ -969,8 +970,7 @@
             } catch (IOException e) {
                 throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
             }
-
-            return reader.readWSDL(null, doc);
+            return reader.readWSDL(getBaseUri(), doc);
         }
     }
 
@@ -1408,5 +1408,12 @@
         }
     }
 
+    public String getBaseUri() {
+        return baseUri;
+    }
+
+    public void setBaseUri(String baseUri) {
+        this.baseUri = baseUri;
+    }
 
 }