axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From R J Scheuerle Jr <>
Subject Re: [Axis2] Question about Axis 2 SAAJ implementation
Date Tue, 14 Feb 2006 13:42:46 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.

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

Scheu response:
Thanks Afkham.
The Iterator returned by getChildElements should traverse the actual
soap.Node objects in the tree.  One should be able to use the iterator to
add to the tree.  The iterator should also support removal of the elements.
The iterator could be used frequently by callers and the implementation;
thus it should not be creating new proxy objects representing the soap.Node

>> -------------------------------
>> 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.

>Afkham said:
>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.

My response:

Yes, per the SAAJ 1.2 specification, the SOAPElement interface extends the
org.w3c.dom.Element interface.
This revision of the specification allows you to access the SAAJ tree using
traditional DOM methods.
It also allows the SAAJ tree to be treated like a DOM tree.

Note that javax.xml.soap.Node extends org.w3c.dom.Node.

If this is a SAAJ tree, the getFirstChild method should return a
org.w3c.dom.Node which is also a valid object in the SAAJ tree (which means
that it must also be a javax.xml.soap.Node).

If one has a SOAPBody object and accesses a child node (via any of the SAAJ
1.2 methods), the child node must be either a
javax.xml.soap.SOAPBodyElement, javax.xml.soap.SOAPFault or
javax.xml.soap.Text object.

dims asked "where's the patch":

My response:
There are several "phases" of changes that are needed to move to this
model.  I could add all of them as one large patch, but I am more
comfortable with adding the changes gradually (with testcases).  What do I
need to do to become a committer (I was a committer for Axis 1.0).

Here is a view of the proposed model:

Initially we have a SOAPBody (view) that has uses DOOM as the backing store

               ---------------                          ----------------
               | SOAPBody    |  -------delegate-------> | OM Element   |
               ---------------  <--------view---------- ----------------
                                                           |           |
                                                    | OM Element|  -  | OM

The SOAPBody.getFirstChild() method is invoked.  The getFirstChild() method
implementation should look
something like this.

getSOAPBody() {
   // Get the object representing the first child from the delegate
   doomNode = delegate.getFirstChild();

   // If the doom node already has an SAAJ view, then use it.
   // Otherwise create one
   org.w3c.saaj.Node node = getOrCreateSAAJNodeFromDOOMNode(doomNode);

   return node;

The result of calling this method is:

               ---------------                          ----------------
               | SOAPBody    |  -------delegate-------> | OM Element   |
               ---------------  <--------view---------- ----------------
                                                           |           |
               ------------------                   -------------
               | SOAPBodyElement| ----delegate----> | OM Element|  -  | OM
               ------------------ <-----view------- -------------

Important notes:
1) The SAAJ objects are lightweight view objects onto the DOOM tree.
2) All hierarchy information is maintained in the DOOM tree.  There are no
pointers between SAAJ objects.
3) The SAAJ objects are lazily instantiated.

Comments ?

Rich Scheuerle
Senior Developer
IBM WebSphere Web Services Engine & Tooling
512-838-5115  (IBM TL 678-5115)
View raw message