You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2010/01/22 23:03:24 UTC
svn commit: r902290 -
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
Author: scheu
Date: Fri Jan 22 22:03:24 2010
New Revision: 902290
URL: http://svn.apache.org/viewvc?rev=902290&view=rev
Log:
Quick fix for to allow SAAJ Converter to ignore bad prefix declares.
Contributor: Rich Scheuerle
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java?rev=902290&r1=902289&r2=902290&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java Fri Jan 22 22:03:24 2010
@@ -475,17 +475,41 @@
for (int i=0; i<size; i++) {
String pre = reader.getNamespacePrefix(i);
String ns = reader.getNamespaceURI(i);
- String existingNS = element.getNamespaceURI(pre);
- if (!ns.equals(existingNS)) {
- element.removeNamespaceDeclaration(pre); // Is it necessary to remove the existing prefix/ns
- element.addNamespaceDeclaration(pre, ns);
+ if ((pre != null && pre.length() > 0) &&
+ (ns == null || ns.length() == 0)) {
+ if (log.isDebugEnabled()) {
+ log.debug("The prefix is (" + pre + ") but there is no namespace. " +
+ "This erroneous declaration is skipped.");
+ }
+ } else {
+ String existingNS = element.getNamespaceURI(pre);
+ if (!ns.equals(existingNS)) {
+ element.removeNamespaceDeclaration(pre); // Is it necessary to remove the existing prefix/ns
+ element.addNamespaceDeclaration(pre, ns);
+ }
}
}
} else {
// Add the namespace declarations from the reader
int size = reader.getNamespaceCount();
for (int i=0; i<size; i++) {
- element.addNamespaceDeclaration(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
+ String newPrefix = reader.getNamespacePrefix(i);
+ String newNS = reader.getNamespaceURI(i);
+
+ if ((newPrefix != null && newPrefix.length() > 0) &&
+ (newNS == null || newNS.length() == 0)) {
+ // Due to a bug in Axiom DOM or the reader, I have
+ // seen cases where the prefix is non-null but there is not
+ // namespace. Example: prefix is axis2ns3 and namespace is null.
+ // This is an error..log, tolerate and continue
+ if (log.isDebugEnabled()) {
+ log.debug("The prefix is (" + newPrefix + ") but there is no namespace. " +
+ "This erroneous declaration is skipped.");
+ }
+ } else {
+ element.addNamespaceDeclaration(newPrefix,
+ newNS);
+ }
}
}