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 pr...@apache.org on 2007/10/30 13:11:15 UTC

svn commit: r590048 [8/9] - in /webservices/axis2/branches/java/jaxws21: legal/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/ modules/adb-codegen/src/org/apache/axis2/schema/template/ modules/adb-codegen/src/org/apache/axis2/sch...

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/MessageContext.java Tue Oct 30 05:10:34 2007
@@ -861,6 +861,33 @@
 
     /**
      * Retrieves a property value. The order of search is as follows: search in
+     * my own options and then look locally. Does not search up the hierarchy.
+     *
+     * @param name name of the property to search for
+     * @return the value of the property, or null if the property is not found
+     */
+    public Object getLocalProperty(String name) {
+        if (LoggingControl.debugLoggingAllowed) {
+            checkActivateWarning("getProperty");
+        }
+
+        // search in my own options
+        Object obj = super.getLocalProperty(name);
+        if (obj != null) {
+            return obj;
+        }
+
+        obj = options.getProperty(name);
+        if (obj != null) {
+            return obj;
+        }
+
+        // tough
+        return null;
+    }
+    
+    /**
+     * Retrieves a property value. The order of search is as follows: search in
      * my own options and then look in my context hierarchy. Since its possible
      * that the entire hierarchy is not present, I will start at whatever level
      * has been set and start there.

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectInput.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectInput.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectInput.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectInput.java Tue Oct 30 05:10:34 2007
@@ -143,7 +143,7 @@
         trace("start readObject()");
         Object value = oi.readObject();
         
-        trace("end readObject()="+ value);
+        trace("end readObject()="+ valueName(value));
         return value;
     }
 
@@ -195,4 +195,13 @@
         }
     }
     
+    private String valueName(Object obj) {
+        if (obj == null) {
+            return "null";
+        } else if (obj instanceof String) {
+            return (String) obj;
+        } else {
+            return "Object of class = " + obj.getClass().getName();
+        }
+    }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectOutputStream.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectOutputStream.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/DebugObjectOutputStream.java Tue Oct 30 05:10:34 2007
@@ -131,7 +131,7 @@
     }
 
     public void writeObject(Object obj) throws IOException {
-        trace ("start writeObject(v) v=" + obj);
+        trace ("start writeObject(v) v=" + valueName(obj));
         out.writeObject(obj);
         trace ("end writeObject(v)");
     }
@@ -151,6 +151,16 @@
     public void trace(String str) {
         if (isDebug) {
             log.debug(str);
+        }
+    }
+    
+    private String valueName(Object obj) {
+        if (obj == null) {
+            return "null";
+        } else if (obj instanceof String) {
+            return (String) obj;
+        } else {
+            return "Object of class = " + obj.getClass().getName();
         }
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectInputStream.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectInputStream.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectInputStream.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectInputStream.java Tue Oct 30 05:10:34 2007
@@ -200,7 +200,7 @@
                 }
                 // Put the key and value in the map
                 if (isDebug) {
-                    log.debug("Read key=" + key + " value="+value);
+                    log.debug("Read key=" + valueName(key) + " value="+valueName(value));
                 }
                 map.put(key, value);
             } catch (ClassNotFoundException e) {
@@ -273,9 +273,9 @@
                     tempOIS.close();
                     bais.close();
                 }
-                // Put the key and value in the map
+                // Put the key and value in the list
                 if (isDebug) {
-                    log.debug("Read value="+value);
+                    log.debug("Read value="+valueName(value));
                 }
                 list.add(value);
             } catch (IOException e) {
@@ -341,10 +341,20 @@
         }
         
         if (isDebug) {
-            log.debug("Read object=" + obj);
+            log.debug("Read object=" + valueName(obj));
         }
         return obj;   
         
+    }
+    
+    private String valueName(Object obj) {
+        if (obj == null) {
+            return "null";
+        } else if (obj instanceof String) {
+            return (String) obj;
+        } else {
+            return "Object of class = " + obj.getClass().getName();
+        }
     }
     
     /**

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectOutputStream.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectOutputStream.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/context/externalize/SafeObjectOutputStream.java Tue Oct 30 05:10:34 2007
@@ -332,7 +332,7 @@
                        boolean isSafe) throws IOException {
         
         if (isDebug) {
-            log.debug("Writing object:" + obj);
+            log.debug("Writing object:" + valueName(obj));
         }
         
         // Shortcut for null objects
@@ -431,7 +431,8 @@
                        boolean isSafe2) throws IOException {
         
         if (isDebug) {
-            log.debug("Writing key=" + obj1 + " value="+obj2);
+            log.debug("Writing key=" + valueName(obj1) + 
+                      " value="+valueName(obj2));
         }
         // Shortcut for non-serializable objects
         if ((!isSafe1 && !isSerializable(obj1)) ||
@@ -505,7 +506,7 @@
                        boolean isSafe) throws IOException {
         
         if (isDebug) {
-            log.debug("Writing obj=" + obj);
+            log.debug("Writing obj=" + valueName(obj));
         }
         // Shortcut for non-serializable objects
         if (!isSafe && !isSerializable(obj)) {
@@ -692,6 +693,15 @@
         }
     }
     
+    private String valueName(Object obj) {
+        if (obj == null) {
+            return "null";
+        } else if (obj instanceof String) {
+            return (String) obj;
+        } else {
+            return "Object of class = " + obj.getClass().getName();
+        }
+    }
     /**
      * MyBAOS is a ByteArrayOutputStream with a few additions.
      *

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Tue Oct 30 05:10:34 2007
@@ -338,10 +338,12 @@
                 String wsdlLocation =  "META-INF/service.wsdl";
                 InputStream wsdlStream =
                         serviceClassLoader.getResourceAsStream(wsdlLocation);
+                URL wsdlURL = serviceClassLoader.getResource(metainf + "/service.wsdl");
                 if (wsdlStream == null) {
                     wsdlLocation =  "META-INF/" + serviceName + ".wsdl";
                     wsdlStream = serviceClassLoader
                             .getResourceAsStream(wsdlLocation);
+                    wsdlURL = serviceClassLoader.getResource(wsdlLocation);
                 }
                 if (wsdlStream != null) {
                     WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder =
@@ -353,6 +355,9 @@
                         wsdl2AxisServiceBuilder.setCustomResolver(
                                 new AARFileBasedURIResolver(file));
                     }
+                    if (wsdlURL != null) {
+                        wsdl2AxisServiceBuilder.setDocumentBaseUri(wsdlURL.toString());
+                    }
                     axisService = wsdl2AxisServiceBuilder.populateService();
                     axisService.setWsdlFound(true);
                     axisService.setCustomWsdl(true);
@@ -381,10 +386,13 @@
                     String wsdlLocation =  "META-INF/service.wsdl";
                     InputStream wsdlStream =
                             serviceClassLoader.getResourceAsStream(wsdlLocation);
+                    URL wsdlURL = serviceClassLoader.getResource(wsdlLocation);
                     if (wsdlStream == null) {
                         wsdlLocation =  "META-INF/" + serviceName + ".wsdl";
                         wsdlStream = serviceClassLoader
                                 .getResourceAsStream(wsdlLocation);
+                        wsdlURL =
+                                serviceClassLoader.getResource(wsdlLocation);
                     }
                     if (wsdlStream != null) {
                         WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder =
@@ -395,6 +403,9 @@
                                         new AARBasedWSDLLocator(wsdlLocation, file, wsdlStream));
                             wsdl2AxisServiceBuilder.setCustomResolver(
                                     new AARFileBasedURIResolver(file));
+                        }
+                        if (wsdlURL != null) {
+                            wsdl2AxisServiceBuilder.setDocumentBaseUri(wsdlURL.toString());
                         }
                         axisService = wsdl2AxisServiceBuilder.populateService();
                         axisService.setWsdlFound(true);

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Tue Oct 30 05:10:34 2007
@@ -35,7 +35,15 @@
 import org.apache.axis2.deployment.resolver.AARFileBasedURIResolver;
 import org.apache.axis2.deployment.resolver.WarBasedWSDLLocator;
 import org.apache.axis2.deployment.resolver.WarFileBasedURIResolver;
-import org.apache.axis2.description.*;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.WSDL20ToAllAxisServicesBuilder;
+import org.apache.axis2.description.WSDL20ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.namespace.Constants;
@@ -52,6 +60,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -212,8 +222,12 @@
                         new AARFileBasedURIResolver(serviceArchiveFile));
                 if (axisServiceBuilder instanceof WSDL11ToAllAxisServicesBuilder) {
 
-                    ((WSDL11ToAllAxisServicesBuilder) axisServiceBuilder).setCustomWSLD4JResolver(
+                    ((WSDL11ToAllAxisServicesBuilder) axisServiceBuilder).setCustomWSDLResolver(
                             new AARBasedWSDLLocator(baseURI, serviceArchiveFile, in));
+
+                    ((WSDL11ToAllAxisServicesBuilder) axisServiceBuilder).setDocumentBaseUri(
+                            serviceArchiveFile.getCanonicalFile().toURI().toString());
+
                 } else if (axisServiceBuilder instanceof WSDL20ToAllAxisServicesBuilder) {
                     // trying to use the jar scheme as the base URI. I think this can be used to handle
                     // wsdl 1.1 as well without using a custom URI resolver. Need to look at it later.
@@ -224,6 +238,11 @@
                 if (serviceArchiveFile != null) {
                     axisServiceBuilder.setBaseUri(
                             serviceArchiveFile.getParentFile().toURI().toString());
+
+                    if (axisServiceBuilder instanceof WSDL11ToAllAxisServicesBuilder) {
+                        ((WSDL11ToAllAxisServicesBuilder) axisServiceBuilder).setDocumentBaseUri(
+                                serviceArchiveFile.getCanonicalFile().toURI().toString());
+                    }
                 }
             }
             if (axisServiceBuilder instanceof WSDL11ToAllAxisServicesBuilder) {
@@ -236,6 +255,11 @@
             if (log.isDebugEnabled()) {
                 log.debug(axisFault);
             }
+        } catch (IOException ioex) {
+            log.info("Trouble processing wsdl file :" + ioex.getMessage());
+            if (log.isDebugEnabled()) {
+                log.debug(ioex);
+            }
         }
         return null;
     }
@@ -326,6 +350,7 @@
                                     equals(documentElementNS.getNamespaceURI())) {
                                 wsdlToAxisServiceBuilder = new WSDL11ToAllAxisServicesBuilder(
                                         new ByteArrayInputStream(out.toByteArray()));
+                                ((WSDL11ToAxisServiceBuilder) wsdlToAxisServiceBuilder).setDocumentBaseUri(entryName);
                             } else {
                                 throw new DeploymentException(Messages.getMessage("invalidWSDLFound"));
                             }
@@ -384,7 +409,7 @@
                     equals(documentElementNS.getNamespaceURI())) {
                 wsdlToAxisServiceBuilder = new WSDL11ToAllAxisServicesBuilder(
                         new ByteArrayInputStream(out.toByteArray()));
-                wsdlToAxisServiceBuilder.setCustomWSLD4JResolver(new WarBasedWSDLLocator(wsdlUrl,
+                wsdlToAxisServiceBuilder.setCustomWSDLResolver(new WarBasedWSDLLocator(wsdlUrl,
                                                                                          loader,
                                                                                          new ByteArrayInputStream(
                                                                                                  out.toByteArray())));
@@ -423,6 +448,8 @@
                             equals(documentElementNS.getNamespaceURI())) {
                         in2 = new FileInputStream(file1);
                         wsdlToAxisServiceBuilder = new WSDL11ToAllAxisServicesBuilder(in2);
+                        ((WSDL11ToAxisServiceBuilder) wsdlToAxisServiceBuilder).setDocumentBaseUri(file1.toURI()
+                                                                                                        .toString());
                     } else {
                         throw new DeploymentException(Messages.getMessage("invalidWSDLFound"));
                     }

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService.java Tue Oct 30 05:10:34 2007
@@ -1626,6 +1626,9 @@
             WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
             reader.setFeature("javax.wsdl.importDocuments", true);
             Definition wsdlDefinition = reader.readWSDL(getBaseURI(wsdlURL.toString()), doc);
+            if (wsdlDefinition != null) {
+                wsdlDefinition.setDocumentBaseURI(getDocumentURI(wsdlURL.toString()));
+            }
             return createClientSideAxisService(wsdlDefinition, wsdlServiceName, portName, options);
         } catch (IOException e) {
             log.error(e.getMessage(), e);
@@ -1655,6 +1658,15 @@
         }
     }
 
+    private static String getDocumentURI(String currentURI)  {
+        try {
+            File file = new File(currentURI);
+            return file.getCanonicalFile().toURI().toString();
+        } catch (IOException e) {
+            return null;
+        }
+    }
+
     public static AxisService createClientSideAxisService(Definition wsdlDefinition,
                                                           QName wsdlServiceName,
                                                           String portName,
@@ -1957,10 +1969,11 @@
         Map changedScheamLocations = null;
         if (!this.schemaLocationsAdjusted) {
             Hashtable nameTable = new Hashtable();
+            Hashtable sourceURIToNewLocationMap = new Hashtable();
             //calculate unique names for the schemas
-            calcualteSchemaNames(schema, nameTable);
+            calcualteSchemaNames(schema, nameTable, sourceURIToNewLocationMap);
             //adjust the schema locations as per the calculated names
-            changedScheamLocations = adjustSchemaNames(schema, nameTable);
+            changedScheamLocations = adjustSchemaNames(schema, nameTable,sourceURIToNewLocationMap);
             //reverse the nametable so that there is a mapping from the
             //name to the schemaObject
             setSchemaMappingTable(swapMappingTable(nameTable));
@@ -1975,7 +1988,7 @@
      *
      * @param schemas
      */
-    private void calcualteSchemaNames(List schemas, Hashtable nameTable) {
+    private void calcualteSchemaNames(List schemas, Hashtable nameTable, Hashtable sourceURIToNewLocationMap) {
         //first traversal - fill the hashtable
         for (int i = 0; i < schemas.size(); i++) {
             XmlSchema schema = (XmlSchema) schemas.get(i);
@@ -1987,13 +2000,11 @@
                 if (item instanceof XmlSchemaExternal) {
                     XmlSchemaExternal externalSchema = (XmlSchemaExternal) item;
                     s = externalSchema.getSchema();
-                    if (s != null && nameTable.get(s) == null) {
+                    if (s != null && sourceURIToNewLocationMap.get(s.getSourceURI()) == null) {
                         //insert the name into the table
-                        insertIntoNameTable(nameTable, s);
+                        insertIntoNameTable(nameTable, s, sourceURIToNewLocationMap);
                         //recursively call the same procedure
-                        calcualteSchemaNames(Arrays.asList(
-                                new XmlSchema[]{s}),
-                                             nameTable);
+                        calcualteSchemaNames(Arrays.asList(new XmlSchema[]{s}), nameTable, sourceURIToNewLocationMap);
                     }
                 }
             }
@@ -2006,36 +2017,47 @@
      * @param nameTable
      * @param s
      */
-    private void insertIntoNameTable(Hashtable nameTable, XmlSchema s) {
+    private void insertIntoNameTable(Hashtable nameTable, XmlSchema s, Hashtable sourceURIToNewLocationMap) {
         String sourceURI = s.getSourceURI();
-        sourceURI = sourceURI.substring(sourceURI.lastIndexOf('/') + 1);
-        //remove the .xsd extention
-        sourceURI = sourceURI.substring(0,sourceURI.indexOf("."));
+        String newURI = sourceURI.substring(sourceURI.lastIndexOf('/') + 1);
+        if (newURI.endsWith(".xsd")) {
+            //remove the .xsd extention
+            newURI = newURI.substring(0, newURI.lastIndexOf("."));
+        } else {
+            newURI = "xsd" + count++;
+        }
+
+        newURI = customSchemaNameSuffix != null? newURI + customSchemaNameSuffix: newURI;
         // make it unique
-        while(nameTable.containsValue(sourceURI)){
-            sourceURI = sourceURI + count++;
+        while(nameTable.containsValue(newURI)){
+            newURI = newURI + count++;
         }
 
-        nameTable.put(s,
-                      (sourceURI)
-                      + (customSchemaNameSuffix != null ?
-                         customSchemaNameSuffix :
-                         ""));
+        nameTable.put(s, newURI);
+        sourceURIToNewLocationMap.put(sourceURI,newURI);
     }
 
     /**
      * Run 2  - adjust the names
      */
-    private Map adjustSchemaNames(List schemas, Hashtable nameTable) {
+    private Map adjustSchemaNames(List schemas,
+                                  Hashtable nameTable,
+                                  Hashtable sourceURIToNewLocationMap) {
         Hashtable importedSchemas = new Hashtable();
         //process the schemas in the main schema list
         for (int i = 0; i < schemas.size(); i++) {
-            adjustSchemaName((XmlSchema) schemas.get(i), nameTable, importedSchemas);
+            adjustSchemaName((XmlSchema) schemas.get(i),
+                    nameTable,
+                    importedSchemas,
+                    sourceURIToNewLocationMap);
         }
         //process all the rest in the name table
         Enumeration nameTableKeys = nameTable.keys();
         while (nameTableKeys.hasMoreElements()) {
-            adjustSchemaName((XmlSchema) nameTableKeys.nextElement(), nameTable, importedSchemas);
+            adjustSchemaName((XmlSchema) nameTableKeys.nextElement(),
+                    nameTable,
+                    importedSchemas,
+                    sourceURIToNewLocationMap);
 
         }
         return importedSchemas;
@@ -2047,15 +2069,21 @@
      * @param parentSchema
      * @param nameTable
      */
-    private void adjustSchemaName(XmlSchema parentSchema, Hashtable nameTable,
-                                  Hashtable importedScheams) {
+    private void adjustSchemaName(XmlSchema parentSchema,
+                                  Hashtable nameTable,
+                                  Hashtable importedScheams,
+                                  Hashtable sourceURIToNewLocationMap) {
         XmlSchemaObjectCollection includes = parentSchema.getIncludes();
         for (int j = 0; j < includes.getCount(); j++) {
             Object item = includes.getItem(j);
             if (item instanceof XmlSchemaExternal) {
                 XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal) item;
                 XmlSchema s = xmlSchemaExternal.getSchema();
-                adjustSchemaLocation(s, xmlSchemaExternal, nameTable, importedScheams);
+                adjustSchemaLocation(s,
+                        xmlSchemaExternal,
+                        nameTable,
+                        importedScheams,
+                        sourceURIToNewLocationMap);
             }
         }
 
@@ -2068,27 +2096,21 @@
      * @param xmlSchemaExternal
      * @param nameTable
      */
-    private void adjustSchemaLocation(XmlSchema s, XmlSchemaExternal xmlSchemaExternal,
-                                      Hashtable nameTable, Hashtable importedScheams) {
+    private void adjustSchemaLocation(XmlSchema s,
+                                      XmlSchemaExternal xmlSchemaExternal,
+                                      Hashtable nameTable,
+                                      Hashtable importedScheams,
+                                      Hashtable sourceURIToNewLocationMap) {
         if (s != null) {
-            String schemaLocation = xmlSchemaExternal.getSchemaLocation();
-            if (importedScheams.get(schemaLocation) != null) {
-                xmlSchemaExternal.setSchemaLocation(
-                        (String) importedScheams.get(xmlSchemaExternal.getSchemaLocation()));
-            } else {
-                String newscheamlocation = customSchemaNamePrefix == null ?
-                                           //use the default mode
-                                           (getName() +
-                                            "?xsd=" +
-                                            nameTable.get(s)) :
-                                                              //custom prefix is present - add the custom prefix
-                                                              (customSchemaNamePrefix +
-                                                               nameTable.get(s));
-                xmlSchemaExternal.setSchemaLocation(
-                        newscheamlocation);
-                importedScheams.put(schemaLocation, newscheamlocation);
-            }
 
+            String newscheamlocation = customSchemaNamePrefix == null ?
+                    //use the default mode
+                    (getName() + "?xsd=" + sourceURIToNewLocationMap.get(s.getSourceURI())) :
+                    //custom prefix is present - add the custom prefix
+                    (customSchemaNamePrefix + sourceURIToNewLocationMap.get(s.getSourceURI()));
+            String schemaLocation = xmlSchemaExternal.getSchemaLocation();
+            xmlSchemaExternal.setSchemaLocation(newscheamlocation);
+            importedScheams.put(schemaLocation, newscheamlocation);
         }
     }
 

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Tue Oct 30 05:10:34 2007
@@ -147,6 +147,7 @@
         namespaceMap.put(prefix, axisService.getTargetNamespace());
         tns = ele.declareNamespace(axisService.getTargetNamespace(), prefix);
 
+        // axis2.xml indicated no HTTP binding?
         boolean disableREST = false;
         Parameter disableRESTParameter =
                 axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
@@ -154,6 +155,15 @@
                 JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
             disableREST = true;
         }
+        
+        // axis2.xml indicated no SOAP 1.2 binding?
+        boolean disableSOAP12 = false;
+        Parameter disableSOAP12Parameter =
+        axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+        if (disableSOAP12Parameter != null &&
+                JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+            disableSOAP12 = true;
+        }
 
         // adding documentation element
         // <documentation>&lt;b&gt;NEW!&lt;/b&gt; This method accepts an ISBN
@@ -189,12 +199,14 @@
         generateMessages(fac, ele);
         generatePortType(fac, ele);
         generateSOAP11Binding(fac, ele);
-        generateSOAP12Binding(fac, ele);
+        if (!disableSOAP12) {
+            generateSOAP12Binding(fac, ele);
+        }
         if (!disableREST) {
             generateHTTPBinding(fac, ele);
         }
 
-        generateService(fac, ele, disableREST);
+        generateService(fac, ele, disableREST, disableSOAP12);
         addPoliciesToDefinitionElement(policiesInDefinitions.values()
                 .iterator(), definition);
 
@@ -439,15 +451,18 @@
      * @param fac the active OMFactory
      * @param defintions the WSDL &lt;definitions&gt; element under which to put the service
      * @param disableREST if false, generate REST binding, if true, don't
+     * @param disableSOAP12 if false, generate SOAP 1.2 binding, if true, don't
      * @throws Exception if there's a problem
      */
-    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST)
+    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST, boolean disableSOAP12)
             throws Exception {
         OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
         defintions.addChild(service);
         service.addAttribute(ATTRIBUTE_NAME, axisService.getName(), null);
         generateSOAP11Ports(fac, service);
-        generateSOAP12Ports(fac, service);
+        if (!disableSOAP12) {
+            generateSOAP12Ports(fac, service);
+        }
 
         addPolicyAsExtElement(PolicyInclude.SERVICE_POLICY, axisService
                 .getPolicyInclude(), service);

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Tue Oct 30 05:10:34 2007
@@ -25,14 +25,23 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAP12Constants;
 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.description.java2wsdl.Java2WSDLConstants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamConstants;
@@ -44,7 +53,9 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.HashMap;
 import java.net.URI;
+import java.net.URISyntaxException;
 
 public class AxisService2WSDL20 implements WSDL2Constants {
 
@@ -184,6 +195,7 @@
         // Add the interface element
         descriptionElement.addChild(getInterfaceElement(wsdl, tns, wsdlx, omFactory, interfaceName));
 
+        // axis2.xml indicated no HTTP binding?
         boolean disableREST = false;
         Parameter disableRESTParameter =
                 axisService.getParameter(Constants.Configuration.DISABLE_REST);
@@ -192,6 +204,15 @@
             disableREST = true;
         }
 
+        // axis2.xml indicated no SOAP 1.2 binding?
+        boolean disableSOAP12 = false;
+        Parameter disableSOAP12Parameter =
+        axisService.getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+        if (disableSOAP12Parameter != null &&
+                JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+            disableSOAP12 = true;
+        }        
+        
         // Check whether the axisService has any endpoints. If they exists serialize them else
         // generate default endpoint elements.
         Set bindings = new HashSet();
@@ -212,11 +233,22 @@
                 AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
                 AxisBinding axisBinding = axisEndpoint.getBinding();
                 String type = axisBinding.getType();
+                
+                // If HTTP binding is disabled, do not add.
                 if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
                     if (disableREST) {
                         continue;
                     }
                 }
+                
+                // If SOAP 1.2 binding is disabled, do not add.
+                String propertySOAPVersion = (String)axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
+                if (propertySOAPVersion != null) {
+                    if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
+                        continue;
+                    }
+                }
+                
                 bindings.add(axisBinding);
                 for (int i = 0; i < eprs.length; i++) {
                     String epr = eprs[i];
@@ -260,9 +292,11 @@
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
                                                                 tns));
+            if (!disableSOAP12) {
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl, wsoap,
                                                                 tns));
+            }
             if (!disableREST) {
                 descriptionElement.addChild(
                         WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
@@ -271,7 +305,7 @@
             }
             descriptionElement
                     .addChild(WSDLSerializationUtil.generateServiceElement(omFactory, wsdl, tns,
-                                                                           axisService, disableREST, eprs));
+                                                                           axisService, disableREST, disableSOAP12, eprs));
         }
 
         return descriptionElement;
@@ -288,7 +322,8 @@
      * @return The generated interface element
      */
     private OMElement getInterfaceElement(OMNamespace wsdl, OMNamespace tns, OMNamespace wsdlx,
-                                          OMFactory fac, String interfaceName) {
+                                          OMFactory fac, String interfaceName)
+            throws URISyntaxException, AxisFault {
 
         OMElement interfaceElement = fac.createOMElement(WSDL2Constants.INTERFACE_LOCAL_NAME, wsdl);
         interfaceElement.addAttribute(fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null,
@@ -320,7 +355,7 @@
                     interfaceElement.addChild(faultElement);
                 }
             }
-
+                     
         }
         for (i = 0; i < interfaceOperations.size(); i++) {
             interfaceElement.addChild((OMNode) interfaceOperations.get(i));
@@ -364,7 +399,8 @@
     public OMElement generateInterfaceOperationElement(AxisOperation axisOperation,
                                                        OMNamespace wsdl,
                                                        OMNamespace tns,
-                                                       OMNamespace wsdlx) {
+                                                       OMNamespace wsdlx) throws
+            URISyntaxException, AxisFault {
         OMFactory omFactory = OMAbstractFactory.getOMFactory();
         OMElement axisOperationElement =
                 omFactory.createOMElement(WSDL2Constants.OPERATION_LOCAL_NAME, wsdl);
@@ -373,6 +409,13 @@
                                                                       null,
                                                                       axisOperation.getName().getLocalPart()));
         URI[] opStyle = (URI[]) axisOperation.getParameterValue(WSDL2Constants.OPERATION_STYLE);
+        if (opStyle == null) {
+            opStyle = checkStyle(axisOperation);
+            Parameter opStyleParameter = new Parameter();
+            opStyleParameter.setName(WSDL2Constants.OPERATION_STYLE);
+            opStyleParameter.setValue(opStyle);
+            axisOperation.addParameter(opStyleParameter);
+        }
         if (opStyle != null && opStyle.length > 0) {
             String style = opStyle[0].toString();
             for (int i = 1; i < opStyle.length; i++) {
@@ -435,5 +478,170 @@
 
     public void setEPRs(String[] eprs) {
         this.eprs = eprs;
+    }
+
+    /**
+     * This function checks the schema and returns the WSDL 2.0 styles that it conform to.
+     * It checks for RPC, IRI and Multipart styles.
+     * For full details on the rules please refer http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#styles
+     * @param axisOperation - The axisOperation that needs to be checked
+     * @return String [] - An array of styles that the operation adheres to.
+     */
+    private URI [] checkStyle(AxisOperation axisOperation) throws URISyntaxException {
+        boolean isRPC = true;
+        boolean isMultipart = true;
+        boolean isIRI = true;
+        ArrayList styles = new ArrayList(3);
+
+        String mep = axisOperation.getMessageExchangePattern();
+        if (!(WSDL2Constants.MEP_URI_IN_ONLY.equals(mep) ||
+                WSDL2Constants.MEP_URI_IN_OUT.equals(mep))) {
+            isRPC = false;
+        }
+
+        QName inMessageElementQname;
+        Map inMessageElementDetails = new HashMap();
+        AxisMessage inMessage = axisOperation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN);
+        if (inMessage != null) {
+            QName qName = inMessage.getElementQName();
+            if (qName == null || Constants.XSD_ANY.equals(qName)) {
+                return new URI [0];
+            }
+            XmlSchemaElement schemaElement = inMessage.getSchemaElement();
+            if (schemaElement != null) {
+                if (!axisOperation.getName().getLocalPart().equals(schemaElement.getName())) {
+                    return new URI [0];
+                }
+                inMessageElementQname = schemaElement.getQName();
+                XmlSchemaType type = schemaElement.getSchemaType();
+                if (type != null && type instanceof XmlSchemaComplexType){
+                    XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+                    XmlSchemaParticle particle = complexType.getParticle();
+                    if (particle != null && particle instanceof XmlSchemaSequence){
+                        XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
+                        XmlSchemaObjectCollection schemaObjectCollection = xmlSchemaSequence.getItems();
+                        if (schemaObjectCollection != null) {
+                            Iterator iterator = schemaObjectCollection.getIterator();
+                            while (iterator.hasNext()) {
+                                Object next = iterator.next();
+                                if (!(next instanceof XmlSchemaElement)) {
+                                    return new URI [0];
+                                }
+                                XmlSchemaElement innerElement = (XmlSchemaElement) next;
+                                if (innerElement.getRefName() != null) {
+                                    return new URI [0];
+                                }
+                                if (innerElement.getMinOccurs() != 1 || innerElement.getMaxOccurs() != 1) {
+                                    isMultipart = false;
+                                }
+                                XmlSchemaType schemaType = innerElement.getSchemaType();
+                                QName innerElementQName = innerElement.getSchemaTypeName();
+                                if (schemaType instanceof XmlSchemaSimpleType) {
+                                    if (Constants.XSD_QNAME.equals(innerElementQName) ||
+                                            Constants.XSD_NOTATION.equals(innerElementQName) ||
+                                            Constants.XSD_HEXBIN.equals(innerElementQName) ||
+                                            Constants.XSD_BASE64.equals(innerElementQName)) {
+                                            isIRI = false;
+                                    }
+                                } else {
+                                    isIRI = false;
+                                }
+                                if (Constants.XSD_ANY.equals(innerElementQName) && iterator.hasNext()) {
+                                    isRPC = false;
+                                }
+                                String name = innerElement.getName();
+                                if (inMessageElementDetails.get(name) != null) {
+                                    isRPC = false;
+                                    isMultipart = false;
+                                }
+                                inMessageElementDetails.put(name, innerElementQName);
+                            }
+                        }
+                    } else {
+                        return new URI [0];
+                    }
+                } else {
+                        return new URI [0];
+                    }
+            } else {
+                return new URI [0];
+            }
+        } else {
+            return new URI [0];
+        }
+        if (isRPC && !WSDL2Constants.MEP_URI_IN_ONLY.equals(mep)) {
+            AxisMessage outMessage = axisOperation.getMessage(WSDL2Constants.MESSAGE_LABEL_OUT);
+            QName qName = outMessage.getElementQName();
+            if (qName == null && Constants.XSD_ANY.equals(qName)) {
+                isRPC = false;
+            }
+            XmlSchemaElement schemaElement = outMessage.getSchemaElement();
+            if (schemaElement != null) {
+                if (!(axisOperation.getName().getLocalPart() + Java2WSDLConstants.RESPONSE)
+                        .equals(schemaElement.getName())) {
+                    isRPC = false;
+                }
+                if (!schemaElement.getQName().getNamespaceURI()
+                        .equals(inMessageElementQname.getNamespaceURI())) {
+                    isRPC = false;
+                }
+                XmlSchemaType type = schemaElement.getSchemaType();
+                if (type != null && type instanceof XmlSchemaComplexType) {
+                    XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+                    XmlSchemaParticle particle = complexType.getParticle();
+                    if (particle != null && particle instanceof XmlSchemaSequence) {
+                        XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
+                        XmlSchemaObjectCollection schemaObjectCollection =
+                                xmlSchemaSequence.getItems();
+                        if (schemaObjectCollection != null) {
+                            Iterator iterator = schemaObjectCollection.getIterator();
+                            Map outMessageElementDetails = new HashMap();
+                            while (iterator.hasNext()) {
+                                Object next = iterator.next();
+                                if (!(next instanceof XmlSchemaElement)) {
+                                    isRPC = false;
+                                }
+                                XmlSchemaElement innerElement = (XmlSchemaElement) next;
+                                QName schemaTypeName = innerElement.getSchemaTypeName();
+                                String name = innerElement.getName();
+                                if (innerElement.getRefName() != null) {
+                                    isRPC = false;
+                                }
+                                if (outMessageElementDetails.get(name) != null) {
+                                    isRPC = false;
+                                }
+                                QName inMessageElementType =
+                                        (QName) inMessageElementDetails.get(name);
+                                if (inMessageElementType != null &&
+                                        inMessageElementType != schemaTypeName) {
+                                    isRPC = false;
+                                }
+                                outMessageElementDetails.put(name, schemaTypeName);
+                            }
+                        }
+                    } else {
+                        isRPC = false;
+                    }
+                } else {
+                    isRPC = false;
+                }
+            } else {
+                isRPC = false;
+            }
+        }
+        int count = 0;
+        if (isRPC) {
+            styles.add(new URI(WSDL2Constants.STYLE_RPC));
+            count ++;
+        }
+        if (isIRI) {
+            styles.add(new URI(WSDL2Constants.STYLE_IRI));
+            count ++;
+        }
+        if (isMultipart) {
+            styles.add(new URI(WSDL2Constants.STYLE_MULTIPART));
+            count ++;
+        }
+        return (URI[]) styles.toArray(new URI[count]);
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Tue Oct 30 05:10:34 2007
@@ -19,9 +19,10 @@
 package org.apache.axis2.description;
 
 import com.ibm.wsdl.util.xml.DOM2Writer;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AddressingHelper;
 import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.util.RESTUtil;
@@ -30,25 +31,46 @@
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.WSDLUtil;
+import org.apache.axis2.wsdl.util.WSDLDefinitionWrapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.neethi.Constants;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyReference;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
-import javax.wsdl.*;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Import;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.OperationType;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.UnknownExtensibilityElement;
-import javax.wsdl.extensions.mime.MIMEMultipartRelated;
-import javax.wsdl.extensions.mime.MIMEPart;
 import javax.wsdl.extensions.http.HTTPAddress;
 import javax.wsdl.extensions.http.HTTPBinding;
 import javax.wsdl.extensions.http.HTTPOperation;
+import javax.wsdl.extensions.mime.MIMEMultipartRelated;
+import javax.wsdl.extensions.mime.MIMEPart;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
@@ -67,7 +89,15 @@
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.Vector;
 
 public class WSDL11ToAxisServiceBuilder extends WSDLToAxisServiceBuilder {
 
@@ -100,8 +130,9 @@
     private static final String BINDING_OPERATION_OUTPUT = "Binding.Operation.Output";
 
     protected Definition wsdl4jDefinition = null;
+    protected String     wsdlBaseDocumentURI = null;
 
-    private WSDLLocator customWSLD4JResolver;
+    private WSDLLocator customWSDLResolver;
 
     public static final String RPC_STYLE = "rpc";
 
@@ -150,9 +181,9 @@
     /**
      * constructor taking in the service name and the port name
      *
-     * @param in
-     * @param serviceName
-     * @param portName
+     * @param in - InputStream for the WSDL
+     * @param serviceName - The service Name
+     * @param portName - The port name
      */
     public WSDL11ToAxisServiceBuilder(InputStream in, QName serviceName,
                                       String portName) {
@@ -161,9 +192,9 @@
     }
 
     /**
-     * @param def
-     * @param serviceName
-     * @param portName
+     * @param def - The WSDL4J Definition object
+     * @param serviceName - The service Name
+     * @param portName - The port name
      */
     public WSDL11ToAxisServiceBuilder(Definition def, QName serviceName,
                                       String portName) {
@@ -174,9 +205,10 @@
     }
 
     /**
-     * @param def
-     * @param serviceName
-     * @param portName
+     * @param def - The WSDL4J Definition object
+     * @param serviceName - The service Name
+     * @param portName - The port name
+     * @param isAllPorts - boolean representing whether to generate code for all ports or not
      */
     public WSDL11ToAxisServiceBuilder(Definition def,
                                       QName serviceName,
@@ -203,31 +235,65 @@
     }
 
     /**
-     * sets a custem WSDL4J locator
+     * @deprecated
+     * @see setCustomWSDLResolver
+     */
+    public void setCustomWSLD4JResolver(WSDLLocator customResolver) {
+        setCustomWSDLResolver(customResolver);
+    }
+
+
+    /**
+     * sets a custom WSDL locator
+     *
+     * @param customWSDLResolver
+     */
+    public void setCustomWSDLResolver(WSDLLocator customResolver) {
+        this.customWSDLResolver = customResolver;
+        setDocumentBaseUri(this.customWSDLResolver.getBaseURI());
+    }
+
+
+    /**
+     * Sets the URI to the base document associated with the WSDL definition.
+     * This identifies the origin of the Definition and allows the 
+     * Definition to be reloaded.  Note that this is the URI of the base
+     * document, not the imports.
      *
-     * @param customWSLD4JResolver
+     * @param baseUri
      */
-    public void setCustomWSLD4JResolver(WSDLLocator customWSLD4JResolver) {
-        this.customWSLD4JResolver = customWSLD4JResolver;
+    public void setDocumentBaseUri(String baseUri) {
+        if (wsdl4jDefinition != null) {
+            wsdl4jDefinition.setDocumentBaseURI(baseUri);
+        }
+        wsdlBaseDocumentURI = baseUri;
     }
 
     /**
-     * populates a given service This is the only publicly accessible method in
-     * this class
+     * Gets the URI to the base document associated with the WSDL definition.
+     * This identifies the origin of the Definition and allows the 
+     * Definition to be reloaded.  Note that this is the URI of the base
+     * document, not the imports.
+     *
+     */
+    public String getDocumentBaseUri() {
+        return wsdlBaseDocumentURI;
+    }
+
+
+
+
+    /**
+     * Populates a given service. 
      *
      * @throws AxisFault
      */
     public AxisService populateService() throws AxisFault {
         try {
             setup();
-            // Setting wsdl4jdefintion to axisService , so if some one want
-            // to play with it he can do that by getting the parameter
-            Parameter wsdlDefinitionParameter = new Parameter();
-            wsdlDefinitionParameter.setName(WSDLConstants.WSDL_4_J_DEFINITION);
-            wsdlDefinitionParameter.setValue(wsdl4jDefinition);
-            axisService.addParameter(wsdlDefinitionParameter);
-            axisService.setWsdlFound(true);
-            axisService.setCustomWsdl(true);
+
+            // NOTE: set the axisService with the Parameter for the WSDL 
+            // Definition after the rest of the work
 
             if (wsdl4jDefinition == null) {
                 return null;
@@ -279,6 +345,26 @@
             populateEndpoints(binding, wsdl4jService, portType);
             processPoliciesInDefintion(wsdl4jDefinition);
             axisService.getPolicyInclude().setPolicyRegistry(registry);
+
+
+            // Setting wsdl4jdefintion to the axisService parameter include list, 
+            // so if someone needs to use the definition directly, 
+            // he can do that by getting the parameter 
+            Parameter wsdlDefinitionParameter = new Parameter();
+            wsdlDefinitionParameter.setName(WSDLConstants.WSDL_4_J_DEFINITION);
+
+            if (!(wsdl4jDefinition instanceof WSDLDefinitionWrapper)) {
+                WSDLDefinitionWrapper wrapper = new WSDLDefinitionWrapper(wsdl4jDefinition);
+                wsdlDefinitionParameter.setValue(wrapper);
+            } else {
+                wsdlDefinitionParameter.setValue(wsdl4jDefinition);
+            }
+
+            axisService.addParameter(wsdlDefinitionParameter);
+            axisService.setWsdlFound(true);
+            axisService.setCustomWsdl(true);
+
+
             return axisService;
 
         } catch (WSDLException e) {
@@ -502,8 +588,13 @@
 
             httpLocation =
                     (String) axisBindingOperation.getProperty(WSDL2Constants.ATTR_WHTTP_LOCATION);
+            String httpMethod =
+                    (String) axisBindingOperation.getProperty(WSDL2Constants.ATTR_WHTTP_METHOD);
+            if (httpMethod == null || "".equals(httpMethod)) {
+                httpMethod = HTTPConstants.HEADER_POST;
+            }
             if (httpLocation != null) {
-                httpLocationMap.put(RESTUtil.getConstantFromHTTPLocation(httpLocation),
+                httpLocationMap.put(RESTUtil.getConstantFromHTTPLocation(httpLocation, httpMethod),
                                     axisBindingOperation.getAxisOperation());
             }
 
@@ -769,7 +860,8 @@
 
                 if (port != null) {
                     // i.e we have find a correct port
-                    if (!this.isAllPorts) {
+                    // this is only use full in codegen time.
+                    if (this.isCodegen && !this.isAllPorts) {
                         // if user has not set all option
                         // we have to generate code only for that option.
                         this.portName = port.getName();
@@ -2040,9 +2132,13 @@
         // switch off the verbose mode for all usecases
         reader.setFeature(JAVAX_WSDL_VERBOSE_MODE_KEY, false);
 
+        Definition def;
         // if the custem resolver is present then use it
-        if (customWSLD4JResolver != null) {
-            return reader.readWSDL(customWSLD4JResolver);
+        if (customWSDLResolver != null) {
+            // make sure the wsdl definition has the URI for the base document set
+            def = reader.readWSDL(customWSDLResolver);
+            def.setDocumentBaseURI(customWSDLResolver.getBaseURI());
+            return def;
         } else {
             Document doc;
             try {
@@ -2058,7 +2154,16 @@
                 throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error",
                                         e);
             }
-            return reader.readWSDL(getBaseUri(), doc);
+            
+            // Log when and from where the WSDL is loaded.
+            if (log.isDebugEnabled()) {
+                log.debug("Reading 1.1 WSDL with base uri = " + getBaseUri());
+                log.debug("  the document base uri = " + getDocumentBaseUri());
+                log.debug("  the stack at this point is: " + stackToString());
+            }
+            def = reader.readWSDL(getBaseUri(), doc);
+            def.setDocumentBaseURI(getDocumentBaseUri());
+            return def;
         }
     }
 

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAllAxisServicesBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAllAxisServicesBuilder.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAllAxisServicesBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAllAxisServicesBuilder.java Tue Oct 30 05:10:34 2007
@@ -24,6 +24,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.woden.wsdl20.Endpoint;
 import org.apache.woden.wsdl20.Service;
+import org.apache.woden.WSDLException;
 
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -46,6 +47,11 @@
      */
     public WSDL20ToAllAxisServicesBuilder(InputStream in) {
         super(in, null, null);
+        axisServices = new ArrayList();   // create an empty ArrayList
+    }
+
+    public WSDL20ToAllAxisServicesBuilder(String wsdlUri, String endpointName) throws WSDLException {
+        super(wsdlUri, null, endpointName);
         axisServices = new ArrayList();   // create an empty ArrayList
     }
 

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Tue Oct 30 05:10:34 2007
@@ -18,30 +18,31 @@
  */
 package org.apache.axis2.description;
 
+import com.ibm.wsdl.util.xml.DOM2Writer;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.namespace.Constants;
+import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.axis2.wsdl.HTTPHeaderMessage;
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 import org.apache.axis2.wsdl.SOAPModuleMessage;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.woden.WSDLException;
 import org.apache.woden.WSDLFactory;
 import org.apache.woden.WSDLReader;
 import org.apache.woden.WSDLSource;
 import org.apache.woden.XMLElement;
 import org.apache.woden.internal.DOMWSDLFactory;
+import org.apache.woden.internal.wsdl20.BindingFaultImpl;
+import org.apache.woden.internal.wsdl20.BindingOperationImpl;
 import org.apache.woden.internal.wsdl20.extensions.InterfaceOperationExtensionsImpl;
 import org.apache.woden.internal.wsdl20.extensions.http.HTTPBindingExtensionsImpl;
 import org.apache.woden.internal.wsdl20.extensions.http.HTTPHeaderImpl;
 import org.apache.woden.internal.wsdl20.extensions.soap.SOAPBindingExtensionsImpl;
-import org.apache.woden.internal.wsdl20.BindingFaultImpl;
-import org.apache.woden.internal.wsdl20.BindingOperationImpl;
 import org.apache.woden.schema.Schema;
 import org.apache.woden.wsdl20.Binding;
 import org.apache.woden.wsdl20.BindingFault;
@@ -57,13 +58,13 @@
 import org.apache.woden.wsdl20.InterfaceMessageReference;
 import org.apache.woden.wsdl20.InterfaceOperation;
 import org.apache.woden.wsdl20.Service;
-import org.apache.woden.wsdl20.WSDLComponent;
 import org.apache.woden.wsdl20.enumeration.MessageLabel;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
 import org.apache.woden.wsdl20.extensions.http.HTTPHeader;
 import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions;
@@ -72,9 +73,9 @@
 import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlock;
 import org.apache.woden.wsdl20.extensions.soap.SOAPModule;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
-import org.apache.woden.wsdl20.xml.TypesElement;
-import org.apache.woden.wsdl20.xml.DocumentationElement;
 import org.apache.woden.wsdl20.xml.DocumentableElement;
+import org.apache.woden.wsdl20.xml.DocumentationElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
 import org.apache.woden.xml.XMLAttr;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
@@ -89,25 +90,20 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
-import java.util.Comparator;
-
-import com.ibm.wsdl.util.xml.DOM2Writer;
 
 public class WSDL20ToAxisServiceBuilder extends WSDLToAxisServiceBuilder {
 
+    protected static final Log log = LogFactory.getLog(WSDL20ToAxisServiceBuilder.class);
     protected Description description;
 
     private String wsdlURI;
 
-    // FIXME @author Chathura THis shoud be a URI. Find whats used by
-    // woden.
-    private static String RPC = "rpc";
-
     protected String interfaceName;
 
     private String savedTargetNamespace;
@@ -119,8 +115,11 @@
     private NamespaceMap stringBasedNamespaceMap;
 
     private boolean setupComplete = false;
+
     private Service wsdlService;
 
+    private boolean isAllPorts;
+
 //    As bindings are processed add it to this array so that we dont process the same binding twice
     private Map processedBindings;
 
@@ -157,6 +156,12 @@
         setPolicyRegistryFromService(axisService);
     }
 
+    public WSDL20ToAxisServiceBuilder(String wsdlUri,
+                                      String name, String interfaceName, boolean isAllPorts) throws WSDLException {
+        this(wsdlUri, name, interfaceName);
+        this.isAllPorts = isAllPorts;
+    }
+
     public WSDL20ToAxisServiceBuilder(String wsdlUri, QName serviceName) {
         super(null, serviceName);
         this.wsdlURI = wsdlUri;
@@ -167,6 +172,14 @@
         this.wsdlURI = wsdlUri;
     }
 
+    public boolean isAllPorts() {
+        return isAllPorts;
+    }
+
+    public void setAllPorts(boolean allPorts) {
+        isAllPorts = allPorts;
+    }
+
     public AxisService populateService() throws AxisFault {
 
         try {
@@ -248,6 +261,14 @@
         processedBindings = new HashMap();
         Endpoint endpoint = null;
 
+        // If the interface name is not null thats means that this is a call from the codegen engine
+        // and we need to populate a single endpoint. Hence find the endpoint and populate it.
+        // If that was not the case then we need to check whether the call is from the codegen
+        // engine with thw allports check false. If its so no need to populate all endpoints, we
+        // select an enspoint accrding to the following criteria.
+        // 1. Find the first SOAP 1.2 endpoint
+        // 2. Find the first SOAP 1.1 endpoint
+        // 3. Use the first endpoint
         if (this.interfaceName != null) {
             for (int i = 0; i < endpoints.length; ++i) {
                 if (this.interfaceName.equals(endpoints[i].getName().toString())) {
@@ -261,7 +282,37 @@
             }
 
             axisService
-                    .addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint, serviceInterface));
+                    .addEndpoint(endpoint.getName().toString(),
+                                 processEndpoint(endpoint, serviceInterface));
+        } else if (this.isCodegen && !this.isAllPorts) {
+            Endpoint soap11Endpoint = null;
+            for (int i = 0; i < endpoints.length; ++i) {
+                Binding binding = endpoints[i].getBinding();
+                if (WSDL2Constants.URI_WSDL2_SOAP.equals(binding.getType().toString())) {
+                    SOAPBindingExtensions soapBindingExtensions;
+                    try {
+                        soapBindingExtensions = (SOAPBindingExtensionsImpl) binding
+                                .getComponentExtensionsForNamespace(
+                                        new URI(WSDL2Constants.URI_WSDL2_SOAP));
+                    } catch (URISyntaxException e) {
+                        throw new AxisFault("Soap Binding Extention not found");
+                    }
+                    if (!WSDL2Constants.SOAP_VERSION_1_1
+                            .equals(soapBindingExtensions.getSoapVersion())) {
+                        endpoint = endpoints[i];
+                        break;  // found it.  Stop looking
+                    } else if (soap11Endpoint == null){
+                        soap11Endpoint = endpoints[i];
+                    }
+                }
+            }
+            if (endpoint == null) {
+                endpoint = endpoints[0];
+            }
+
+            axisService
+                    .addEndpoint(endpoint.getName().toString(),
+                                 processEndpoint(endpoint, serviceInterface));
         } else {
             for (int i = 0; i < endpoints.length; i++) {
                 axisService
@@ -274,10 +325,11 @@
             endpoint = endpoints[0];
         }
 
-        axisService.setEndpointName(endpoint.getName().toString());
-        axisService.setBindingName(endpoint.getBinding().getName().getLocalPart());
-        axisService.setEndpointURL(endpoint.getAddress().toString());
-
+        if (endpoint != null) {
+            axisService.setEndpointName(endpoint.getName().toString());
+            axisService.setBindingName(endpoint.getBinding().getName().getLocalPart());
+            axisService.setEndpointURL(endpoint.getAddress().toString());
+        }
     }
 
     private void processService() throws AxisFault {
@@ -301,7 +353,7 @@
            wsdlService = services[0];
         }
 
-        axisService.setName(wsdlService.getName().getLocalPart().toString());
+        axisService.setName(wsdlService.getName().getLocalPart());
         Interface serviceInterface = wsdlService.getInterface();
         axisService.addParameter(new Parameter(WSDL2Constants.INTERFACE_LOCAL_NAME, serviceInterface.getName().getLocalPart()));
         processInterface(serviceInterface);
@@ -323,7 +375,7 @@
             axisEndpoint.setBinding(processBinding(endpoint.getBinding(), serviceInterface));
         }
 
-        SOAPEndpointExtensions soapEndpointExtensions = null;
+        SOAPEndpointExtensions soapEndpointExtensions;
         try {
             soapEndpointExtensions = (SOAPEndpointExtensions) endpoint
                     .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
@@ -355,7 +407,8 @@
      * information here allows WSDL20ToAllAxisServicesBuilder to only do this
      * work 1 time per WSDL, instead of for each endpoint on each wsdlService.
      *
-     * @throws AxisFault
+     * @throws AxisFault - Thrown in case the necessary resources are not available in the WSDL
+     * @throws WSDLException - Thrown in case Woden throws an exception
      */
     protected void setup() throws AxisFault, WSDLException {
         if (setupComplete) { // already setup, just do nothing and return
@@ -364,8 +417,8 @@
         try {
             if (description == null) {
 
-                Description description = null;
-                DescriptionElement descriptionElement = null;
+                Description description;
+                DescriptionElement descriptionElement;
                 if (wsdlURI != null && !"".equals(wsdlURI)) {
                     description = readInTheWSDLFile(wsdlURI);
                     descriptionElement = description.toElement();
@@ -445,7 +498,7 @@
                 return (-1 * ((Comparable)o1).compareTo(o2));
             }
         });
-        SOAPBindingExtensionsImpl soapBindingExtensions = null;
+        SOAPBindingExtensions soapBindingExtensions;
         try {
             soapBindingExtensions = (SOAPBindingExtensionsImpl) binding
                     .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
@@ -498,7 +551,7 @@
             axisBindingFault.setParent(axisBinding);
 
             addDocumentation(axisBindingFault, interfaceFault.toElement());
-            SOAPBindingFaultExtensions soapBindingFaultExtensions = null;
+            SOAPBindingFaultExtensions soapBindingFaultExtensions;
 
             try {
                 soapBindingFaultExtensions = (SOAPBindingFaultExtensions) bindingFault
@@ -542,7 +595,7 @@
             axisBindingOperation.setParent(axisBinding);
             axisBindingOperation.setName(axisOperation.getName());
             addDocumentation(axisBindingOperation, bindingOperation.toElement());
-            SOAPBindingOperationExtensions soapBindingOperationExtensions = null;
+            SOAPBindingOperationExtensions soapBindingOperationExtensions;
             try {
                 soapBindingOperationExtensions = ((SOAPBindingOperationExtensions)
                         bindingOperation.getComponentExtensionsForNamespace(
@@ -552,7 +605,7 @@
             }
 
             URI soapAction = soapBindingOperationExtensions.getSoapAction();
-            if (soapAction != null && !"\"\"".equals(soapAction)) {
+            if (soapAction != null && !"\"\"".equals(soapAction.toString())) {
                 axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION,
                                                  soapAction.toString());
             }
@@ -573,7 +626,7 @@
                 String httpLocationTemplete = httpLocation.getOriginalLocation();
                 axisBindingOperation
                         .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
-                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);
+                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete, HTTPConstants.HEADER_POST);
 
             }
 
@@ -600,7 +653,7 @@
                 axisBindingMessage.setDirection(axisMessage.getDirection());
 
 
-                SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions = null;
+                SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions;
                 try {
                     soapBindingMessageReferenceExtensions =
                             (SOAPBindingMessageReferenceExtensions) bindingMessageReference
@@ -638,7 +691,7 @@
                 axisBindingMessageFault.setName(bindingFaultReference.getInterfaceFaultReference()
                         .getInterfaceFault().getName().getLocalPart());
 
-                SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions = null;
+                SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions;
                 try {
                     soapBindingFaultReferenceExtensions =
                             (SOAPBindingFaultReferenceExtensions) bindingFaultReference
@@ -674,7 +727,7 @@
         });
         // Capture all the binding specific properties
 
-        HTTPBindingExtensionsImpl httpBindingExtensions = null;
+        HTTPBindingExtensionsImpl httpBindingExtensions;
         try {
             httpBindingExtensions = (HTTPBindingExtensionsImpl) binding
                     .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_HTTP));
@@ -682,8 +735,9 @@
             throw new AxisFault("HTTP Binding Extention not found");
         }
 
+        String httpMethodDefault = httpBindingExtensions.getHttpMethodDefault();
         axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD,
-                                httpBindingExtensions.getHttpMethodDefault());
+                                httpMethodDefault);
         axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
                                 httpBindingExtensions.getHttpQueryParameterSeparatorDefault());
         axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
@@ -702,7 +756,7 @@
             axisBindingFault.setParent(axisBinding);
 
             addDocumentation(axisBindingFault, interfaceFault.toElement());
-            HTTPBindingFaultExtensions httpBindingFaultExtensions = null;
+            HTTPBindingFaultExtensions httpBindingFaultExtensions;
 
             try {
                 httpBindingFaultExtensions = (HTTPBindingFaultExtensions) bindingFault
@@ -739,7 +793,7 @@
             axisBindingOperation.setName(axisOperation.getName());
 
             addDocumentation(axisBindingOperation, bindingOperation.toElement());
-            HTTPBindingOperationExtensions httpBindingOperationExtensions = null;
+            HTTPBindingOperationExtensions httpBindingOperationExtensions;
             try {
                 httpBindingOperationExtensions = ((HTTPBindingOperationExtensions)
                         bindingOperation.getComponentExtensionsForNamespace(
@@ -752,6 +806,23 @@
                                              httpBindingOperationExtensions.getHttpFaultSerialization());
             axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
                                              httpBindingOperationExtensions.getHttpInputSerialization());
+            String httpMethod = httpBindingOperationExtensions.
+                    getHttpMethod();
+            if (httpMethod == null) {
+                if (httpMethodDefault != null) {
+                    httpMethod = httpMethodDefault;
+                } else {
+                    Boolean safeParameter =
+                            (Boolean) axisOperation.getParameterValue(WSDL2Constants.ATTR_WSDLX_SAFE);
+                    if (safeParameter != null && safeParameter.booleanValue()){
+                        httpMethod = HTTPConstants.HEADER_GET;
+                    } else {
+                        httpMethod = HTTPConstants.HEADER_POST;
+                    }
+                }
+            }
+            axisBindingOperation
+                    .setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethod);
             HTTPLocation httpLocation = httpBindingOperationExtensions.getHttpLocation();
 
             // If httpLocation is not null we should extract a constant part from it and add its value and the
@@ -762,7 +833,7 @@
                 String httpLocationTemplete = httpLocation.getOriginalLocation();
                 axisBindingOperation
                         .setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
-                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);
+                httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete, httpMethod);
 
             }
 
@@ -771,9 +842,6 @@
             axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED,
                                              httpBindingOperationExtensions.
                                                      isHttpLocationIgnoreUncited());
-            axisBindingOperation
-                    .setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpBindingOperationExtensions.
-                            getHttpMethod());
             axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_OUTPUT_SERIALIZATION,
                                              httpBindingOperationExtensions.getHttpOutputSerialization());
             axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
@@ -797,7 +865,7 @@
                 axisBindingMessage.setDirection(axisMessage.getDirection());
 
                 addDocumentation(axisBindingMessage, bindingMessageReference.toElement());
-                HTTPBindingMessageReferenceExtensions httpBindingMessageReferenceExtensions = null;
+                HTTPBindingMessageReferenceExtensions httpBindingMessageReferenceExtensions;
                 try {
                     httpBindingMessageReferenceExtensions =
                             (HTTPBindingMessageReferenceExtensions) bindingMessageReference
@@ -910,7 +978,7 @@
         }
 
         if (interfaceOperationExtensions != null) {
-            Parameter parameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, new Boolean(
+            Parameter parameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, Boolean.valueOf(
                     interfaceOperationExtensions.isSafety()));
             axisOperation.addParameter(parameter);
         }
@@ -1025,8 +1093,13 @@
         WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
         // This turns on WSDL validation which is set off by default.
 //        reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
-        Description description1 = reader.readWSDL(wsdlURI);
-        return description1;
+        
+//      Log when and from where the WSDL is loaded.
+        if (log.isDebugEnabled()) {
+            log.debug("Reading 2.0 WSDL with wsdl uri = " + wsdlURI);
+            log.debug("  the stack at this point is: " + stackToString());
+        }
+        return reader.readWSDL(wsdlURI);
     }
 
     /**
@@ -1114,7 +1187,6 @@
     private void addDocumentation(AxisDescription axisDescription, DocumentableElement element) {
         DocumentationElement[] documentationElements = element.getDocumentationElements();
         String documentation = "";
-        StringBuffer x;
         for (int i = 0; i < documentationElements.length; i++) {
             DocumentationElement documentationElement = documentationElements[i];
             XMLElement contentElement = documentationElement.getContent();

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java Tue Oct 30 05:10:34 2007
@@ -194,10 +194,24 @@
         return "ns" + nsCount++;
     }
 
+    /**
+     * Gets the URI associated with the base document
+     * for the WSDL definition.  Note that this URI
+     * is for the base document, not the imports.
+     * 
+     * @return The URI as a String
+     */
     public String getBaseUri() {
         return baseUri;
     }
 
+    /**
+     * Sets the URI associated with the base document
+     * for the WSDL definition.  Note that this URI
+     * is for the base document, not the imports.
+     * 
+     * @param baseUri  The URI as a String
+     */
     public void setBaseUri(String baseUri) {
         this.baseUri = baseUri;
     }
@@ -216,5 +230,69 @@
 
     public void setServiceName(QName serviceName) {
         this.serviceName = serviceName;
+    }
+    
+    /**
+     * Get a string containing the stack of the current location
+     *
+     * @return String
+     */
+    protected static String stackToString() {
+        return stackToString(new RuntimeException());
+    }
+
+    /**
+     * Get a string containing the stack of the specified exception
+     *
+     * @param e
+     * @return
+     */
+    protected static String stackToString(Throwable e) {
+        java.io.StringWriter sw = new java.io.StringWriter();
+        java.io.BufferedWriter bw = new java.io.BufferedWriter(sw);
+        java.io.PrintWriter pw = new java.io.PrintWriter(bw);
+        e.printStackTrace(pw);
+        pw.close();
+        String text = sw.getBuffer().toString();
+        // Jump past the throwable
+        text = text.substring(text.indexOf("at"));
+        text = replace(text, "at ", "DEBUG_FRAME = ");
+        return text;
+    }
+    
+    /**
+     * replace: Like String.replace except that the old new items are strings.
+     *
+     * @param name string
+     * @param oldT old text to replace
+     * @param newT new text to use
+     * @return replacement string
+     */
+    protected static final String replace(String name,
+                                       String oldT, String newT) {
+
+        if (name == null) return "";
+
+        // Create a string buffer that is twice initial length.
+        // This is a good starting point.
+        StringBuffer sb = new StringBuffer(name.length() * 2);
+
+        int len = oldT.length();
+        try {
+            int start = 0;
+            int i = name.indexOf(oldT, start);
+
+            while (i >= 0) {
+                sb.append(name.substring(start, i));
+                sb.append(newT);
+                start = i + len;
+                i = name.indexOf(oldT, start);
+            }
+            if (start < name.length())
+                sb.append(name.substring(start));
+        } catch (NullPointerException e) {
+        }
+
+        return new String(sb);
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/dispatchers/HTTPLocationBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/dispatchers/HTTPLocationBasedDispatcher.java?rev=590048&r1=590047&r2=590048&view=diff
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/dispatchers/HTTPLocationBasedDispatcher.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/dispatchers/HTTPLocationBasedDispatcher.java Tue Oct 30 05:10:34 2007
@@ -21,13 +21,14 @@
 package org.apache.axis2.dispatchers;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AbstractDispatcher;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisEndpoint;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.HandlerDescription;
 import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -55,16 +56,36 @@
             String uri = messageContext.getTo().getAddress();
             String httpLocation = parseRequestURL(uri, messageContext
                     .getConfigurationContext().getServiceContextPath());
+            String httpMethod = (String) messageContext.getProperty(HTTPConstants.HTTP_METHOD);
 
             if (httpLocation != null) {
+                httpLocation = httpMethod + httpLocation;
                 AxisEndpoint axisEndpoint = (AxisEndpoint) messageContext
                         .getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
+                // Here we check whether the request was dispatched to the correct endpoint. If it
+                // was we can dispatch the operation using the HTTPLocationDispatcher table of that
+                // specific endpoint. In most cases we wont be able to do this. So as a last resort
+                // iterate through the endpoint map and try to dispatch the operation.
                 if (axisEndpoint != null) {
                     Map httpLocationTable = (Map) axisEndpoint.getBinding()
                             .getProperty(WSDL2Constants.HTTP_LOCATION_TABLE);
                     if (httpLocationTable != null) {
                         return getOperationFromHTTPLocation(httpLocation, httpLocationTable);
                     }
+                } else {
+                    Map endpoints = axisService.getEndpoints();
+                    if (endpoints != null) {
+                        Iterator iterator = endpoints.values().iterator();
+                        while (iterator.hasNext()) {
+                            AxisEndpoint endpoint = (AxisEndpoint) iterator.next();
+                            Map httpLocationTable = (Map) endpoint.getBinding()
+                                    .getProperty(WSDL2Constants.HTTP_LOCATION_TABLE);
+                            if (httpLocationTable != null) {
+                                return getOperationFromHTTPLocation(httpLocation,
+                                                                    httpLocationTable);
+                            }
+                        }
+                    }
                 }
             } else {
                 log.debug("Attempt to check for Operation using HTTP Location failed");
@@ -118,6 +139,7 @@
      * Given the requestPath that the request came to his method returns the corresponding axisOperation
      *
      * @param requestPath - Part of the request url which is the part after the service name
+     * @param httpLocationTable - The httpLocationTable stored in the relavant binding
      * @return AxisOperation - The corresponding AxisOperation
      */
     private AxisOperation getOperationFromHTTPLocation(String requestPath, Map httpLocationTable) {



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