[jboss-user] [JBossWS] - Re: IndexOutOfBoundsException when transforming into SAAJ SO

alessio.soldano@jboss.com do-not-reply at jboss.com
Tue Jul 29 12:05:12 EDT 2008


OK, I've taken a look at your issue: I've added your test to the native testsuite. Our implementation of Node, NodeImpl, holds the actual w3c node along with its children and our implementation of soapChildren. The exception you were having was due to the latter being null while it should have not. That's happen because of the transformation you use to append your document content to the SOAPBody.
I've put a check there to prevent throwing the exception, but I know that's not the solution of your issue, as you don't get the soap message you would expect.
In particular, as far as I can see, the current implementation was written relying on the following signature for the org.w3c.dom.Node's appendChild method:
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException
The implementation returns a new Node (a wrapper of the supplied one), that's what is actually appended as a child. The xalan implementation that does the transformation works on the node parameter supplied to the appendChild method.
For the sake of understanding, the following patch on the current trunk of Xalan would fix this:

  | [alessio at dhcp-176-228 trunk]$ svn diff src/org/apache/xml/utils/DOMBuilder.java
  | Index: src/org/apache/xml/utils/DOMBuilder.java
  | ===================================================================
  | --- src/org/apache/xml/utils/DOMBuilder.java    (revisione 680693)
  | +++ src/org/apache/xml/utils/DOMBuilder.java    (copia locale)
  | @@ -172,26 +172,27 @@
  |     *
  |     * @param newNode New node to append
  |     */
  | -  protected void append(Node newNode) throws org.xml.sax.SAXException
  | +  protected Node append(Node newNode) throws org.xml.sax.SAXException
  |    {
  |  
  |      Node currentNode = m_currentNode;
  | +    Node result = null;
  |  
  |      if (null != currentNode)
  |      {
  |        if (currentNode == m_root && m_nextSibling != null)
  | -        currentNode.insertBefore(newNode, m_nextSibling);
  | +         result = currentNode.insertBefore(newNode, m_nextSibling);
  |        else
  | -        currentNode.appendChild(newNode);
  | +         result = currentNode.appendChild(newNode);
  |  
  |        // System.out.println(newNode.getNodeName());
  |      }
  |      else if (null != m_docFrag)
  |      {
  |        if (m_nextSibling != null)
  | -        m_docFrag.insertBefore(newNode, m_nextSibling);
  | +         result = m_docFrag.insertBefore(newNode, m_nextSibling);
  |        else
  | -        m_docFrag.appendChild(newNode);
  | +         result = m_docFrag.appendChild(newNode);
  |      }
  |      else
  |      {
  | @@ -226,11 +227,12 @@
  |        if (ok)
  |        {
  |          if (m_nextSibling != null)
  | -          m_doc.insertBefore(newNode, m_nextSibling);
  | +          result = m_doc.insertBefore(newNode, m_nextSibling);
  |          else
  | -          m_doc.appendChild(newNode);
  | +          result = m_doc.appendChild(newNode);
  |        }
  |      }
  | +    return result;
  |    }
  |  
  |    /**
  | @@ -329,7 +331,7 @@
  |      else
  |        elem = m_doc.createElementNS(ns, name);
  |  
  | -    append(elem);
  | +    elem = (Element)append(elem);
  |  
  |      try
  |      {
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4167381#4167381

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4167381



More information about the jboss-user mailing list