3 Replies Latest reply on May 17, 2005 6:40 AM by thomas.diesler

    16:22:50,265 ERROR [SOAPElementAxisImpl] Cannot convert SAX

    avrahamr

      I just downloaded JBoss 4.0.2 and tried to deploy my previous applications developed under 4.0.1sp1.

      One of them is a JAX-RPC Collector, trying to get a String from a SOAPMessage. It was working on 4.0.0 to 4.0.1sp1, now I got an exception. Someone has an Idea why, or another way to get the Soap Message as String that will work for all versions.

      Here is the code:

      ...
      SOAPMessageContext soapContext = (SOAPMessageContext) messageContext;
      SOAPMessage soapMsg = soapContext.getMessage();
      SOAPEnvelope envelope = soapMsg.getSOAPPart().getEnvelope();
      String soapText = nodeToString(envelope);
      ...
      private String nodeToString(Node node) throws TransformerFactoryConfigurationError, TransformerException {
      
       Source domSource = new DOMSource(node);
       StringWriter writer = new StringWriter();
       Result result = new StreamResult(writer);
       Transformer xformer = TransformerFactory.newInstance().newTransformer();
       xformer.transform(domSource, result); //Exception HERE!!
       return writer.toString();
      }
      


      And the Exception:

      16:22:50,245 ERROR [SOAPElementAxisImpl] Cannot convert SAX to DOM attributes
      org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
      at org.apache.xerces.dom.CoreDocumentImpl.checkNamespaceWF(Unknown Source)
      at org.apache.xerces.dom.AttrNSImpl.setName(Unknown Source)
      at org.apache.xerces.dom.AttrNSImpl.<init>(Unknown Source)
      at org.apache.xerces.dom.CoreDocumentImpl.createAttributeNS(Unknown Source)
      at org.jboss.axis.message.SOAPElementAxisImpl.convertAttrSAXtoDOM(SOAPElementAxisImpl.java:724)
      at org.jboss.axis.message.SOAPElementAxisImpl.getAttributes(SOAPElementAxisImpl.java:686)
      at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:316)
      at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:159)
      at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:337)
      at ****.nodeToString(***.java:382)
      ...


      Thanks
      Avraham

        • 1. Re: 16:22:50,265 ERROR [SOAPElementAxisImpl] Cannot convert
          danoakland

          I ran into this same problem -- it occurs when parsing a SOAP response and there is an attribute with a URI. The JBoss code that causes the exception is in the org.jboss.axis.message.SOAPElementAxisImpl at line 724. The 4.0.2 source code I downloaded shows this (starting with line 712):

          if (uri != null && uri.trim().length() > 0)
           {
           // filterring out the tricky method to differentiate the null namespace
           // -ware case
           if (uri.equals("intentionalNullURI"))
           {
           uri = null;
           }
          
           if (qname.startsWith("xmlns:") == false && qname.startsWith("xsi:") == false)
           qname = "xmlns:" + qname;
          
           Attr attr = doc.createAttributeNS(uri, qname);
           attr.setValue(value);
           domAttributes.setNamedItemNS(attr);
           }
          


          What happens is that any attribute with a URI, say for example, "POS:lineTotal" ends up being passed to the Document.createAttributeNS method as "xmlns:POS:lineTotal". It seems to be a bug. If I can find some time to create a test case, I'll submit it to JIRA.

          By the way, commenting out lines 721 and 722 (where qname is set to "xmlns:" + qname) seems to correct the problem for me, but I'm not sure what consequences that would have in other cases.

          Dan

          • 2. Re: 16:22:50,265 ERROR [SOAPElementAxisImpl] Cannot convert
            avrahamr

            I found a way to make it work on 4.0.2. I didn't test it back to 4.0.1:

            SOAPMessageContext soapContext = (SOAPMessageContext) messageContext;
            SOAPMessage soapMsg = soapContext.getMessage();
            Source source = soapMsg.getSOAPPart().getContent();
            StringWriter writer = new StringWriter();
            Result result = new StreamResult(writer);
            Transformer xformer = TransformerFactory.newInstance().newTransformer();
            xformer.transform(source, result);
            return writer.toString();
            


            • 3. Re: 16:22:50,265 ERROR [SOAPElementAxisImpl] Cannot convert
              thomas.diesler