butek 02/04/11 06:30:55
Modified: java/src/org/apache/axis/utils resources.properties
java/src/org/apache/axis/wsdl/toJava SymbolTable.java
Log:
Move checkForUndefined so that it checks each imported WSDL file for
things undefined within it. We used to get a NullPointerException for a
sample that Sam had. Now it generates a reasonable error. Sam's sample
was:
X.WSDL
Y.WSDL - depends on stuff from X but doesn't import X (bad wsdl)
Z.WSDL - imports X.WSDL and Y.WSDL.
We used to call checkForUndefined after processing all files. Because of
a quirk within WSDL4J, none of the types in Z are undefined, so we have
to check each imported file.
Revision Changes Path
1.89 +2 -0 xml-axis/java/src/org/apache/axis/utils/resources.properties
Index: resources.properties
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- resources.properties 9 Apr 2002 16:58:18 -0000 1.88
+++ resources.properties 11 Apr 2002 13:30:55 -0000 1.89
@@ -150,8 +150,10 @@
emitFailNoBindingEntry01=Emitter failure. No binding entry found for {0}
emitFailNoPortType01=Emitter failure. No portType entry found for {0}
emitFailtUndefinedBinding01=Emitter failure. There is an undefined binding ({0})
in the WSDL document.\nHint: make sure <port binding=\"..\"> is fully qualified.
+emitFailtUndefinedBinding02=Emitter failure. There is an undefined binding ({0})
in the WSDL document {1}.\nHint: make sure <port binding=\"..\"> is fully qualified.
emitFailtUndefinedMessage01=Emitter failure. There is an undefined message ({0})
in the WSDL document.\nHint: make sure <input message=\"..\"> and <output
message=".."> are fully qualified.
emitFailtUndefinedPort01=Emitter failure. There is an undefined portType ({0}) in
the WSDL document.\nHint: make sure <binding type=\"..\"> is fully qualified.
+emitFailtUndefinedPort02=Emitter failure. There is an undefined portType ({0}) in
the WSDL document {1}.\nHint: make sure <binding type=\"..\"> is fully qualified.
emitter00=emitter
empty00=empty
1.54 +29 -11 xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java
Index: SymbolTable.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- SymbolTable.java 8 Apr 2002 17:33:52 -0000 1.53
+++ SymbolTable.java 11 Apr 2002 13:30:55 -0000 1.54
@@ -326,9 +326,8 @@
*/
protected void add(String context, Definition def, Document doc)
throws IOException {
- checkForUndefined(def);
URL contextURL = context == null ? null : getURL(null, context);
- populate(contextURL, def, doc);
+ populate(contextURL, def, doc, null);
checkForUndefined();
populateParameters();
setReferences(def, doc); // uses wrapped flag set in populateParameters
@@ -337,16 +336,23 @@
/**
* Scan the Definition for undefined objects and throw an error.
*/
- private void checkForUndefined(Definition def) throws IOException {
+ private void checkForUndefined(Definition def, String filename) throws
IOException {
if (def != null) {
// Bindings
Iterator ib = def.getBindings().values().iterator();
while (ib.hasNext()) {
Binding binding = (Binding) ib.next();
if (binding.isUndefined()) {
- throw new IOException(
+ if (filename == null) {
+ throw new IOException(
JavaUtils.getMessage("emitFailtUndefinedBinding01",
binding.getQName().getLocalPart()));
+ }
+ else {
+ throw new IOException(
+ JavaUtils.getMessage("emitFailtUndefinedBinding02",
+ binding.getQName().getLocalPart(), filename));
+ }
}
}
@@ -355,9 +361,16 @@
while (ip.hasNext()) {
PortType portType = (PortType) ip.next();
if (portType.isUndefined()) {
- throw new IOException(
+ if (filename == null) {
+ throw new IOException(
JavaUtils.getMessage("emitFailtUndefinedPort01",
portType.getQName().getLocalPart()));
+ }
+ else {
+ throw new IOException(
+ JavaUtils.getMessage("emitFailtUndefinedPort02",
+ portType.getQName().getLocalPart(), filename));
+ }
}
}
@@ -400,10 +413,13 @@
/**
* Add the given Definition and Document information to the symbol table
(including imported
* symbols), populating it with SymTabEntries for each of the top-level symbols.
+ * NOTE: filename is used only by checkForUndefined so that it can report
which WSDL file
+ * has the problem. If we're on the primary WSDL file, then we don't know the
name and
+ * filename will be null. But we know the names of all imported files.
*/
private HashSet importedFiles = new HashSet();
- private void populate(URL context, Definition def, Document doc)
- throws IOException {
+ private void populate(URL context, Definition def, Document doc,
+ String filename) throws IOException {
if (doc != null) {
populateTypes(doc);
@@ -413,6 +429,7 @@
}
}
if (def != null) {
+ checkForUndefined(def, filename);
if (addImports) {
// Add the symbols from the wsdl:import'ed WSDL documents
Map imports = def.getImports();
@@ -425,7 +442,8 @@
importedFiles.add(imp.getLocationURI());
URL url = getURL(context, imp.getLocationURI());
populate(url, imp.getDefinition(),
- XMLUtils.newDocument(url.toString()));
+ XMLUtils.newDocument(url.toString()),
+ url.toString());
}
}
}
@@ -496,10 +514,10 @@
NamedNodeMap attributes = child.getAttributes();
Node importFile = attributes.getNamedItem("schemaLocation");
if (importFile != null) {
+ String filename = getURL(context,
+ importFile.getNodeValue()).toString();
populate(context, null,
- XMLUtils.newDocument(
- getURL(context,
- importFile.getNodeValue()).toString()));
+ XMLUtils.newDocument(filename), filename);
}
}
lookForImports(context, child);