axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Afkham Azeez <>
Subject Re: [Axis2] Question about Axis 2 SAAJ implementation
Date Tue, 14 Feb 2006 11:25:54 GMT
> Consider the following code from the SOAPElementTest:
> final String value = "foo";
> soapElem.addTextNode(value);
> I should be able to get the javax.xml.soap.Node using several
> different accessors (getChildElements(), getChildNodes(),
> getFirstChild()), etc.
> ------------------------------
> Problem 1:
> Object x = soapElem.getChildElements().next();
> Object y = soapElem.getChildElements().next();
> In this case, x and y are both javax.xml.soap.Node objects (good);
> however they are not the same object. The iterator is constructing
> new objects each time it is invoked. This is not efficient and
> incorrect.

I agree with Ias on this point. Only if you call
soapElem.getChildElements(), new objects will be created.

> -------------------------------
> Problem 2
> Object z1 = soapElem.getChildNodes().item(0);
> Object z2 = soapElem.getFirstChild();
> In both cases, the returned object is not an SAAJ
> javax.xml.soap.Node. This also seems to be a violation of the
> specification.
Note that the javax.xml.SOAPElement extends org.w3c.dom.Node. The
getChildNodes() and getFirstChild() methods are inherited from the
org.w3c.dom.Node interface. Hence we cannot return javax.xml.soap.Node
objects from these methods. For instance, the method signature of
getFirstChild() is;
    public org.w3c.dom.Node getFirstChild();
So now we can see that, we cannot return javax.xml.soap.Node objects.
In order to use only SAAJ interfaces, you need to use the methods that
are directly in the javax.xml.SOAPElement interface.


View raw message