You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ga...@apache.org on 2004/06/22 19:42:50 UTC

cvs commit: ws-axis/java/src/org/apache/axis/message MessageElement.java SOAPBody.java SOAPBodyElement.java SOAPFault.java SOAPFaultBuilder.java SOAPHeader.java SOAPHeaderElement.java

gawor       2004/06/22 10:42:50

  Modified:    java/src/org/apache/axis/client Call.java
               java/src/org/apache/axis/encoding/ser
                        DocumentDeserializer.java ElementDeserializer.java
               java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/message MessageElement.java
                        SOAPBody.java SOAPBodyElement.java SOAPFault.java
                        SOAPFaultBuilder.java SOAPHeader.java
                        SOAPHeaderElement.java
  Log:
  SAAJ API updates, makes SOAPBody/SOAPHeader impl more consistent, setParent() removes a child from previous parent, and setDirty() propagates the flag to the parent
  
  Revision  Changes    Path
  1.226     +6 -2      ws-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.225
  retrieving revision 1.226
  diff -u -r1.225 -r1.226
  --- Call.java	17 Jun 2004 21:48:39 -0000	1.225
  +++ Call.java	22 Jun 2004 17:42:49 -0000	1.226
  @@ -2002,8 +2002,12 @@
   
           if ( params == null || numParams != params.length ) {
               throw new JAXRPCException(
  -                    Messages.getMessage("parmMismatch00",
  -                    "" + params.length, "" + numParams) );
  +                    Messages.getMessage(
  +                              "parmMismatch00",
  +                              (params == null) ? "no params" : "" + params.length, 
  +                              "" + numParams
  +                   ) 
  +           );
           }
   
           log.debug( "getParamList number of params: " + params.length);
  
  
  
  1.4       +2 -2      ws-axis/java/src/org/apache/axis/encoding/ser/DocumentDeserializer.java
  
  Index: DocumentDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/DocumentDeserializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentDeserializer.java	25 Feb 2004 14:02:37 -0000	1.3
  +++ DocumentDeserializer.java	22 Jun 2004 17:42:50 -0000	1.4
  @@ -25,7 +25,7 @@
   import org.apache.commons.logging.Log;
   import org.xml.sax.SAXException;
   
  -import java.util.ArrayList;
  +import java.util.List;
   
   /**
    * Deserializer for DOM Document
  @@ -53,7 +53,7 @@
                       messageContext.setProperty(DESERIALIZE_CURRENT_ELEMENT, Boolean.FALSE);
                       return;
                   }
  -                ArrayList children = msgElem.getChildren();
  +                List children = msgElem.getChildren();
                   if ( children != null ) {
                       msgElem = (MessageElement) children.get(0);
                       if ( msgElem != null )
  
  
  
  1.21      +2 -2      ws-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializer.java
  
  Index: ElementDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ElementDeserializer.java	25 Feb 2004 14:02:37 -0000	1.20
  +++ ElementDeserializer.java	22 Jun 2004 17:42:50 -0000	1.21
  @@ -25,7 +25,7 @@
   import org.apache.commons.logging.Log;
   import org.xml.sax.SAXException;
   
  -import java.util.ArrayList;
  +import java.util.List;
   
   /**
    * Deserializer for DOM elements
  @@ -54,7 +54,7 @@
                       messageContext.setProperty(DESERIALIZE_CURRENT_ELEMENT, Boolean.FALSE);
                       return;
                   }
  -                ArrayList children = msgElem.getChildren();
  +                List children = msgElem.getChildren();
                   if ( children != null ) {
                       msgElem = (MessageElement) children.get(0);
                       if ( msgElem != null )
  
  
  
  1.90      +1 -0      ws-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- resource.properties	13 Jun 2004 13:06:19 -0000	1.89
  +++ resource.properties	22 Jun 2004 17:42:50 -0000	1.90
  @@ -91,6 +91,7 @@
   badWSDDElem00=Invalid WSDD Element
   beanSerConfigFail00=Exception configuring bean serialization for {0}
   bodyElementParent=Warning: SOAPBodyElement.setParentElement should take a SOAPBody parameter instead of a SOAPEnvelope (but need not be called after SOAPBody.addBodyElement)
  +bodyHeaderParent=Warning: SOAPHeaderElement.setParentElement should take a SOAPHeader parameter instead of a SOAPEnvelope (but need not be called after SOAPHeader.addHeaderElement)
   bodyElems00=There are {0} body elements.
   bodyIs00=body is {0}
   bodyPresent=Body already present
  
  
  
  1.169     +120 -76   ws-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.168
  retrieving revision 1.169
  diff -u -r1.168 -r1.169
  --- MessageElement.java	15 Jun 2004 17:26:34 -0000	1.168
  +++ MessageElement.java	22 Jun 2004 17:42:50 -0000	1.169
  @@ -24,6 +24,7 @@
   import java.util.Iterator;
   import java.util.Vector;
   import java.util.Enumeration;
  +import java.util.List;
   
   import javax.xml.namespace.QName;
   import javax.xml.rpc.encoding.TypeMapping;
  @@ -120,7 +121,7 @@
   
       /** No-arg constructor for building messages?
        */
  -    public MessageElement()
  +    public MessageElement() 
       {
       }
   
  @@ -138,7 +139,7 @@
           addMapping(new Mapping(namespace, prefix));
       }
   
  -    public MessageElement(Name eltName)
  +    public MessageElement(Name eltName) 
       {
           this(eltName.getLocalName(),eltName.getPrefix(), eltName.getURI());
       }
  @@ -149,7 +150,7 @@
           objectValue = value;
       }
   
  -    public MessageElement(QName name)
  +    public MessageElement(QName name) 
       {
           this(name.getNamespaceURI(), name.getLocalPart());
       }
  @@ -277,7 +278,7 @@
       {
           return fixupDeserializer;
       }
  -
  + 
       public void setEndIndex(int endIndex)
       {
           endEventIndex = endIndex;
  @@ -285,7 +286,14 @@
       }
   
       public boolean isDirty() { return _isDirty; }
  -    public void setDirty(boolean dirty) { _isDirty = dirty; }
  +
  +    public void setDirty(boolean dirty)
  +    { 
  +        _isDirty = dirty; 
  +        if (_isDirty && parent != null) {
  +            parent.setDirty(true);
  +        }
  +    }
   
       public boolean isRoot() { return _isRoot; }
       public String getID() { return id; }
  @@ -294,21 +302,22 @@
   
       public Attributes getAttributesEx() { return attributes; }
   
  -    public Node getFirstChild() {
  -        Iterator iterator = getChildElements();
  -        if(iterator != null && iterator.hasNext()){
  -            return (Node)iterator.next();
  -        }else{
  +    public Node getFirstChild()
  +    {
  +        if (children != null && !children.isEmpty()) {
  +            return (Node)children.get(0);
  +        } else {
               return null;
           }
       }
   
  -    public Node getLastChild() {
  -        ArrayList children = getChildren();
  -        if(children != null)
  +    public Node getLastChild()
  +    {
  +        if (children != null && !children.isEmpty()) {
               return (Node)children.get(children.size()-1);
  -        else
  +        } else {
               return null;
  +        }
       }
   
       public Node getNextSibling() {
  @@ -444,8 +453,11 @@
           attributes = attrs;
       }
   
  -    public void detachAllChildren(){
  -        children =  new ArrayList();
  +    public void detachAllChildren()
  +    {
  +        if (children != null) {
  +            children.clear();
  +        }
       }
       
       public NodeList getChildNodes() {
  @@ -457,36 +469,42 @@
       }
   
       public Node appendChild(Node newChild) throws DOMException {
  -        if(children == null) children = new ArrayList();
  +        initializeChildren();
           children.add(newChild);
           return newChild;
       }
   
       public Node removeChild(Node oldChild) throws DOMException {
  -        if(children == null) children = new ArrayList();
  +        initializeChildren();
           int position = children.indexOf(oldChild);
  -        if(position < 0)
  -            throw new  DOMException(DOMException.NOT_FOUND_ERR,"MessageElement Not found");;
  -            children.remove(position);
  -            return oldChild;
  +        if(position < 0) {
  +            throw new DOMException(DOMException.NOT_FOUND_ERR,
  +                                   "MessageElement Not found");
  +        }
  +        children.remove(position);
  +        return oldChild;
       }
  -
  +    
       public Node insertBefore(Node newChild, Node refChild) throws DOMException {
  -        if(children == null) children = new ArrayList();
  +        initializeChildren();
           int position = children.indexOf(refChild);
  -        if(position < 0)  position = 0;
  +        if (position < 0) {
  +            position = 0;
  +        }
           children.add(position,newChild);
           return newChild;
       }
  -
  +    
       public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
  -        if(children == null) children = new ArrayList();
  +        initializeChildren();
           int position = children.indexOf(oldChild);
  -        if(position < 0)
  -            throw new  DOMException(DOMException.NOT_FOUND_ERR,"MessageElement Not found");;
  -            children.remove(position);
  -            children.add(position, newChild);
  -            return oldChild;
  +        if(position < 0) {
  +            throw new DOMException(DOMException.NOT_FOUND_ERR,
  +                                   "MessageElement Not found");;
  +        }
  +        children.remove(position);
  +        children.add(position, newChild);
  +        return oldChild;
       }
   
       /**
  @@ -611,7 +629,7 @@
       }
   
       public boolean hasChildNodes() {
  -        return children.size() > 0;
  +        return (children != null && !children.isEmpty());
       }
   
       public String getLocalName() {
  @@ -666,7 +684,7 @@
   
       public void removeContents() {
           // unlink
  -        if(children != null){
  +        if(children != null) {
               for(int i = 0; i < children.size(); i++){
                   try{
                       ((MessageElement)children.get(i)).setParent(null);
  @@ -675,6 +693,7 @@
               }
               // empty the collection
               children.clear();
  +            setDirty(true);
           }
       }
   
  @@ -711,7 +730,7 @@
        *     there was a problem in the encoding style being set.
        * @see #getEncodingStyle() getEncodingStyle()
        */
  -    public void setEncodingStyle(String encodingStyle) throws SOAPException {
  +    public void setEncodingStyle(String encodingStyle) throws SOAPException { 
           if (encodingStyle == null) {
               encodingStyle = "";
           }
  @@ -728,15 +747,29 @@
       }
   
       private MessageElement getParent() { return parent; }
  +
       private void setParent(MessageElement parent) throws SOAPException
       {
  -        this.parent = parent;
  +        if (this.parent == parent) {
  +            return;
  +        }
  +        if (this.parent != null) {
  +            this.parent.removeChild(this);
  +        }
           if (parent != null) {
               parent.addChild(this);
           }
  +        this.parent = parent;
       }
   
  -    private ArrayList children = null;
  +    protected List children = null;
  +
  +    protected void initializeChildren() 
  +    {
  +        if (children == null) {
  +            children = new ArrayList();
  +        }
  +    }
   
       /**
        * Note that this method will log a error and no-op if there is
  @@ -745,12 +778,12 @@
       public void addChild(MessageElement el) throws SOAPException
       {
           if (objectValue != null) {
  -            SOAPException exc = new SOAPException(Messages.getMessage("valuePresent"));
  +            SOAPException exc = 
  +                new SOAPException(Messages.getMessage("valuePresent"));
               log.error(Messages.getMessage("valuePresent"), exc);
               throw exc;
           }
  -        if (children == null)
  -            children = new ArrayList();
  +        initializeChildren();
           children.add(el);
           el.parent = this;
       }
  @@ -758,24 +791,31 @@
       /**
        * Remove a child element.
        */
  -    public void removeChild(MessageElement child) {
  +    public void removeChild(MessageElement child) 
  +    {
  +        if (children == null) {
  +            return;
  +        }
           // Remove all occurrences in case it has been added multiple times.
  +        boolean removed = false;
           int i;
           while ((i = children.indexOf(child)) != -1) {
               children.remove(i);
  +            removed = true;
           }
  +        setDirty(removed);
       }
   
  -    public ArrayList getChildren()
  +    public List getChildren()
       {
           return children;
       }
   
  -    public void setContentsIndex(int index)
  +    public void setContentsIndex(int index) 
       {
           startContentsIndex = index;
       }
  -
  + 
       public void setNSMappings(ArrayList namespaces)
       {
           this.namespaces = namespaces;
  @@ -881,11 +921,12 @@
           this.objectValue = newValue;
       }
   
  -    public Object getValueAsType(QName type) throws Exception
  +    public Object getValueAsType(QName type) throws Exception 
       {
           return getValueAsType(type, null);
       }
  -    public Object getValueAsType(QName type, Class cls) throws Exception
  +
  +    public Object getValueAsType(QName type, Class cls) throws Exception 
       {
           if (context == null)
               throw new Exception(Messages.getMessage("noContext00"));
  @@ -958,6 +999,7 @@
           attributes.addAttribute(namespace, localName, attrName, "CDATA",
                                   value);
       }
  +
       /**
        * Set an attribute, adding the attribute if it isn't already present
        * in this element, and changing the value if it is.  Passing null as the
  @@ -995,7 +1037,8 @@
           env.setDirty(true);
           message = env;
       }
  -    public SOAPEnvelope getEnvelope()
  +
  +    public SOAPEnvelope getEnvelope() 
       {
           return message;
       }
  @@ -1015,7 +1058,7 @@
           return (MessageElement)obj;
       }
   
  -    public Document getAsDocument() throws Exception
  +    public Document getAsDocument() throws Exception 
       {
           String elementString = getAsString();
   
  @@ -1044,7 +1087,7 @@
           return writer.getBuffer().toString();
       }
   
  -    public Element getAsDOM() throws Exception
  +    public Element getAsDOM() throws Exception 
       {
           return getAsDocument().getDocumentElement();
       }
  @@ -1057,7 +1100,7 @@
           recorder.replay(startEventIndex, endEventIndex, handler);
       }
   
  -    public void publishContents(ContentHandler handler) throws SAXException
  +    public void publishContents(ContentHandler handler) throws SAXException 
       {
           if (recorder == null)
               throw new SAXException(Messages.getMessage("noRecorder00"));
  @@ -1120,7 +1163,7 @@
   
       /** Subclasses can override
        */
  -    protected void outputImpl(SerializationContext context) throws Exception
  +    protected void outputImpl(SerializationContext context) throws Exception 
       {
           if (elementRep != null) {
               boolean oldPretty = context.getPretty();
  @@ -1279,11 +1322,11 @@
       public SOAPElement addChildElement(String localName,
                                          String prefix,
                                          String uri) throws SOAPException {
  -            MessageElement child = new MessageElement(uri, localName);
  -            child.setPrefix(prefix);
  -            child.addNamespaceDeclaration(prefix, uri);
  -            addChild(child);
  -            return child;
  +        MessageElement child = new MessageElement(uri, localName);
  +        child.setPrefix(prefix);
  +        child.addNamespaceDeclaration(prefix, uri);
  +        addChild(child);
  +        return child;
       }
   
       /**
  @@ -1295,6 +1338,7 @@
           throws SOAPException {
           try {
               addChild((MessageElement)element);
  +            setDirty(true);
               return element;
           } catch (ClassCastException e) {
               throw new SOAPException(e);
  @@ -1404,8 +1448,7 @@
       }
   
       public Iterator getChildElements() {
  -        if (children == null)
  -            children = new ArrayList();
  +        initializeChildren();
           return children.iterator();
       }
   
  @@ -1416,20 +1459,19 @@
        * @return
        */
       public MessageElement getChildElement(QName qname) {
  -        if (children == null) return null;
  -        for (Iterator i = children.iterator(); i.hasNext();) {
  -            MessageElement child = (MessageElement) i.next();
  -            if (child.getQName().equals(qname))
  -                return child;
  +        if (children != null) {
  +            for (Iterator i = children.iterator(); i.hasNext();) {
  +                MessageElement child = (MessageElement) i.next();
  +                if (child.getQName().equals(qname))
  +                    return child;
  +            }
           }
           return null;
       }
   
       public Iterator getChildElements(QName qname) {
  -        if (children == null)
  -            children = new ArrayList();
  +        initializeChildren();
           int num = children.size();
  -
           Vector c = new Vector(num);
           for (int i = 0; i < num; i++) {
               MessageElement child = (MessageElement)children.get(i);
  @@ -1582,7 +1624,10 @@
           return null;
       }
   
  -    public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
  +    public void setAttributeNS(String namespaceURI, String qualifiedName, 
  +                               String value) 
  +        throws DOMException 
  +    {
           AttributesImpl attributes = makeAttributesEditable();
           String localName =  qualifiedName.substring(qualifiedName.indexOf(":")+1, qualifiedName.length());
   
  @@ -1600,7 +1645,9 @@
           return null;  //TODO: Fix this for SAAJ 1.2 Implementation
       }
   
  -    public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
  +    public NodeList getElementsByTagNameNS(String namespaceURI, 
  +                                           String localName) 
  +    {
           return getElementsNS(this,namespaceURI,localName);
       }
   
  @@ -1648,12 +1695,9 @@
        *
        * @since SAAJ 1.2 : Nodelist Interface
        */
  -    public int getLength(){
  -        if(children  == null){
  -            children = new ArrayList();
  -            return 0;
  -        }
  -        return children.size();
  +    public int getLength() 
  +    {
  +        return (children == null) ? 0 : children.size();
       }
   
       // setEncodingStyle implemented above
  @@ -1661,7 +1705,7 @@
       // getEncodingStyle() implemented above
       
       MessageElement findElement(Vector vec, String namespace,
  -                                         String localPart)
  +                               String localPart) 
       {
           if (vec.isEmpty())
               return null;
  @@ -1678,7 +1722,7 @@
           return null;
       }
       
  -    public boolean equals(Object obj)
  +    public boolean equals(Object obj) 
       {
           if (obj == null || !(obj instanceof MessageElement))
               return false;
  
  
  
  1.51      +105 -87   ws-axis/java/src/org/apache/axis/message/SOAPBody.java
  
  Index: SOAPBody.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPBody.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- SOAPBody.java	6 Apr 2004 15:02:50 -0000	1.50
  +++ SOAPBody.java	22 Jun 2004 17:42:50 -0000	1.51
  @@ -36,6 +36,8 @@
   import java.util.Vector;
   import java.util.ArrayList;
   import java.util.Locale;
  +import java.util.List;
  +import java.util.Iterator;
   
   /**
    * Holder for body elements.
  @@ -47,13 +49,12 @@
   
       private static Log log = LogFactory.getLog(SOAPBody.class.getName());
   
  -    private Vector bodyElements = new Vector();
  -
       private SOAPConstants soapConstants;
   
       private boolean disableFormatting = false;
       private boolean doSAAJEncodingCompliance = false;
       private static ArrayList knownEncodingStyles = new ArrayList();
  +
       static {
           knownEncodingStyles.add(Constants.URI_SOAP11_ENC);
           knownEncodingStyles.add(Constants.URI_SOAP12_ENC);
  @@ -80,11 +81,13 @@
       }
   
       public void setParentElement(SOAPElement parent) throws SOAPException {
  -        if(parent == null)
  +        if(parent == null) {
               throw new IllegalArgumentException(Messages.getMessage("nullParent00")); 
  +        }
           try {
  -            // cast to force exception if wrong type
  -            super.setParentElement((SOAPEnvelope)parent);
  +            SOAPEnvelope env = (SOAPEnvelope)parent;
  +            super.setParentElement(env);
  +            setEnvelope(env);
           } catch (Throwable t) {
               throw new SOAPException(t);
           }
  @@ -123,7 +126,9 @@
                context.setPretty(false);
           }
   
  -        if (bodyElements.isEmpty()) {
  +        List bodyElements = getChildren();
  +
  +        if (bodyElements == null || bodyElements.isEmpty()) {
               // This is a problem.
               // throw new Exception("No body elements!");
               // If there are no body elements just return - it's ok that
  @@ -132,12 +137,16 @@
   
           // Output <SOAP-ENV:Body>
           context.startElement(new QName(soapConstants.getEnvelopeURI(),
  -                                       Constants.ELEM_BODY), getAttributesEx());
  -        Enumeration enumeration = bodyElements.elements();
  -        while (enumeration.hasMoreElements()) {
  -            SOAPBodyElement body = (SOAPBodyElement)enumeration.nextElement();
  -            body.output(context);
  -            // Output this body element.
  +                                       Constants.ELEM_BODY),
  +                             getAttributesEx());
  +        
  +        if (bodyElements != null) {
  +            Iterator e = bodyElements.iterator();
  +            while (e.hasNext()) {
  +                SOAPBodyElement body = (SOAPBodyElement)e.next();
  +                body.output(context);
  +                // Output this body element.
  +            }
           }
           
           // Output multi-refs if appropriate
  @@ -149,50 +158,57 @@
           context.setPretty(oldPretty);
       }
   
  -    Vector getBodyElements() throws AxisFault
  +    protected void initializeChildren()
       {
  -        return bodyElements;
  +        if (children == null) {
  +            children = new Vector();
  +        }
  +    }
  +    
  +    Vector getBodyElements() throws AxisFault {
  +        initializeChildren();
  +        return (Vector)getChildren();
       }
   
       SOAPBodyElement getFirstBody() throws AxisFault
       {
  -        if (bodyElements.isEmpty())
  -            return null;
  -        
  -        return (SOAPBodyElement)bodyElements.elementAt(0);
  +        List bodyElements = getChildren();
  +        return (bodyElements == null) ? 
  +            null : (SOAPBodyElement)bodyElements.get(0);
       }
   
  -    void addBodyElement(SOAPBodyElement element)
  +    void addBodyElement(SOAPBodyElement element) 
       {
           if (log.isDebugEnabled())
               log.debug(Messages.getMessage("addBody00"));
           try {
  -            element.setParentElement(this);
  +            addChildElement(element);
           } catch (SOAPException ex) {
               // class cast should never fail when parent is a SOAPBody
               log.fatal(Messages.getMessage("exception00"), ex);
           }
       }
   
  -    void removeBodyElement(SOAPBodyElement element)
  +    void removeBodyElement(SOAPBodyElement element) 
       {
           if (log.isDebugEnabled())
               log.debug(Messages.getMessage("removeBody00"));
  -        bodyElements.removeElement(element);
  +        removeChild( (MessageElement)element );
       }
   
  -    void clearBody()
  +    void clearBody() 
       {
  -        if (!bodyElements.isEmpty())
  -            bodyElements.removeAllElements();
  +        List bodyElements = getChildren();
  +        if (bodyElements != null) {
  +            bodyElements.clear();
  +        }
       }
   
       SOAPBodyElement getBodyByName(String namespace, String localPart)
           throws AxisFault
       {
  -        return (SOAPBodyElement)findElement(bodyElements,
  -                                            namespace,
  -                                            localPart);
  +        QName name = new QName(namespace, localPart);
  +        return (SOAPBodyElement)getChildElement(name);
       }
   
       // JAXM methods
  @@ -200,21 +216,21 @@
       public javax.xml.soap.SOAPBodyElement addBodyElement(Name name)
           throws SOAPException {
           SOAPBodyElement bodyElement = new SOAPBodyElement(name);
  -        addBodyElement(bodyElement);
  +        addChildElement(bodyElement);
           return bodyElement;
       }
   
       public javax.xml.soap.SOAPFault addFault(Name name, String s, Locale locale) throws SOAPException {
           AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
           SOAPFault fault = new SOAPFault(af);
  -        addBodyElement(fault);
  +        addChildElement(fault);
           return fault;
       }
   
       public javax.xml.soap.SOAPFault addFault(Name name, String s) throws SOAPException {
           AxisFault af = new AxisFault(new QName(name.getURI(), name.getLocalName()), s, "", new Element[0]);
           SOAPFault fault = new SOAPFault(af);
  -        addBodyElement(fault);
  +        addChildElement(fault);
           return fault;
       }
   
  @@ -226,79 +242,81 @@
           
           AxisFault af = new AxisFault(new QName(Constants.NS_URI_AXIS, Constants.FAULT_SERVER_GENERAL), "", "", new Element[0]);
           SOAPFault fault = new SOAPFault(af);
  -        addBodyElement(fault);
  +        addChildElement(fault);
           return fault;
       }
   
       public javax.xml.soap.SOAPFault getFault() {
  -        Enumeration e = bodyElements.elements();
  -        while (e.hasMoreElements()) {
  -            Object element = e.nextElement();
  -            if(element instanceof javax.xml.soap.SOAPFault) {
  -                return (javax.xml.soap.SOAPFault) element;
  +        List bodyElements = getChildren();
  +        if (bodyElements != null) {
  +            Iterator e = bodyElements.iterator();
  +            while (e.hasNext()) {
  +                Object element = e.next();
  +                if(element instanceof javax.xml.soap.SOAPFault) {
  +                    return (javax.xml.soap.SOAPFault) element;
  +                }
               }
           }
           return null;
       }
  -
  +    
       public boolean hasFault() {
  -        Enumeration e = bodyElements.elements();
  -        while (e.hasMoreElements()) {
  -            if(e.nextElement() instanceof javax.xml.soap.SOAPFault) {
  -                return true;
  -            }
  -        }
  -        return false;
  +        return (getFault() != null);
       }
   
  -    public void addChild(MessageElement el) throws SOAPException {
  -        bodyElements.addElement(el);
  -    }
  -
  -    public java.util.Iterator getChildElements() {
  -        return bodyElements.iterator();
  -    }
  -
  -    public java.util.Iterator getChildElements(Name name) {
  -        Vector v = new Vector();
  -        Enumeration e = bodyElements.elements();
  -        SOAPElement bodyEl;
  -        while (e.hasMoreElements()) {
  -            bodyEl = (SOAPElement)e.nextElement();
  -            Name cname = bodyEl.getElementName(); 
  -            if (cname.getURI().equals(name.getURI()) &&
  -                cname.getLocalName().equals(name.getLocalName())) {
  -                v.addElement(bodyEl);
  -            }
  -        }
  -        return v.iterator();
  -    }
  -
  -    public void removeChild(MessageElement child) {
  -        // Remove all occurrences in case it has been added multiple times.
  -        int i;
  -        while ((i = bodyElements.indexOf(child)) != -1) {
  -            bodyElements.remove(i);
  -        }
  +    // overwrite the one in MessageElement and set envelope
  +    public void addChild(MessageElement element) throws SOAPException {
  +// Commented out for SAAJ compatibility - gdaniels, 05/19/2003
  +//      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
  +//        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
  +//      }
  +        element.setEnvelope(getEnvelope());
  +        super.addChild(element);
       }
   
  -    
  -    /**
  -     * we have to override this to enforce that SOAPHeader immediate 
  -     * children are exclusively of type SOAPHeaderElement (otherwise
  -     * we'll get mysterious ClassCastExceptions down the road...) 
  -     * 
  -     * @param element
  -     * @return
  -     * @throws SOAPException
  -     */ 
  -    public SOAPElement addChildElement(SOAPElement element) 
  -      throws SOAPException {
  +    // overwrite the one in MessageElement and sets dirty flag
  +    public SOAPElement addChildElement(SOAPElement element)
  +        throws SOAPException {
   // Commented out for SAAJ compatibility - gdaniels, 05/19/2003
   //      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
   //        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
   //      }
  -      return super.addChildElement(element);
  +        SOAPElement child = super.addChildElement(element);
  +        setDirty(true);
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(Name name) throws SOAPException {
  +        SOAPBodyElement child = new SOAPBodyElement(name);
  +        addChildElement(child);
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName) throws SOAPException {
  +        // Inherit parent's namespace
  +        SOAPBodyElement child = new SOAPBodyElement(getNamespaceURI(),
  +                                                    localName);
  +        addChildElement(child);
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName,
  +                                       String prefix) throws SOAPException {
  +        SOAPBodyElement child = 
  +            new SOAPBodyElement(getNamespaceURI(prefix), localName);
  +        child.setPrefix(prefix);
  +        addChildElement(child);
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName,
  +                                       String prefix,
  +                                       String uri) throws SOAPException {
  +        SOAPBodyElement child = new SOAPBodyElement(uri, localName);
  +        child.setPrefix(prefix);
  +        child.addNamespaceDeclaration(prefix, uri);
  +        addChildElement(child);
  +        return child;
       }
   
       public void setSAAJEncodingCompliance(boolean comply) {
  
  
  
  1.34      +18 -18    ws-axis/java/src/org/apache/axis/message/SOAPBodyElement.java
  
  Index: SOAPBodyElement.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPBodyElement.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SOAPBodyElement.java	3 May 2004 20:04:09 -0000	1.33
  +++ SOAPBodyElement.java	22 Jun 2004 17:42:50 -0000	1.34
  @@ -35,8 +35,8 @@
    * A Body element.
    */
   public class SOAPBodyElement extends MessageElement
  -    implements javax.xml.soap.SOAPBodyElement
  -{
  +    implements javax.xml.soap.SOAPBodyElement {
  +
       private static Log log =
           LogFactory.getLog(SOAPBodyElement.class.getName());
   
  @@ -45,12 +45,12 @@
                              String prefix,
                              Attributes attributes,
                              DeserializationContext context)
  -        throws AxisFault
  +        throws AxisFault 
       {
           super(namespace, localPart, prefix, attributes, context);
       }
   
  -    public SOAPBodyElement(Name name)
  +    public SOAPBodyElement(Name name) 
       {
           super(name);
       }
  @@ -70,7 +70,7 @@
           super(elem);
       }
       
  -    public SOAPBodyElement()
  +    public SOAPBodyElement() 
       {
       }
   
  @@ -79,7 +79,13 @@
           super( getDocumentElement(input) );
       }
   
  -    private static Element getDocumentElement(InputStream input) {
  +    public SOAPBodyElement(String namespace, String localPart)
  +    {
  +        super(namespace, localPart);
  +    }
  +
  +    private static Element getDocumentElement(InputStream input)
  +    {
           try {
               return XMLUtils.newDocument(input).getDocumentElement();
           } catch (Exception e) {
  @@ -88,25 +94,19 @@
       }
   
       public void setParentElement(SOAPElement parent) throws SOAPException {
  -        if(parent == null)
  +        if(parent == null) {
               throw new IllegalArgumentException(Messages.getMessage("nullParent00")); 
  +        }
           // migration aid
           if (parent instanceof SOAPEnvelope) {
               log.warn(Messages.getMessage("bodyElementParent"));
               parent = ((SOAPEnvelope)parent).getBody();
           }
  -        try {
  -            // cast to force exception if wrong type
  -            super.setParentElement(parent);
  -        } catch (Throwable t) {
  -            throw new SOAPException(t);
  +        if (!(parent instanceof SOAPBody)) {
  +            throw new IllegalArgumentException(Messages.getMessage("illegalArgumentException00"));
           }
  +        
  +        super.setParentElement(parent);
       }
   
  -    public void detachNode() {
  -        if (parent != null) {
  -            ((SOAPBody)parent).removeBodyElement(this);
  -        }
  -        super.detachNode();
  -    }
   }
  
  
  
  1.27      +2 -2      ws-axis/java/src/org/apache/axis/message/SOAPFault.java
  
  Index: SOAPFault.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPFault.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- SOAPFault.java	25 Feb 2004 14:02:43 -0000	1.26
  +++ SOAPFault.java	22 Jun 2004 17:42:50 -0000	1.27
  @@ -34,8 +34,8 @@
   import javax.xml.soap.DetailEntry;
   import javax.xml.soap.Name;
   import java.io.IOException;
  -import java.util.ArrayList;
   import java.util.Locale;
  +import java.util.List;
   
   /** A Fault body element.
    *
  @@ -291,7 +291,7 @@
        *     application-specific error information
        */
       public javax.xml.soap.Detail getDetail() {
  -        ArrayList children = this.getChildren();
  +        List children = this.getChildren();
           if(children==null || children.size()<=0)
               return null;
   
  
  
  
  1.37      +3 -2      ws-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java
  
  Index: SOAPFaultBuilder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- SOAPFaultBuilder.java	25 Feb 2004 14:02:43 -0000	1.36
  +++ SOAPFaultBuilder.java	22 Jun 2004 17:42:50 -0000	1.37
  @@ -29,9 +29,10 @@
   
   import javax.xml.namespace.QName;
   import java.lang.reflect.Constructor;
  -import java.util.ArrayList;
  +import java.util.List;
   import java.util.HashMap;
   import java.util.Vector;
  +import java.util.List;
   import java.rmi.RemoteException;
   
   /** 
  @@ -293,7 +294,7 @@
               throws SAXException {
           if (Constants.ELEM_FAULT_DETAIL.equals(localName)) {
               MessageElement el = context.getCurElement();
  -            ArrayList children = el.getChildren();
  +            List children = el.getChildren();
               if (children != null) {
                   Element [] elements = new Element [children.size()];
                   for (int i = 0; i < elements.length; i++) {
  
  
  
  1.82      +74 -91    ws-axis/java/src/org/apache/axis/message/SOAPHeader.java
  
  Index: SOAPHeader.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- SOAPHeader.java	6 Apr 2004 15:02:50 -0000	1.81
  +++ SOAPHeader.java	22 Jun 2004 17:42:50 -0000	1.82
  @@ -32,6 +32,8 @@
   import javax.xml.soap.Name;
   import javax.xml.soap.SOAPElement;
   import javax.xml.soap.SOAPException;
  +
  +import java.util.List;
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.Iterator;
  @@ -48,8 +50,6 @@
   
       private static Log log = LogFactory.getLog(SOAPHeader.class.getName());
   
  -    private Vector headers = new Vector();
  -
       private SOAPConstants soapConstants;
   
       SOAPHeader(SOAPEnvelope env, SOAPConstants soapConsts) {
  @@ -59,7 +59,6 @@
           soapConstants = (soapConsts != null) ? soapConsts : Constants.DEFAULT_SOAP_VERSION;
           try {
               setParentElement(env);
  -            setEnvelope(env);
           } catch (SOAPException ex) {
               // class cast should never fail when parent is a SOAPEnvelope
               log.fatal(Messages.getMessage("exception00"), ex);
  @@ -74,11 +73,12 @@
       }
   
       public void setParentElement(SOAPElement parent) throws SOAPException {
  -        if(parent == null)
  +        if(parent == null) {
               throw new IllegalArgumentException(Messages.getMessage("nullParent00")); 
  +        }
           try {
  -            SOAPEnvelope env = (SOAPEnvelope)parent;
               // cast to force exception if wrong type
  +            SOAPEnvelope env = (SOAPEnvelope)parent;
               super.setParentElement(env);
               setEnvelope(env);
           } catch (Throwable t) {
  @@ -96,10 +96,7 @@
       public javax.xml.soap.SOAPHeaderElement addHeaderElement(Name name)
           throws SOAPException {
           SOAPHeaderElement headerElement = new SOAPHeaderElement(name);
  -        SOAPEnvelope envelope = getEnvelope();
  -        headerElement.setEnvelope(envelope);
  -        addHeader(headerElement);
  -        envelope.setDirty(true);
  +        addChildElement(headerElement);
           return headerElement;
       }
       
  @@ -129,13 +126,15 @@
           if (actor == null) return null;
   
           Vector result = new Vector();
  -
  -        for(int i = 0; i < headers.size(); i++) {
  -            SOAPHeaderElement she = (SOAPHeaderElement)headers.get(i);
  -            if (she.getMustUnderstand()) {
  -                String candidate = she.getActor();
  -                if (actor.equals(candidate)) {
  -                    result.add(headers.get(i));
  +        List headers = getChildren();
  +        if (headers != null) {
  +            for(int i = 0; i < headers.size(); i++) {
  +                SOAPHeaderElement she = (SOAPHeaderElement)headers.get(i);
  +                if (she.getMustUnderstand()) {
  +                    String candidate = she.getActor();
  +                    if (actor.equals(candidate)) {
  +                        result.add(headers.get(i));
  +                    }
                   }
               }
           }
  @@ -143,20 +142,30 @@
       }
   
       public Iterator examineAllHeaderElements() {
  -        return headers.iterator();
  +        return getChildElements();
       }
   
       public Iterator extractAllHeaderElements() {
           Vector result = new Vector();
  -        for(int i = 0; i < headers.size(); i++) {
  -            result.add(headers.get(i));
  +        List headers = getChildren();
  +        if (headers != null) {
  +            for(int i = 0; i < headers.size(); i++) {
  +                result.add(headers.get(i));
  +            }
  +            headers.clear();
           }
  -        headers.clear();
           return result.iterator();
       }
   
  +    protected void initializeChildren() {
  +        if (children == null) {
  +            children = new Vector();
  +        }
  +    }
  +
       Vector getHeaders() {
  -        return headers;
  +        initializeChildren();
  +        return (Vector)getChildren();
       }
   
       /**
  @@ -164,6 +173,10 @@
        */ 
       Vector getHeadersByActor(ArrayList actors) {
           Vector results = new Vector();
  +        List headers = getChildren();
  +        if (headers == null) {
  +            return results;
  +        }
           Iterator i = headers.iterator();
           SOAPConstants soapVer = getEnvelope().getSOAPConstants();
           boolean isSOAP12 = soapVer == SOAPConstants.SOAP12_CONSTANTS;
  @@ -194,7 +207,7 @@
           if (log.isDebugEnabled())
               log.debug(Messages.getMessage("addHeader00"));
           try {
  -            header.setParentElement(this);
  +            addChildElement(header);
           } catch (SOAPException ex) {
               // class cast should never fail when parent is a SOAPHeader
               log.fatal(Messages.getMessage("exception00"), ex);
  @@ -204,7 +217,7 @@
       void removeHeader(SOAPHeaderElement header) {
           if (log.isDebugEnabled())
               log.debug(Messages.getMessage("removeHeader00"));
  -        headers.removeElement(header);
  +        removeChild((MessageElement)header);
       }
   
       /**
  @@ -214,9 +227,8 @@
       SOAPHeaderElement getHeaderByName(String namespace,
                                         String localPart,
                                         boolean accessAllHeaders) {
  -        SOAPHeaderElement header = (SOAPHeaderElement)findElement(headers,
  -                                                                  namespace,
  -                                                                  localPart);
  +        QName name = new QName(namespace, localPart);
  +        SOAPHeaderElement header = (SOAPHeaderElement)getChildElement(name);
   
           // If we're operating within an AxisEngine, respect its actor list
           // unless told otherwise
  @@ -268,12 +280,16 @@
            * returning only the next one each time.... this is Q&D for now.
            */
           Vector v = new Vector();
  -        Enumeration e = headers.elements();
  +        List headers = getChildren();
  +        if (headers == null) {
  +            return v.elements();
  +        }
  +        Iterator e = headers.iterator();
           SOAPHeaderElement header;
           String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI();
           
  -        while (e.hasMoreElements()) {
  -            header = (SOAPHeaderElement)e.nextElement();
  +        while (e.hasNext()) {
  +            header = (SOAPHeaderElement)e.next();
               if (header.getNamespaceURI().equals(namespace) &&
                   header.getName().equals(localPart)) {
   
  @@ -302,6 +318,10 @@
       }
   
       protected void outputImpl(SerializationContext context) throws Exception {
  +        List headers = getChildren();
  +        if (headers == null) {
  +            return;
  +        }
           boolean oldPretty = context.getPretty();
           context.setPretty(true);
   
  @@ -313,10 +333,10 @@
               // Output <SOAP-ENV:Header>
               context.startElement(new QName(soapConstants.getEnvelopeURI(),
                                              Constants.ELEM_HEADER), null);
  -            Enumeration enumeration = headers.elements();
  -            while (enumeration.hasMoreElements()) {
  +            Iterator enumeration = headers.iterator();
  +            while (enumeration.hasNext()) {
                   // Output this header element
  -                ((SOAPHeaderElement)enumeration.nextElement()).output(context);
  +                ((SOAPHeaderElement)enumeration.next()).output(context);
               }
               // Output </SOAP-ENV:Header>
               context.endElement();
  @@ -325,93 +345,56 @@
           context.setPretty(oldPretty);
       }
   
  +    // overwrite the one in MessageElement and set envelope
       public void addChild(MessageElement element) throws SOAPException {
           if (!(element instanceof SOAPHeaderElement)) {
  -          throw new SOAPException(Messages.getMessage("badSOAPHeader00"));
  +            throw new SOAPException(Messages.getMessage("badSOAPHeader00"));
           }
  -        ((SOAPHeaderElement)element).setEnvelope(getEnvelope());
  -        headers.addElement(element);
  -    }
  -
  -    public java.util.Iterator getChildElements() {
  -        return headers.iterator();
  +        element.setEnvelope(getEnvelope());
  +        super.addChild(element);
       }
   
  -    public java.util.Iterator getChildElements(Name name) {
  -        Vector v = new Vector();
  -        Enumeration e = headers.elements();
  -        SOAPHeaderElement header;
  -        while (e.hasMoreElements()) {
  -            header = (SOAPHeaderElement)e.nextElement();
  -            if (header.getNamespaceURI().equals(name.getURI()) &&
  -                header.getName().equals(name.getLocalName())) {
  -                v.addElement(header);
  -            }
  -        }
  -        return v.iterator();
  -    }
  -    public void removeChild(MessageElement child) {
  -        // Remove all occurrences in case it has been added multiple times.
  -        int i;
  -        while ((i = headers.indexOf(child)) != -1) {
  -            headers.remove(i);
  +    // overwrite the one in MessageElement and sets dirty flag
  +    public SOAPElement addChildElement(SOAPElement element)
  +        throws SOAPException {
  +        if (!(element instanceof SOAPHeaderElement)) {
  +            throw new SOAPException(Messages.getMessage("badSOAPHeader00"));
           }
  -    }
  -
  -    /**
  -     * we have to override this to enforce that SOAPHeader immediate 
  -     * children are exclusively of type SOAPHeaderElement (otherwise
  -     * we'll get mysterious ClassCastExceptions down the road... )
  -     * 
  -     * @param element child element
  -     * @return soap element
  -     * @throws SOAPException
  -     */ 
  -    public SOAPElement addChildElement(SOAPElement element) 
  -      throws SOAPException
  -    {
  -      if (!(element instanceof SOAPHeaderElement)) {
  -        throw new SOAPException(Messages.getMessage("badSOAPHeader00"));
  -      }
  -      ((SOAPHeaderElement)element).setEnvelope(getEnvelope());
  -      return super.addChildElement(element);
  +        SOAPElement child = super.addChildElement(element);
  +        setDirty(true);
  +        return child;
       }
   
       public SOAPElement addChildElement(Name name) throws SOAPException {
  -        SOAPHeaderElement child = new SOAPHeaderElement(name.getURI(),
  -                                                  name.getLocalName());
  -        addChild(child);
  -        child.setEnvelope(getEnvelope());
  +        SOAPHeaderElement child = new SOAPHeaderElement(name);
  +        addChildElement(child);
           return child;
       }
   
       public SOAPElement addChildElement(String localName) throws SOAPException {
           // Inherit parent's namespace
           SOAPHeaderElement child = new SOAPHeaderElement(getNamespaceURI(),
  -                                                  localName);
  -        addChild(child);
  -        child.setEnvelope(getEnvelope());
  +                                                        localName);
  +        addChildElement(child);
           return child;
       }
   
       public SOAPElement addChildElement(String localName,
                                          String prefix) throws SOAPException {
  -        SOAPHeaderElement child = new SOAPHeaderElement(getNamespaceURI(prefix),
  -                                                  localName);
  -        addChild(child);
  -        child.setEnvelope(getEnvelope());
  +        SOAPHeaderElement child = 
  +            new SOAPHeaderElement(getNamespaceURI(prefix), localName);
  +        child.setPrefix(prefix);
  +        addChildElement(child);
           return child;
       }
   
       public SOAPElement addChildElement(String localName,
                                          String prefix,
                                          String uri) throws SOAPException {
  -        SOAPHeaderElement child = new SOAPHeaderElement(uri,
  -                                                  localName);
  +        SOAPHeaderElement child = new SOAPHeaderElement(uri, localName);
           child.setPrefix(prefix);
           child.addNamespaceDeclaration(prefix, uri);
  -        addChild(child);
  -        child.setEnvelope(getEnvelope());
  +        addChildElement(child);
           return child;
       }
   }
  
  
  
  1.34      +23 -22    ws-axis/java/src/org/apache/axis/message/SOAPHeaderElement.java
  
  Index: SOAPHeaderElement.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPHeaderElement.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SOAPHeaderElement.java	18 Apr 2004 18:07:36 -0000	1.33
  +++ SOAPHeaderElement.java	22 Jun 2004 17:42:50 -0000	1.34
  @@ -37,29 +37,32 @@
    * @author Glyn Normington (glyn@apache.org)
    */
   public class SOAPHeaderElement extends MessageElement
  -    implements javax.xml.soap.SOAPHeaderElement {
  +    implements javax.xml.soap.SOAPHeaderElement 
  +{
  +
       protected boolean   processed = false;
   
       protected String    actor = "http://schemas.xmlsoap.org/soap/actor/next";
       protected boolean   mustUnderstand = false;
       protected boolean   relay = false;
   
  -    public SOAPHeaderElement(String namespace, String localPart)
  +    public SOAPHeaderElement(String namespace, String localPart) 
       {
           super(namespace, localPart);
       }
   
  -    public SOAPHeaderElement(Name name)
  +    public SOAPHeaderElement(Name name) 
       {
           super(name);
       }
   
  -    public SOAPHeaderElement(QName qname)
  +    public SOAPHeaderElement(QName qname) 
       {
           super(qname);
       }
   
  -    public SOAPHeaderElement(String namespace, String localPart, Object value)
  +    public SOAPHeaderElement(String namespace, String localPart, 
  +                             Object value) 
       {
           super(namespace, localPart, value);
       }
  @@ -69,7 +72,7 @@
           super(qname, value);
       }
   
  -    public SOAPHeaderElement(Element elem)
  +    public SOAPHeaderElement(Element elem) 
       {
           super(elem);
   
  @@ -105,16 +108,21 @@
           }
       }
   
  -    public void setParentElement(SOAPElement parent) throws SOAPException {
  -        if(parent == null)
  +    public void setParentElement(SOAPElement parent) throws SOAPException 
  +    {
  +        if(parent == null) {
               throw new IllegalArgumentException(Messages.getMessage("nullParent00"));
  -        if(!(parent instanceof SOAPHeader))
  +        }
  +        // migration aid
  +        if (parent instanceof SOAPEnvelope) {
  +            log.warn(Messages.getMessage("bodyHeaderParent"));
  +            parent = ((SOAPEnvelope)parent).getHeader();
  +        }
  +        if (!(parent instanceof SOAPHeader)) {
               throw new IllegalArgumentException(Messages.getMessage("illegalArgumentException00"));
  -        try {
  -            super.setParentElement(parent);
  -        } catch (Throwable t) {
  -            throw new SOAPException(t);
           }
  +
  +        super.setParentElement(parent);
       }
   
       public SOAPHeaderElement(String namespace,
  @@ -122,7 +130,7 @@
                                String prefix,
                                Attributes attributes,
                                DeserializationContext context)
  -            throws AxisFault
  +        throws AxisFault
       {
           super(namespace, localPart, prefix, attributes, context);
   
  @@ -154,15 +162,8 @@
           alreadySerialized = true;
       }
   
  -    public void detachNode() {
  -        if (parent != null) {
  -            ((SOAPHeader)parent).removeHeader(this);
  -        }
  -        super.detachNode();
  -    }
  -
       private void setMustUnderstandFromString(String val, boolean isSOAP12) 
  -            throws AxisFault {
  +        throws AxisFault {
           if (val != null && val.length() > 0) {
               if ("0".equals(val)) {
                   mustUnderstand = false;