Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-2029

SOAPHeader.appendChild() throws unexpected ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2
    • None
    • Basic Architecture, SAAJ
    • Windows XP Pro/WebSphere 4.0

    Description

      The class org.apache.axis.message.SOAPHeader overrides the appendChild(org.w3c.dom.Node) method of org.apache.axis.message.NodeImpl in such a way that it breaks the contract of the org.3c.dom.Node.appendChild(org.w3c.dom.Node) interface.

      Here's the implementation of appendChild(Node) in SOAPHeader:

      390 public Node appendChild(Node newChild) throws DOMException {
      391 SOAPHeaderElement headerElement = null;
      392 if(newChild instanceof SOAPHeaderElement)
      393 headerElement = (SOAPHeaderElement)newChild;
      394 else
      395 headerElement = new SOAPHeaderElement((Element)newChild);
      396 try

      { 397 addChildElement(headerElement); 398 }

      catch (SOAPException e)

      { 399 throw new DOMException(DOMException.INVALID_STATE_ERR,e.toString()); 400 }

      401 return headerElement;
      402 }

      This works fine if the newChild Node parameter is an instance of SOAPHeaderElement or org.w3c.dom.Element, but any other subclass of Node will cause a ClassCastException to be thrown at line 395.

      It's reasonable to expect that in most cases, the Node being appended to a SOAP Header will be DOM Element representing a header entry. However, there is no prohibition in the SOAP 1.1 Note or the SOAP 1.2 Recommendation against whitespace before, after, or in between the header entries of a SOAP Header. Some parsers will render such whitespace as Text nodes, which will cause a ClassCastException in the appendChild() method.

      Even if a deliberate design decision has been made not to support whitespace in the SOAPHeader class, the appendChild(Node) method should probably do something more elegant than throw a ClassCastException if the Node parameter is a Text node containing whitespace.

      Attachments

        1. 2029.diff
          1 kB
          Ashutosh Shahi

        Activity

          People

            ashutosh Ashutosh Shahi
            mtye Mark Tye
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: