You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ax...@ws.apache.org on 2004/10/15 08:14:51 UTC

[jira] Commented: (AXIS-1538) getParentNode returns null on Envelopes

The following comment has been added to this issue:

     Author: Jayachandra Sekhara Rao Sunkara
    Created: Thu, 14 Oct 2004 11:14 PM
       Body:
Hi Michael,
I think, response messages (similarly request message on the clinet side) are clearly part of a tree like object model. But since they are SOAP messages, Axis follows the convention of wrapping the message with envelope as the root. Thats the reason SOAP envelope fails to have a parent. getParent() returns null but surely you can query through getChildren() the various parts inside the envelope (viz. Body, header etc.). Infact SOAPEnvelope class completely implements org.w3c.dom.Node interface through one of its super class (NodeImpl) in the inheritance hierarchy chain. Hope this makes things clearer. If that clarifies the doubt, we can have this bug's status resolved/closed.
---------------------------------------------------------------------
View this comment:
  http://issues.apache.org/jira/browse/AXIS-1538?page=comments#action_54138

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/AXIS-1538

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: AXIS-1538
    Summary: getParentNode returns null on Envelopes
       Type: Bug

     Status: Unassigned
   Priority: Minor

    Project: Axis
   Versions:
             beta-3

   Assignee: 
   Reporter: Michael Theroux

    Created: Tue, 31 Aug 2004 1:17 PM
    Updated: Thu, 14 Oct 2004 11:14 PM
Environment: Windows 2000, JDK 1.3

Description:
I am attempting to run an XSLT directly against a result SOAPEnvelope and have hit a couple of issues.  I worked around bug AXIS-1537 using a local Axis build.  The next issue I got is demonstrated by the following code snippet:


/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;

public class Test
{
   public static void main(String [] args) {
       try {
           String endpoint =
                    "http://webservices.sonicsw.com:8080/axis/CreditCheck.jws";

           Service  service = new Service();
           Call     call    = (Call) service.createCall();

           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://webservices.sonicsw.com:8080/axis/CreditCheck.jws", "checkCredit") );

           // Call to addParameter/setReturnType as described in user-guide.html
           call.addParameter("custid",
                             org.apache.axis.Constants.XSD_STRING,
                             javax.xml.rpc.ParameterMode.IN);
           call.addParameter("amount",
                             org.apache.axis.Constants.XSD_FLOAT,
                             javax.xml.rpc.ParameterMode.IN);
           call.setReturnType(org.apache.axis.Constants.XSD_BOOLEAN);

           Boolean ret = (Boolean) call.invoke( new Object[] { "1234", new Float( 1.24 ) } );
           org.w3c.dom.Node n = call.getResponseMessage().getSOAPEnvelope();
//           n.getPreviousSibling();
           org.w3c.dom.Node parentNode = n.getParentNode();
           if( parentNode == null )
               System.err.println( "PARENT NODE IS NULL!" );

//           String test = com.sonicsw.xqimpl.script.Util.getElementAsString( (org.w3c.dom.Element)n, true );
           String test = org.apache.axis.utils.DOM2Writer.nodeToString( n, true );
           System.out.println("Resulting XML: " + test );

       } catch (Exception e) {
           e.printStackTrace();
           System.err.println(e.toString());
       }
   }
}

What happens is n.getParentNode() returns null.  This causes my particular XSLT transformation engine not to perform a transform because, if the parentNode is null.  This results in the transformer resulting in and exception "Supplied element is not within a Document"

This error jives with the javadoc for org.w3c.dom.Node:

getParentNode

public Node getParentNode()

     The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null. 

Is this the intended behavior?  Is the SOAPEnvelope node intended not to be part of a tree?

A workaround is to call getAsDOM() on the Envelope.  

However, performance may make this undesireable.  getAsDOM() will cause Axis's object model to be serialized as a string, then a subsequent deserialization will occur to create a native DOM because of performanceit results in a serialization of Axis's DOM structure to a string, then another deserialization occurs to create a DOM in your parser (such as Xerces).



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira