You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/11 19:08:16 UTC

svn commit: r583883 - in /incubator/cxf/branches/2.0.x-fixes: ./ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/ws...

Author: dkulp
Date: Thu Oct 11 10:08:14 2007
New Revision: 583883

URL: http://svn.apache.org/viewvc?rev=583883&view=rev
Log:
Merged revisions 583674 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r583674 | ema | 2007-10-11 00:20:48 -0400 (Thu, 11 Oct 2007) | 1 line
  
  Fixed issue CXF-1094, CXF-1095
........

Added:
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/
      - copied from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/async_binding.xml
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/async_binding.xml
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/echo_date.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/echo_date.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/hello_world.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/hello_world.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/hello_world_oneway.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/hello_world_oneway.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/jaxbbinding.xml
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1094/jaxbbinding.xml
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/
      - copied from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/binding.xml
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/binding.xml
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/binding1.xml
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/binding1.xml
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_bindings.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_bindings.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_messages.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_messages.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_services.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_services.wsdl
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_wsdl_import.wsdl
      - copied unchanged from r583674, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1095/hello_world_wsdl_import.wsdl
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=583883&r1=583882&r2=583883&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Thu Oct 11 10:08:14 2007
@@ -18,11 +18,15 @@
  */
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.customization;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
@@ -41,7 +45,9 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.MapNamespaceContext;
+import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
@@ -55,8 +61,10 @@
     private static final Logger LOG = LogUtils.getL7dLogger(CustomizationParser.class);
 
     private ToolContext env;
-    private final List<Element> jaxwsBindings = new ArrayList<Element>();
+    //map for jaxws binding and wsdl element
+    private final Map<Element, Element> jaxwsBindingsMap = new HashMap<Element, Element>();
     private final List<InputSource> jaxbBindings = new ArrayList<InputSource>();
+    private final Map<String, Element> customizedElements = new HashMap<String, Element>();
 
     private Element handlerChains;
     private Element wsdlNode;
@@ -65,7 +73,7 @@
     private CustomNodeSelector nodeSelector = new CustomNodeSelector();
 
     public CustomizationParser() {
-        jaxwsBindings.clear();
+        jaxwsBindingsMap.clear();
         jaxbBindings.clear();
     }
 
@@ -77,8 +85,9 @@
         this.env = pe;
         String[] bindingFiles;
         try {
-            this.wsdlURL = URIParserUtil.getAbsoluteURI((String)env.get(ToolConstants.CFG_WSDLURL));
-            this.wsdlNode = this.getTargetNode(this.wsdlURL);
+            wsdlURL = URIParserUtil.getAbsoluteURI((String)env.get(ToolConstants.CFG_WSDLURL));
+            wsdlNode = getTargetNode(this.wsdlURL);
+            customizedElements.put(wsdlURL.toString(), wsdlNode);
             bindingFiles = (String[])env.get(ToolConstants.CFG_BINDING);
             if (bindingFiles == null) {
                 return;
@@ -97,9 +106,12 @@
             }
         }
 
-        for (Element element : jaxwsBindings) {
+        for (Element element : jaxwsBindingsMap.keySet()) {
             nodeSelector.addNamespaces(element);
-            internalizeBinding(element, "");
+            Element targetNode = jaxwsBindingsMap.get(element);
+            internalizeBinding(element, targetNode, "");
+            String uri = element.getAttribute("wsdlLocation");
+            customizedElements.put(uri, targetNode);
         }
         buildHandlerChains();
     }
@@ -129,7 +141,7 @@
 
     private void buildHandlerChains() {
 
-        for (Element jaxwsBinding : jaxwsBindings) {
+        for (Element jaxwsBinding : jaxwsBindingsMap.keySet()) {
             NodeList nl = jaxwsBinding.getElementsByTagNameNS(ToolConstants.HANDLER_CHAINS_URI,
                                                               ToolConstants.HANDLER_CHAINS);
             if (nl.getLength() == 0) {
@@ -207,13 +219,13 @@
         }
     }
 
-    protected void internalizeBinding(Element bindings, String expression) {
+    protected void internalizeBinding(Element bindings, Element targetNode, String expression) {
         if (bindings.getAttributeNode("wsdlLocation") != null) {
             expression = "/";
         }
 
         if (isGlobaleBindings(bindings)) {
-            String pfx = wsdlNode.getPrefix();
+            String pfx = targetNode.getPrefix();
             if (pfx == null) {
                 pfx = "";
             } else {
@@ -221,7 +233,7 @@
             }
 
             nodeSelector.addNamespaces(wsdlNode);
-            Node node = nodeSelector.queryNode(wsdlNode, "//" + pfx + "definitions");
+            Node node = nodeSelector.queryNode(targetNode, "//" + pfx + "definitions");
             copyBindingsToWsdl(node, bindings, nodeSelector.getNamespaceContext());
         }
 
@@ -230,7 +242,7 @@
 
             nodeSelector.addNamespaces(bindings);
 
-            Node node = nodeSelector.queryNode(wsdlNode, expression);
+            Node node = nodeSelector.queryNode(targetNode, expression);
             if (node == null) {
                 throw new ToolException(new Message("NODE_NOT_EXISTS",
                                                     LOG, new Object[] {expression}));
@@ -246,9 +258,10 @@
         Element[] children = getChildElements(bindings, ToolConstants.NS_JAXWS_BINDINGS);
         for (int i = 0; i < children.length; i++) {
             if (children[i].getNodeType() == Node.ELEMENT_NODE) {
-                internalizeBinding(children[i], expression);
+                internalizeBinding(children[i], targetNode, expression);
             }
         }
+        
     }
 
     private void copyBindingsToWsdl(Node node, Node bindings, MapNamespaceContext ctx) {
@@ -345,50 +358,71 @@
 
         StAXUtil.toStartTag(reader);
 
+        Element root = null;
+        try {
+            URIResolver resolver = new URIResolver(bindingFile);
+            root = DOMUtils.readXml(resolver.getInputStream()).getDocumentElement();
+        } catch (Exception e1) {
+            Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
+            throw new ToolException(msg, e1);
+        }
         if (isValidJaxwsBindingFile(bindingFile, reader)) {
-            Element root = null;
-            try {
-                URIResolver resolver = new URIResolver(bindingFile);
-                root = DOMUtils.readXml(resolver.getInputStream()).getDocumentElement();
-            } catch (Exception e1) {
-                Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
-                throw new ToolException(msg, e1);
-            }
+            
             String wsdlLocation = root.getAttribute("wsdlLocation");
-            URI wsdlURI = null;
-            try {
-                wsdlURI = new URI(wsdlLocation);
-            } catch (URISyntaxException e) {
-                Message msg = new Message("JAXWSBINDINGS_WSDLLOC_ERROR", LOG, new Object[] {wsdlLocation});
-                throw new ToolException(msg);
-            }
-
-            if (!wsdlURI.isAbsolute()) {
+            Element targetNode;
+            if (!StringUtils.isEmpty(wsdlLocation)) {
+                URI wsdlURI = null;
                 try {
-                    URI baseURI = new URI(bindingFile);
-                    wsdlURI = baseURI.resolve(wsdlURI);
+                    wsdlURI = new URI(wsdlLocation);
                 } catch (URISyntaxException e) {
-                    Message msg = new Message("NOT_URI", LOG, new Object[] {bindingFile});
-                    throw new ToolException(msg, e);
-                }
-
-            }
-
-            URI normalizedURL = null;
-            if (this.wsdlURL != null) {
-                normalizedURL = URI.create(this.wsdlURL).normalize();
-            }
+                    Message msg = new Message("JAXWSBINDINGS_WSDLLOC_ERROR",
+                                              LOG, new Object[] {wsdlLocation});
+                    throw new ToolException(msg);
+                } 
+                
+                if (!wsdlURI.isAbsolute()) {
+                    try {
+                        String base = URIParserUtil.getAbsoluteURI(bindingFile);
+                        URI baseURI = new URI(base);
+                        wsdlURI = baseURI.resolve(wsdlURI);
+                    } catch (URISyntaxException e) {
+                        Message msg = new Message("NOT_URI", LOG, new Object[] {bindingFile});
+                        throw new ToolException(msg, e);
+                    }
 
-            if (wsdlURI.normalize().equals(normalizedURL)) {
-                jaxwsBindings.add(root);
+                }
+                targetNode = this.getTargetNode(wsdlURI.toString());
+                if (targetNode == null) {
+                    Message msg = new Message("CAN_NOT_FIND_BINDING_WSDL", 
+                                              LOG, new Object[] {wsdlURI.normalize(), bindingFile});
+                    throw new ToolException(msg);
+                    
+                }
+                root.setAttribute("wsdlLocation", wsdlURI.toString());                
             } else {
-                Message msg = new Message("NOT_POINTTO_URL", LOG, new Object[] {bindingFile, 
-                                                                                wsdlURI.normalize(), 
-                                                                                normalizedURL});
-                throw new ToolException(msg);
+                targetNode = this.getTargetNode(wsdlURL);
+                root.setAttribute("wsdlLocation", wsdlURL);   
             }
+            jaxwsBindingsMap.put(root, targetNode);
+            
         } else if (isValidJaxbBindingFile(reader)) {
-            jaxbBindings.add(is);
+            String schemaLocation = root.getAttribute("schemaLocation");
+            if (StringUtils.isEmpty(schemaLocation)) {
+                root.setAttribute("schemaLocation", wsdlURL);
+                try {
+                    File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml");
+                    XMLUtils.writeTo(root, new FileOutputStream(tmpFile));
+                    InputSource newis = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile
+                        .getAbsolutePath()));
+                    jaxbBindings.add(newis);
+                    tmpFile.deleteOnExit();
+                } catch (Exception e) {
+                    Message msg = new Message("FAILED_TO_ADD_SCHEMALOACTION", LOG, bindingFile);
+                    throw new ToolException(msg, e);
+                }                
+            } else {
+                jaxbBindings.add(is);
+            }
         } else {
             Message msg = new Message("UNKNOWN_BINDING_FILE", LOG, bindingFile);
             throw new ToolException(msg);
@@ -397,6 +431,7 @@
 
     private boolean isValidJaxbBindingFile(XMLStreamReader reader) {
         if (ToolConstants.JAXB_BINDINGS.equals(reader.getName())) {
+            
             return true;
         }
         return false;
@@ -404,10 +439,13 @@
 
     private boolean isValidJaxwsBindingFile(String bindingLocation, XMLStreamReader reader) {
         if (ToolConstants.JAXWS_BINDINGS.equals(reader.getName())) {
-            String wsdlLocation = reader.getAttributeValue(null, "wsdlLocation");
+            //Comment this check , by default wsdlLocation value will be the user input wsdl url
+            /*
+             String wsdlLocation = reader.getAttributeValue(null, "wsdlLocation");
             if (!StringUtils.isEmpty(wsdlLocation)) {
                 return true;
-            }
+            }*/
+            return true;
         }
         return false;
 
@@ -452,8 +490,8 @@
         return false;
     }
 
-    public Element getCustomizedWSDLElement() {
-        return this.wsdlNode;
+    public Map<String, Element> getCustomizedWSDLElements() {
+        return this.customizedElements;
     }
 
     public List<InputSource> getJaxbBindings() {

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties?rev=583883&r1=583882&r2=583883&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties Thu Oct 11 10:08:14 2007
@@ -20,10 +20,11 @@
 #
 STAX_PARSER_ERROR = StAX parser error, check your external binding file(s)
 UNKNOWN_BINDING_FILE= Unknown external binding files : {0}
-NOT_POINTTO_URL = External binding file: {0} does not point to the specified wsdl: {2}, resolved as {1}
+CAN_NOT_FIND_BINDING_WSDL = Can not read the specified wsdl {0} that external binding file {1} points
 JAXWSBINDINGS_WSDLLOC_ERROR = Attribute wsdlLocation value {0} in jaxws binding element is not an URI
 ERROR_TARGETNODE_WITH_XPATH = XPath query {0} is identifying either multiple or no target nodes.
 XPATH_ERROR = XPath query error , check the query expression : {0}
 NOT_URI = Can not construct new URI with this string : {0}
 CAN_NOT_READ_AS_ELEMENT = Can not read this file to a xml element : {0}
-NODE_NOT_EXISTS = Can not find any node with the XPath {0}
\ No newline at end of file
+NODE_NOT_EXISTS = Can not find any node with the XPath {0}
+FAILED_TO_ADD_SCHEMALOACTION = Failed to inject schmeaLoaction for binding file {0}
\ No newline at end of file

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java?rev=583883&r1=583882&r2=583883&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java Thu Oct 11 10:08:14 2007
@@ -20,13 +20,9 @@
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11;
 
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.jws.soap.SOAPBinding;
@@ -40,18 +36,18 @@
 import javax.wsdl.extensions.ExtensionRegistry;
 import javax.wsdl.xml.WSDLReader;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.xml.sax.InputSource;
 
+import org.apache.cxf.catalog.OASISCatalogManager;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.FileUtils;
+
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
+import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.validator.internal.WSDL11Validator;
 import org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.CustomizationParser;
@@ -126,7 +122,7 @@
         } catch (Exception e) {
             Message msg = new Message("FAIL_TO_CREATE_WSDL_DEFINITION",
                                       LOG,
-                                      cusParser.getCustomizedWSDLElement().getBaseURI());
+                                     (String)context.get(ToolConstants.CFG_WSDLURL));
             throw new RuntimeException(msg.toString(), e);
         }
     }
@@ -166,25 +162,17 @@
                     return true;
                 }
             }
-
         }
         return false;
     }
 
-    private CustomizationParser getCustomizationParser() {
-        return cusParser;
-    }
+    private Definition buildCustomizedDefinition() throws Exception {      
+        Map<String, Element> eleMap = cusParser.getCustomizedWSDLElements();
+        String wsdlUrl = URIParserUtil.getAbsoluteURI((String)context.get(ToolConstants.CFG_WSDLURL));
+        CustomizedWSDLLocator wsdlLocator = new CustomizedWSDLLocator(wsdlUrl, eleMap);
+        wsdlLocator.setCatalogResolver(OASISCatalogManager.getCatalogManager(bus).getCatalog());
+        return wsdlReader.readWSDL(wsdlLocator);
 
-    private Definition buildCustomizedDefinition() throws Exception {
-        File tmpFile = FileUtils.createTempFile("customzied", ".wsdl");
-        OutputStream outs = new FileOutputStream(tmpFile);
-        DOMUtils.writeXml(getCustomizationParser().getCustomizedWSDLElement(), outs);
-        InputStream ins = new FileInputStream(new File(tmpFile.toURI()));
-        Document wsdlDoc = DOMUtils.readXml(ins);
-        Definition def =  wsdlReader.readWSDL(this.wsdlDefinition.getDocumentBaseURI(),
-                                              wsdlDoc);
-        FileUtils.delete(tmpFile);
-        return def;
     }
 
     public Definition getWSDLModel() {

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java?rev=583883&r1=583882&r2=583883&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java Thu Oct 11 10:08:14 2007
@@ -76,7 +76,7 @@
         Element jaxwsBinding = getDocumentElement("resources/external_jaxws.xml");
 
         parser.setWSDLNode(wsdlDoc);
-        parser.internalizeBinding(jaxwsBinding, "");
+        parser.internalizeBinding(jaxwsBinding, wsdlDoc, "");
 
         File file = new File(output, "custom_test.wsdl");
         XMLUtils.writeTo(wsdlDoc, new FileOutputStream(file));
@@ -94,7 +94,7 @@
         Element jaxwsBinding = getDocumentElement("resources/external_jaxws_embed_jaxb.xml");
 
         parser.setWSDLNode(wsdlDoc);
-        parser.internalizeBinding(jaxwsBinding, "");
+        parser.internalizeBinding(jaxwsBinding, wsdlDoc, "");
 
         String base = "wsdl:definitions/wsdl:types/xsd:schema/xsd:annotation/xsd:appinfo/";
         String[] checkingPoints =
@@ -112,7 +112,7 @@
         Element wsdlDoc = getDocumentElement("resources/test.wsdl");
         Element jaxwsBinding = getDocumentElement("resources/external_jaxws_embed_jaxb_date.xml");
         parser.setWSDLNode(wsdlDoc);
-        parser.internalizeBinding(jaxwsBinding, "");
+        parser.internalizeBinding(jaxwsBinding, wsdlDoc, "");
 
         String base = "wsdl:definitions/wsdl:types/xsd:schema/xsd:annotation/xsd:appinfo/";
         String[] checkingPoints =
@@ -130,7 +130,7 @@
         Element wsdlDoc = getDocumentElement("resources/hello_world.wsdl");
         Element jaxwsBinding = getDocumentElement("resources/binding2.xml");
         parser.setWSDLNode(wsdlDoc);
-        parser.internalizeBinding(jaxwsBinding, "");
+        parser.internalizeBinding(jaxwsBinding, wsdlDoc, "");
 
         String checkingPoint = "wsdl:definitions/wsdl:types/xsd:schema";
         checkingPoint += "/xsd:element[@name='CreateProcess']/xsd:complexType/xsd:sequence";

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=583883&r1=583882&r2=583883&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java Thu Oct 11 10:08:14 2007
@@ -22,6 +22,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import javax.jws.WebService;
 import javax.xml.namespace.QName;
@@ -308,6 +309,7 @@
                                           output.getCanonicalPath() + "/classes", "-d",
                                           output.getCanonicalPath(), "-b",
                                           getLocation("/wsdl2java_wsdl/bug305924/binding2.xml"),
+                                          "-verbose",
                                           getLocation("/wsdl2java_wsdl/bug305924/hello_world.wsdl")};
             WSDLToJava.main(args);
         } catch (Exception e) {
@@ -724,4 +726,72 @@
         assertTrue(results.indexOf("public  int  getMessageLimit") != -1);
         assertTrue(results.indexOf("header  =  true,  name  =  \"MessengerHeader") != -1);
     }
+    
+    @Test
+    public void testBindingForImportWSDL() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/cxf1095/hello_world_services.wsdl"));
+        env.put(ToolConstants.CFG_BINDING, 
+                new String[] {getLocation("/wsdl2java_wsdl/cxf1095/binding.xml")
+                              , getLocation("/wsdl2java_wsdl/cxf1095/binding1.xml")});
+        processor.setContext(env);
+        processor.execute();
+        Class clz = classLoader
+        .loadClass("org.apache.hello_world.messages.CustomizedFault");
+        assertNotNull("Customization Fault Class is not generated", clz);
+        Class serviceClz = classLoader
+        .loadClass("org.apache.hello_world.services.CustomizedService");
+        assertNotNull("Customization Fault Class is not generated", serviceClz);
+
+    }
+    @Test
+    public void testReuseJaxwsBindingFile() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/cxf1094/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/async_binding.xml"));
+        processor.setContext(env);
+        processor.execute();
+        
+        Class clz = classLoader.loadClass("org.apache.hello_world_soap_http.Greeter");
+        
+        Method method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class,
+                                                                            javax.xml.ws.AsyncHandler.class});
+ 
+        assertNotNull("jaxws binding file does not take effect for hello_world.wsdl", method1);
+
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/cxf1094/echo_date.wsdl"));
+        env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/async_binding.xml"));
+        processor.setContext(env);
+        processor.execute();
+        clz = classLoader.loadClass("org.apache.cxf.tools.fortest.date.EchoDate");
+        
+        Method method2 = clz.getMethod("echoDateAsync",
+                                       new Class[] {javax.xml.datatype.XMLGregorianCalendar.class,
+                                                    javax.xml.ws.AsyncHandler.class});       
+        assertNotNull("jaxws binding file does not take effect for echo_date.wsdl", method2);
+
+    }
+    
+    
+    @Test
+    public void testReuseJabBindingFile1() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/cxf1094/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/jaxbbinding.xml"));
+        processor.setContext(env);
+        processor.execute();
+        Class clz = classLoader.loadClass("org.apache.hello_world_soap_http.types.CreateProcess$MyProcess");
+        assertNotNull("Failed to generate customized class for hello_world.wsdl" , clz);
+       
+        env.put(ToolConstants.CFG_WSDLURL, 
+                getLocation("/wsdl2java_wsdl/cxf1094/hello_world_oneway.wsdl"));
+        env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/jaxbbinding.xml"));
+        processor.setContext(env);
+        processor.execute();
+        Class customizedClz = classLoader.loadClass("org.apache.oneway.types.CreateProcess$MyProcess");
+        assertNotNull("Failed to generate customized class for hello_world_oneway.wsdl", customizedClz);    
+    
+    }    
+    
 }