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 am...@apache.org on 2007/10/16 13:46:11 UTC

svn commit: r585125 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen: CodeGenerationEngine.java writer/WSDL11Writer.java

Author: amilas
Date: Tue Oct 16 04:46:05 2007
New Revision: 585125

URL: http://svn.apache.org/viewvc?rev=585125&view=rev
Log:
add support to give xsd files for wsdl imports

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=585125&r1=585124&r2=585125&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Tue Oct 16 04:46:05 2007
@@ -364,7 +364,7 @@
     }
 
     /**
-     * calculates the URI 
+     * calculates the URI
      * needs improvement
      *
      * @param currentURI
@@ -372,6 +372,11 @@
     private String getURI(String currentURI) throws URISyntaxException, IOException {
 
         File file = new File(currentURI);
-        return file.getCanonicalFile().toURI().toString();
+        if (file.exists()){
+            return file.getCanonicalFile().toURI().toString();
+        } else {
+            return currentURI;
+        }
+
     }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java?rev=585125&r1=585124&r2=585125&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/WSDL11Writer.java Tue Oct 16 04:46:05 2007
@@ -74,8 +74,8 @@
             if (axisService != null) {
                 Map baseURIwsdlNameMap = new HashMap();
                 // add the initial definition to the map
-                baseURIwsdlNameMap.put(definition.getDocumentBaseURI(),axisService.getName());
-                writeWSDL(definition, axisService.getName(), changedMap, baseURIwsdlNameMap);
+                baseURIwsdlNameMap.put(definition.getDocumentBaseURI(),axisService.getName() + ".wsdl");
+                writeWSDL(definition, axisService.getName() + ".wsdl", changedMap, baseURIwsdlNameMap);
             }
         } catch (Exception e) {
             throw new RuntimeException("WSDL writing failed!", e);
@@ -83,7 +83,7 @@
     }
 
     private void writeWSDL(Definition definition,
-                           String serviceName,
+                           String fileName,
                            Map changedMap,
                            Map baseURIwsdlNameMap) throws Exception {
         // first process the imports and save them.
@@ -102,18 +102,28 @@
                     // we have to process this wsdl file only if it has not been processed earlier
                     if (!baseURIwsdlNameMap.containsKey(wsdlLocation)) {
                         wsdlName = wsdlLocation.substring(wsdlLocation.lastIndexOf('/') + 1);
+                        if (!wsdlName.endsWith(".wsdl") && !wsdlName.endsWith(".xsd")){
+                           // this seems to be an online wsdl so we generate a dummy name
+                           if (wsdlName.indexOf("xsd") > -1){
+                               wsdlName = "xsd" + count++ + ".xsd";
+                           } else {
+                               wsdlName = "wsdl" + count++ + ".wsdl";
+                           }
+                        }
 
                         //trim the wsdl part
-                        wsdlName = wsdlName.substring(0, wsdlName.indexOf(".wsdl"));
                         while (baseURIwsdlNameMap.containsValue(wsdlName)) {
-                            wsdlName = wsdlName + count++;
+                            // import file name can either be xsd or wsdl
+                            String fileNamePart = wsdlName.substring(0,wsdlName.lastIndexOf("."));
+                            String extension = wsdlName.substring(wsdlName.lastIndexOf("."));
+                            wsdlName = fileNamePart + count++ + extension;
                         }
                         baseURIwsdlNameMap.put(wsdlLocation, wsdlName);
                         Definition innerDefinition = wsdlImport.getDefinition();
                         writeWSDL(innerDefinition, wsdlName, changedMap, baseURIwsdlNameMap);
                     }
 
-                    wsdlImport.setLocationURI(baseURIwsdlNameMap.get(wsdlLocation) + ".wsdl");
+                    wsdlImport.setLocationURI((String)baseURIwsdlNameMap.get(wsdlLocation));
                 }
             }
         }
@@ -122,7 +132,7 @@
         // finally save the file
         WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
         File outputFile = FileWriter.createClassFile(baseFolder,
-                                                     null, serviceName, ".wsdl");
+                                                     null, fileName, null);
         FileOutputStream out = new FileOutputStream(outputFile);
 
         // we have a catch here
@@ -142,7 +152,7 @@
            Service service;
            for (Iterator iter = servicesList.iterator();iter.hasNext();){
                service = (Service) iter.next();
-               if (!service.getQName().getLocalPart().equals(serviceName)){
+               if (!service.getQName().getLocalPart().equals(fileName)){
                    definition.removeService(service.getQName());
                    removedServices.add(service);
                }



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