You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2007/10/12 08:02:07 UTC
svn commit: r584059 - in /incubator/cxf/trunk/tools/wsdlto:
frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/
frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/
test/src/test/java/org/ap...
Author: ema
Date: Thu Oct 11 23:02:07 2007
New Revision: 584059
URL: http://svn.apache.org/viewvc?rev=584059&view=rev
Log:
Fixed issue CXF-1106
Fixed typo Glen pointed out
Added:
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/
incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/binding.xml
Modified:
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomNodeSelector.java
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java
incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomNodeSelector.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomNodeSelector.java?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomNodeSelector.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomNodeSelector.java Thu Oct 11 23:02:07 2007
@@ -24,6 +24,7 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.apache.cxf.helpers.MapNamespaceContext;
import org.apache.cxf.helpers.XPathUtils;
@@ -68,9 +69,18 @@
public Node queryNode(final Node target, final String expression) {
XPathUtils xpath = new XPathUtils(context);
-
+
Node node = (Node) xpath.getValue(expression, target, XPathConstants.NODE);
return node;
}
+
+ public NodeList queryNodes(final Node target, final String expression) {
+ XPathUtils xpath = new XPathUtils(context);
+
+ NodeList nodeList = (NodeList) xpath.getValue(expression, target, XPathConstants.NODESET);
+
+ return nodeList;
+ }
+
}
Modified: incubator/cxf/trunk/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/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Thu Oct 11 23:02:07 2007
@@ -86,7 +86,11 @@
String[] bindingFiles;
try {
wsdlURL = URIParserUtil.getAbsoluteURI((String)env.get(ToolConstants.CFG_WSDLURL));
- wsdlNode = getTargetNode(this.wsdlURL);
+ try {
+ wsdlNode = getTargetNode(this.wsdlURL);
+ } catch (IOException e) {
+ // do nothing
+ }
customizedElements.put(wsdlURL.toString(), wsdlNode);
bindingFiles = (String[])env.get(ToolConstants.CFG_BINDING);
if (bindingFiles == null) {
@@ -116,20 +120,21 @@
buildHandlerChains();
}
- public Element getTargetNode(String wsdlLoc) {
+ public Element getTargetNode(String wsdlLoc) throws IOException {
Document doc = null;
InputStream ins = null;
try {
URIResolver resolver = new URIResolver(wsdlLoc);
ins = resolver.getInputStream();
} catch (IOException e1) {
- throw new ToolException(e1);
+ throw e1;
+
}
try {
doc = DOMUtils.readXml(ins);
} catch (Exception e) {
- Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {wsdlLoc});
+ Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[]{wsdlLoc});
throw new ToolException(msg, e);
}
@@ -189,9 +194,12 @@
Element jaxbBindingElement = getJaxbBindingElement(jaxwsBindingNode);
appendJaxbVersion((Element)schemaNode);
if (jaxbBindingElement != null) {
- copyAllJaxbDeclarations(nodeSelector.queryNode(schemaNode,
- jaxbBindingElement.getAttribute("node")),
- jaxbBindingElement);
+ NodeList nlist = nodeSelector.queryNodes(schemaNode,
+ jaxbBindingElement.getAttribute("node"));
+ for (int i = 0; i < nlist.getLength(); i++) {
+ Node node = nlist.item(i);
+ copyAllJaxbDeclarations(node, jaxbBindingElement);
+ }
return;
}
@@ -242,16 +250,19 @@
nodeSelector.addNamespaces(bindings);
- Node node = nodeSelector.queryNode(targetNode, expression);
- if (node == null) {
+ NodeList nodeList = nodeSelector.queryNodes(targetNode, expression);
+ if (nodeList == null || nodeList.getLength() == 0) {
throw new ToolException(new Message("NODE_NOT_EXISTS",
LOG, new Object[] {expression}));
}
- if (hasJaxbBindingDeclaration(bindings)) {
- copyAllJaxbDeclarations(node, bindings);
- } else {
- copyBindingsToWsdl(node, bindings, nodeSelector.getNamespaceContext());
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (hasJaxbBindingDeclaration(bindings)) {
+ copyAllJaxbDeclarations(node, bindings);
+ } else {
+ copyBindingsToWsdl(node, bindings, nodeSelector.getNamespaceContext());
+ }
}
}
@@ -369,7 +380,7 @@
if (isValidJaxwsBindingFile(bindingFile, reader)) {
String wsdlLocation = root.getAttribute("wsdlLocation");
- Element targetNode;
+ Element targetNode = null;
if (!StringUtils.isEmpty(wsdlLocation)) {
URI wsdlURI = null;
try {
@@ -391,7 +402,13 @@
}
}
- targetNode = this.getTargetNode(wsdlURI.toString());
+ try {
+ targetNode = this.getTargetNode(wsdlURI.toString());
+ } catch (IOException e) {
+ Message msg = new Message("POINT_TO_WSDL_DOES_NOT_EXIST",
+ LOG, new Object[]{bindingFile, wsdlURI.toString()});
+ throw new ToolException(msg, e);
+ }
if (targetNode == null) {
Message msg = new Message("CAN_NOT_FIND_BINDING_WSDL",
LOG, new Object[] {wsdlURI.normalize(), bindingFile});
@@ -400,7 +417,11 @@
}
root.setAttribute("wsdlLocation", wsdlURI.toString());
} else {
- targetNode = this.getTargetNode(wsdlURL);
+ try {
+ targetNode = getTargetNode(wsdlURL);
+ } catch (IOException e) {
+ //do nothing
+ }
root.setAttribute("wsdlLocation", wsdlURL);
}
jaxwsBindingsMap.put(root, targetNode);
@@ -417,7 +438,7 @@
jaxbBindings.add(newis);
tmpFile.deleteOnExit();
} catch (Exception e) {
- Message msg = new Message("FAILED_TO_ADD_SCHEMALOACTION", LOG, bindingFile);
+ Message msg = new Message("FAILED_TO_ADD_SCHEMALOCATION", LOG, bindingFile);
throw new ToolException(msg, e);
}
} else {
Modified: incubator/cxf/trunk/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/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/Messages.properties Thu Oct 11 23:02:07 2007
@@ -20,11 +20,12 @@
#
STAX_PARSER_ERROR = StAX parser error, check your external binding file(s)
UNKNOWN_BINDING_FILE= Unknown external binding files : {0}
-CAN_NOT_FIND_BINDING_WSDL = Can not read the specified wsdl {0} that external binding file {1} points
+CAN_NOT_FIND_BINDING_WSDL = Can not read the specified wsdl {0} that external binding file {1} points to
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}
-FAILED_TO_ADD_SCHEMALOACTION = Failed to inject schmeaLoaction for binding file {0}
\ No newline at end of file
+FAILED_TO_ADD_SCHEMALOCATION = Failed to inject schmeaLoaction for binding file {0}
+POINT_TO_WSDL_DOES_NOT_EXIST = Binding file : {0} points to wsdl(resovled as {1}) does not exist
\ No newline at end of file
Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java Thu Oct 11 23:02:07 2007
@@ -41,8 +41,8 @@
private Catalog catalogResolver;
private Map<String, Element> elementMap;
- private String lastestImportURI;
- private boolean resolveFormMap;
+ private String latestImportURI;
+ private boolean resolveFromMap;
public CustomizedWSDLLocator(String wsdlUrl, Map<String, Element> map) {
this.wsdlUrl = wsdlUrl;
@@ -95,8 +95,8 @@
return baseUri;
}
public String getLatestImportURI() {
- if (this.resolveFormMap) {
- return this.lastestImportURI;
+ if (this.resolveFromMap) {
+ return this.latestImportURI;
}
return resolver.getLatestImportURI();
@@ -117,15 +117,15 @@
InputSource ins = new InputSource(new StringReader(content));
ins.setSystemId(importURI.toString());
- this.resolveFormMap = true;
- this.lastestImportURI = importURI.toString();
+ this.resolveFromMap = true;
+ this.latestImportURI = importURI.toString();
return ins;
}
} catch (URISyntaxException e) {
- throw new RuntimeException("Resolve " + importLocation + "Failed: ", e);
+ throw new RuntimeException("Failed to Resolve " + importLocation, e);
}
- resolveFormMap = false;
+ resolveFromMap = false;
return resolve(importedUri, baseUri);
}
public void close() {
Modified: incubator/cxf/trunk/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/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java Thu Oct 11 23:02:07 2007
@@ -167,7 +167,7 @@
}
private Definition buildCustomizedDefinition() throws Exception {
- Map<String, Element> eleMap = cusParser.getCustomizedWSDLElements();
+ 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());
Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=584059&r1=584058&r2=584059&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java Thu Oct 11 23:02:07 2007
@@ -741,6 +741,7 @@
assertNotNull("Customization Fault Class is not generated", serviceClz);
}
+
@Test
public void testReuseJaxwsBindingFile() throws Exception {
env.put(ToolConstants.CFG_WSDLURL,
@@ -787,8 +788,31 @@
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);
-
+ assertNotNull("Failed to generate customized class for hello_world_oneway.wsdl",
+ customizedClz);
}
+
+ @Test
+ public void testBindingXPath() throws Exception {
+ env.put(ToolConstants.CFG_WSDLURL,
+ getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+ env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1106/binding.xml"));
+ processor.setContext(env);
+ processor.execute();
+ Class clz = classLoader
+ .loadClass("org.apache.hello_world_soap_http.Greeter");
+ assertNotNull("Failed to generate SEI class", clz);
+ Method[] methods = clz.getMethods();
+ assertEquals("jaxws binding file parse error, number of generated method is not expected"
+ , 14, methods.length);
+
+ boolean existSayHiAsyn = false;
+ for (Method m : methods) {
+ if (m.getName().equals("sayHiAsyn")) {
+ existSayHiAsyn = true;
+ }
+ }
+ assertFalse("sayHiAsyn method should not be generated", existSayHiAsyn);
+ }
}
Added: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/binding.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/binding.xml?rev=584059&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/binding.xml (added)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf1106/binding.xml Thu Oct 11 23:02:07 2007
@@ -0,0 +1,32 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<bindings
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ wsdlLocation="../hello_world.wsdl"
+ xmlns="http://java.sun.com/xml/ns/jaxws">
+ <bindings node="wsdl:definitions/wsdl:portType[@name='Greeter']">
+ <bindings node="wsdl:operation[@name !='sayHi']">
+ <enableAsyncMapping>true</enableAsyncMapping>
+ </bindings>
+ </bindings>
+</bindings>
+
+
+
\ No newline at end of file