axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Tye (JIRA)" <>
Subject [jira] Commented: (AXIS-2029) SOAPHeader.appendChild() throws unexpected ClassCastException
Date Wed, 08 Jun 2005 01:38:39 GMT
    [ ] 

Mark Tye commented on AXIS-2029:

Venkat, to the best of my knowledge, the 1.1 version of the SOAP spec makes no mention of
whitespace or how it should be processed. In the absence of any SOAP-specific rules regarding
whitespace, I would assume that rules from the XML 1.0 specification would apply. Here's section
2.10 (White Space Handling) of the spec:

<xml-spec version="1.0">
In editing XML documents, it is often convenient to use "white space" (spaces, tabs, and blank
lines) to set apart the markup for greater readability. Such white space is typically not
intended for inclusion in the delivered version of the document. On the other hand, "significant"
white space that should be preserved in the delivered version is common, for example in poetry
and source code.

An XML processor MUST always pass all characters in a document that are not markup through
to the application. A validating XML processor MUST also inform the application which of these
characters constitute white space appearing in element content.

The SOAP 1.2 specification is considerably more explicit about the handling of whitespace.
I think the rule that's most relevant to this situation is found in the 4th paragraph of section
5 (SOAP Message Construct):

<soap-spec version="1.2">
Element information items defined by this specification that only have element information
items defined as allowable members of their [children] property can also have zero or more
character information item children whose character code is amongst the white space characters
as defined by XML 1.0 [XML 1.0]. Unless otherwise indicated, such character information items
are considered insignificant.

Since the SOAP Header is defined in Section 5.2 as an element information item that only has
element information items as its children, this would seem to indicate that it's indeed permissible
for the Header element to contain whitespace. The main difference between this rule and the
one you quoted in your previous comment is that in this case, the white space is *not* considered

For both versions of the SOAP spec, the implication seems to be that it's OK to have whitespace
in the SOAP Header, but such whitespace is insignificant, and should therefore be ignored.
I think this supports my contention that the SOAPHeader.appendChild(Node) method shouldn't
throw an Exception if the parameter is a Text node that contains only whitespace, but should
be allowed (or maybe required?) to throw an exception if the Text node parameter contains
any non-whitespace characters.

> SOAPHeader.appendChild() throws unexpected ClassCastException
> -------------------------------------------------------------
>          Key: AXIS-2029
>          URL:
>      Project: Axis
>         Type: Bug
>   Components: Basic Architecture, SAAJ
>     Versions: 1.2
>  Environment: Windows XP Pro/WebSphere 4.0
>     Reporter: Mark Tye
>  Attachments: 2029.diff
> 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.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message