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 ru...@apache.org on 2006/01/02 10:41:46 UTC

svn commit: r365323 - in /webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2: src/org/apache/axis2/saaj2/ src/org/apache/axis2/saaj2/util/ test-resources/

Author: ruchithf
Date: Mon Jan  2 01:40:44 2006
New Revision: 365323

URL: http://svn.apache.org/viewcvs?rev=365323&view=rev
Log:
patch from Azeez for SAAJ over DOOM

Added:
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/SAAJUtil.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/Echo.aar   (with props)
Modified:
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MessageFactoryImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeImplEx.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeListImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyElementImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultElementImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPMessageImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPPartImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/TextImplEx.java

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java Mon Jan  2 01:40:44 2006
@@ -15,9 +15,10 @@
  */
 package org.apache.axis2.saaj2;
 
-import org.apache.axis2.om.OMText;
 import org.apache.axis2.om.DOOMAbstractFactory;
-import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axis2.om.OMText;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.TextImpl;
 import org.apache.axis2.transport.http.HTTPConstants;
 
 import javax.activation.DataHandler;
@@ -104,7 +105,7 @@
      */
     public void clearContent() {
         dataHandler = null;
-		omText = null;
+        omText = null;
     }
 
     /**
@@ -357,10 +358,14 @@
      * @return the OMText
      * @throws SOAPException If omText is not available
      */
-    public OMText getOMText() throws SOAPException{
-		if(omText == null){
-			throw new SOAPException("OMText set to null");
-		}
-		return omText;
-	}
+    public OMText getOMText() throws SOAPException {
+        if (omText == null) {
+            throw new SOAPException("OMText set to null");
+        }
+        return omText;
+    }
+
+    public TextImpl getText(DocumentImpl doc) {
+        return new TextImpl(doc, omText.getText());
+    }
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailImpl.java Mon Jan  2 01:40:44 2006
@@ -15,23 +15,22 @@
  */
 package org.apache.axis2.saaj2;
 
-import java.util.Iterator;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.soap.SOAPFaultDetail;
 
 import javax.xml.soap.Detail;
 import javax.xml.soap.DetailEntry;
 import javax.xml.soap.Name;
-import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
-
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.impl.dom.ElementImpl;
-import org.apache.axis2.soap.SOAPFaultDetail;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * A container for <code>DetailEntry</code> objects. <code>DetailEntry</code>
  * objects give detailed error information that is application-specific and
  * related to the <code>SOAPBody</code> object that contains it.
- * <P>
+ * <p/>
  * A <code>Detail</code> object, which is part of a <code>SOAPFault</code>
  * object, can be retrieved using the method <code>SOAPFault.getDetail</code>.
  * The <code>Detail</code> interface provides two methods. One creates a new
@@ -39,7 +38,7 @@
  * the <code>Detail</code> object. The second method gets a list of the
  * <code>DetailEntry</code> objects contained in a <code>Detail</code>
  * object.
- * <P>
+ * <p/>
  * The following code fragment, in which <i>sf</i> is a <code>SOAPFault</code>
  * object, gets its <code>Detail</code> object (<i>d</i>), adds a new
  * <code>DetailEntry</code> object to <i>d</i>, and then gets a list of all the
@@ -57,17 +56,17 @@
  */
 public class DetailImpl extends SOAPFaultElementImpl implements Detail {
 
-	SOAPFaultDetail faultDetail;
-	
-	/**
-	 * @param element
-	 */
-	public DetailImpl(SOAPFaultDetail element) {
-		super((ElementImpl)element);
-		faultDetail = element;
-	}
+//    private SOAPFaultDetail faultDetail;
+
+    /**
+     * @param element
+     */
+    public DetailImpl(SOAPFaultDetail element) {
+        super((ElementImpl) element);
+//        faultDetail = element;
+    }
 
-	/**
+    /**
      * Creates a new <code>DetailEntry</code> object with the given
      * name and adds it to this <code>Detail</code> object.
      *
@@ -75,21 +74,26 @@
      * @return DetailEntry.
      * @throws SOAPException thrown when there is a problem in adding a DetailEntry object to this Detail object.
      */
-	public DetailEntry addDetailEntry(Name name) throws SOAPException {
-		SOAPElementImpl childElement = (SOAPElementImpl)addChildElement(name);
-		DetailEntryImpl detailEntryImpl = new DetailEntryImpl(childElement.element);
-		faultDetail.addDetailEntry((OMElement)detailEntryImpl);
-		return detailEntryImpl;
-	}
+    public DetailEntry addDetailEntry(Name name) throws SOAPException {
+        SOAPElementImpl childElement = (SOAPElementImpl) addChildElement(name);
+        DetailEntryImpl detailEntryImpl = new DetailEntryImpl(childElement.element);
+//        faultDetail.addDetailEntry(detailEntryImpl.element);  //This causes infinite recursion
+        return detailEntryImpl;
+    }
 
-	/**
+    /**
      * Gets a list of the detail entries in this <code>Detail</code> object.
      *
      * @return an <code>Iterator</code> object over the <code>DetailEntry</code>
      *         objects in this <code>Detail</code> object
      */
-	public Iterator getDetailEntries() {
-		return faultDetail.getAllDetailEntries();
-	}
+    public Iterator getDetailEntries() {
+        final Iterator detailEntriesIter = element.getChildElements();
+        Collection details = new ArrayList();
+        while (detailEntriesIter.hasNext()) {
+            details.add(new DetailEntryImpl((ElementImpl) detailEntriesIter.next()));
+        }
+        return details.iterator();
+    }
 
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MessageFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MessageFactoryImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MessageFactoryImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MessageFactoryImpl.java Mon Jan  2 01:40:44 2006
@@ -15,7 +15,6 @@
  */
 package org.apache.axis2.saaj2;
 
-import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
 
 import javax.xml.soap.MessageFactory;

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeImplEx.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeImplEx.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeImplEx.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeImplEx.java Mon Jan  2 01:40:44 2006
@@ -24,7 +24,6 @@
 import javax.xml.soap.Node;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
-import java.util.Iterator;
 
 /**
  * A representation of a node (element) in a DOM representation of an XML document
@@ -127,17 +126,16 @@
             OMElement elem = ((OMElement) this);
             OMNode firstChild = elem.getFirstOMChild();
             if (firstChild == null ||
-                (((Node) firstChild).getNodeType() == Node.TEXT_NODE && firstChild.getNextOMSibling() == null))
-            {
-                //If there are no children OR
+                (((Node) firstChild).getNodeType() == Node.TEXT_NODE &&
+                 firstChild.getNextOMSibling() == null)){//If there are no children OR
                 //the first child is a text node and the only child
 
                 ((OMElement) this).setText(value);
             } else {
-                throw new IllegalStateException("This node is not a Text  node and either has more than one child node or has a child node that is not a Text node");
+                throw new IllegalStateException("This node is not a Text  node and " +
+                                                "either has more than one child node or has a child " +
+                                                "node that is not a Text node");
             }
-
-
         }
     }
 

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeListImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeListImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/NodeListImpl.java Mon Jan  2 01:40:44 2006
@@ -63,10 +63,11 @@
      * Returns the <code>index</code>th item in the collection. If
      * <code>index</code> is greater than or equal to the number of nodes in
      * the list, this returns <code>null</code>.
+     *
      * @param index Index into the collection.
      * @return The node at the <code>index</code>th position in the
-     *   <code>NodeList</code>, or <code>null</code> if that is not a valid
-     *   index.
+     *         <code>NodeList</code>, or <code>null</code> if that is not a valid
+     *         index.
      */
     public Node item(int index) {
         if (mNodes != null && mNodes.size() > index) {

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyElementImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyElementImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyElementImpl.java Mon Jan  2 01:40:44 2006
@@ -15,17 +15,17 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.SOAPBodyElement;
-
 import org.apache.axis2.om.impl.dom.ElementImpl;
 
+import javax.xml.soap.SOAPBodyElement;
+
 public class SOAPBodyElementImpl extends SOAPElementImpl implements SOAPBodyElement {
 
-	/**
-	 * @param element
-	 */
-	public SOAPBodyElementImpl(ElementImpl element) {
-		super(element);
-	}
+    /**
+     * @param element
+     */
+    public SOAPBodyElementImpl(ElementImpl element) {
+        super(element);
+    }
 
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPBodyImpl.java Mon Jan  2 01:40:44 2006
@@ -159,6 +159,6 @@
 
         SOAPElementImpl elem = new SOAPElementImpl((ElementImpl) document.getDocumentElement());
         return new SOAPBodyElementImpl(elem.element);
-		
-	}
+
+    }
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java Mon Jan  2 01:40:44 2006
@@ -15,8 +15,8 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.SOAPConnectionFactory;
 import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
 import javax.xml.soap.SOAPException;
 
 /**

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java Mon Jan  2 01:40:44 2006
@@ -20,17 +20,21 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Call;
 import org.apache.axis2.client.Options;
+import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMNode;
 import org.apache.axis2.om.OMText;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
 import org.apache.axis2.om.impl.dom.ElementImpl;
-import org.apache.axis2.util.SessionUtils;
+import org.apache.axis2.saaj2.util.SAAJUtil;
+import org.apache.axis2.util.SessionUtils2;
 
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import java.net.MalformedURLException;
@@ -58,41 +62,64 @@
      * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
     public SOAPMessage call(SOAPMessage request, Object endpoint) throws SOAPException {
+
+        // initialize URL
+        URL url;
+        try {
+            url = (endpoint instanceof URL) ? (URL) endpoint : new URL(endpoint.toString());
+        } catch (MalformedURLException e) {
+            throw new SOAPException(e);
+        }
+
+        // initialize the Call
+        Call call;
+        try {
+            call = new Call();
+        } catch (AxisFault e) {
+            throw new SOAPException(e);
+        }
+
+        // initialize and set Options
+        Options options = new Options();
+        options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        options.setTo(new EndpointReference(url.toString()));
+        call.setClientOptions(options);
+
+        String axisOp = request.getSOAPBody().getFirstChild().getNodeName();
+
         try {
-            OMElement envelope =
-                    ((SOAPEnvelopeImpl) request.getSOAPPart().getEnvelope()).getOMEnvelope();
+            final SOAPEnvelope saajEnvelope = request.getSOAPPart().getEnvelope();
+            /* final org.apache.axis2.soap.SOAPEnvelope omEnvelope =
+           ((SOAPEnvelopeImpl) saajEnvelope).getOMEnvelope();*/
+
+            final Iterator attachmentIter = request.getAttachments();
+            while (attachmentIter.hasNext()) {
+                System.err.println("########### Att=" + attachmentIter.next());
+            }
+
+//            final OMElement omEnvelope = ((SOAPEnvelopeImpl) saajEnvelope).getOMEnvelope();
 
             //parse the omEnvelope element and stuff it with the attachment
             //specific omText nodes
-            insertAttachmentNodes(envelope, request);
+//            insertAttachmentNodes(omEnvelope, request);
 
-            Call call = new Call();
-            URL url = new URL(endpoint.toString());
+            //-------------- Send the Request -----------------------
 
-            Options options = new Options();
-            options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
-            options.setListenerTransportProtocol(Constants.TRANSPORT_HTTP);
-            options.setTo(new EndpointReference(url.toString()));
-            call.setClientOptions(options);
-
-            String axisOp = request.getSOAPBody().getFirstChild().getNodeName();
-            NodeImplEx bodyContentNode = (NodeImplEx) request.getSOAPBody().getFirstChild();
-
-            //TODO; check this
-            ElementImpl bodyContent = ((SOAPElementImpl) bodyContentNode).getElement();
-
-            OMElement result = call.invokeBlocking(axisOp, (OMElement) bodyContent);
-            org.apache.axis2.soap.SOAPEnvelope responseEnv =
-                    (org.apache.axis2.soap.SOAPEnvelope) ((OMElement) result.getParent()).getParent();
-            SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
+            //Convert to Default OM Implementation(LLOM at the moment) before calling Call.invokeBlocking
+            OMElement result =
+                    call.invokeBlocking(axisOp,
+                                        SAAJUtil.toOMSOAPEnvelope(request.getSOAPPart().getDocumentElement()));
 
-            SOAPMessageImpl sMsg = new SOAPMessageImpl(response);
-            extractAttachmentNodes(responseEnv, sMsg);
-            return sMsg;
+            //-------------- Handle the response --------------------
+            SOAPEnvelopeImpl responseEnv =
+                    new SOAPEnvelopeImpl(SAAJUtil.toDOOMSOAPEnvelope((org.apache.axis2.soap.SOAPEnvelope) result));
 
-        } catch (MalformedURLException mue) {
-            throw new SOAPException(mue);
-        } catch (AxisFault af) {
+            SOAPMessageImpl sMsg = new SOAPMessageImpl(responseEnv);
+//            extractAttachmentNodes(result, sMsg);
+            return sMsg;
+        }
+        catch (AxisFault af) {
             throw new SOAPException(af);
         }
     }
@@ -111,24 +138,30 @@
      * This method recursively stuffs the OMElement with appropriate OMText nodes
      * that are prepared out of attachment contents whereever those attachments are referenced
      *
-     * @param element
+     * @param omEnvelope
      * @param soapMsg
      */
-    private void insertAttachmentNodes(OMElement element, SOAPMessage soapMsg) throws SOAPException {
-        Iterator childIter = element.getChildElements();
+    private void insertAttachmentNodes(OMElement omEnvelope, SOAPMessage soapMsg) throws SOAPException {
+//    private void insertAttachmentNodes(org.apache.axis2.soap.SOAPEnvelope omEnvelope,
+//                                       SOAPMessage soapMsg) throws SOAPException {
+
+        Iterator childIter = omEnvelope.getChildElements();
         while (childIter.hasNext()) {
             OMElement child = (OMElement) childIter.next();
             //check if there is an href attribute
             OMAttribute hrefAttr = child.getAttribute(new QName("href"));
             String hrefContentId = validateHref(hrefAttr);
 
-            if (hrefContentId != null) {//This is an element referencing an attachment!
-                OMText omText = getOMTextForReferencedAttachment(hrefContentId, soapMsg);
+            System.err.println("########## hrefContentId=" + hrefContentId);
+            if (hrefContentId != null) {//This is an omEnvelope referencing an attachment!
                 child.build();
-                child.removeAttribute(hrefAttr);
-                child.addChild(omText);
+                OMText omText = getOMTextForReferencedAttachment(hrefContentId,
+                                                                 soapMsg,
+                                                                 (DocumentImpl) ((ElementImpl) child).getOwnerDocument());
 
-            } else { //possibly there can be references in the children of this element
+//                child.removeAttribute(hrefAttr); //y did SAAJ1 implementors remove the attribute???
+                child.addChild(omText);
+            } else { //possibly there can be references in the children of this omEnvelope
                 //so recurse through.
                 insertAttachmentNodes(child, soapMsg);
             }
@@ -152,11 +185,15 @@
                 DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
                 if (actualDH != null) {
                     AttachmentPart ap = soapMsg.createAttachmentPart(actualDH);
-                    String contentId = SessionUtils.generateSessionId();
+                    String contentId = SessionUtils2.generateSessionId();
                     ap.setContentId(contentId);
                     ap.setContentType(actualDH.getContentType());
                     OMElement parent = (OMElement) child.getParent();
-                    OMAttribute attr = org.apache.axis2.om.OMAbstractFactory.getOMFactory().createOMAttribute("href", null, "cid:" + contentId);
+                    OMAttribute attr =
+                            DOOMAbstractFactory.getOMFactory().createOMAttribute("href",
+                                                                                 null,
+                                                                                 "cid:" + contentId);
+
                     parent.addAttribute(attr);
                     binaryNode.detach();
                     soapMsg.addAttachmentPart(ap);
@@ -199,13 +236,16 @@
      * @param soapMsg
      * @return OMText
      */
-    private OMText getOMTextForReferencedAttachment(String contentId, SOAPMessage soapMsg) throws SOAPException {
+    private OMText getOMTextForReferencedAttachment(String contentId,
+                                                    SOAPMessage soapMsg,
+                                                    DocumentImpl doc) throws SOAPException {
+
         Iterator attachIter = soapMsg.getAttachments();
         while (attachIter.hasNext()) {
             AttachmentPart attachment = (AttachmentPart) attachIter.next();
             if (attachment.getContentId().equals(contentId)) {
                 try {
-                    return ((AttachmentPartImpl) attachment).getOMText();
+                    return ((AttachmentPartImpl) attachment).getText(doc);
                 } catch (Exception e) {
                     throw new SOAPException(e);
                 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java Mon Jan  2 01:40:44 2006
@@ -213,6 +213,14 @@
         return attribute.getAttributeValue();
     }
 
+    /**
+     * Returns an iterator over all the immediate content of
+     * this element. This includes <CODE>Text</CODE> objects as well
+     * as <CODE>SOAPElement</CODE> objects.
+     *
+     * @return an iterator over <CODE>Text</CODE> and <CODE>SOAPElement</CODE>
+     *         contained within this <CODE>SOAPElement</CODE> object
+     */
     public Iterator getChildElements() {
         //Actually all the children are being treated as OMNodes and are being
         //wrapped accordingly to a single type (SOAPElement) and being returned in an iterator.

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java Mon Jan  2 01:40:44 2006
@@ -25,7 +25,6 @@
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPElement;
 
 /**
  * 
@@ -46,7 +45,7 @@
     public org.apache.axis2.soap.SOAPEnvelope getOMEnvelope() {
         return omSOAPEnvelope;
     }
-    
+
     /**
      * Creates a new <CODE>Name</CODE> object initialized with the
      * given local name, namespace prefix, and namespace URI.

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultElementImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultElementImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultElementImpl.java Mon Jan  2 01:40:44 2006
@@ -15,18 +15,18 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.SOAPFaultElement;
-
 import org.apache.axis2.om.impl.dom.ElementImpl;
 
+import javax.xml.soap.SOAPFaultElement;
+
 public class SOAPFaultElementImpl extends SOAPElementImpl implements
-		SOAPFaultElement {
+                                                          SOAPFaultElement {
 
-	/**
-	 * @param element
-	 */
-	public SOAPFaultElementImpl(ElementImpl element) {
-		super(element);
-	}
+    /**
+     * @param element
+     */
+    public SOAPFaultElementImpl(ElementImpl element) {
+        super(element);
+    }
 
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java Mon Jan  2 01:40:44 2006
@@ -1,21 +1,23 @@
 package org.apache.axis2.saaj2;
 
+import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.soap.SOAPFaultCode;
 import org.apache.axis2.soap.SOAPFaultReason;
 import org.apache.axis2.soap.SOAPFaultRole;
 import org.apache.axis2.soap.SOAPFaultText;
-import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultCodeImpl;
+import org.apache.axis2.soap.SOAPFaultValue;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultDetailImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultReasonImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultRoleImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultTextImpl;
-import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultValueImpl;
 
 import javax.xml.soap.Detail;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayOutputStream;
 import java.util.Locale;
 
 public class SOAPFaultImpl extends SOAPBodyElementImpl implements SOAPFault {
@@ -30,20 +32,63 @@
         fault = element;
     }
 
-    /* (non-Javadoc)
-      * @see javax.xml.soap.SOAPFault#setFaultCode(java.lang.String)
-      */
+    /**
+     * Sets this <CODE>SOAPFault</CODE> object with the given
+     * fault code.
+     * <p/>
+     * <P>Fault codes, which given information about the fault,
+     * are defined in the SOAP 1.1 specification.</P>
+     *
+     * @param faultCode a <CODE>String</CODE> giving
+     *                  the fault code to be set; must be one of the fault codes
+     *                  defined in the SOAP 1.1 specification
+     * @throws SOAPException if there was an error in
+     *                       adding the <CODE>faultCode</CODE> to the underlying XML
+     *                       tree.
+     * @see #getFaultCode() getFaultCode()
+     */
     public void setFaultCode(String faultCode) throws SOAPException {
-        SOAPFaultCode code = new SOAP11FaultCodeImpl(fault);
+        /*SOAPFaultCode code = new SOAP11FaultCodeImpl(fault);
         SOAP11FaultValueImpl faultValueImpl = new SOAP11FaultValueImpl(code);
         faultValueImpl.setText(faultCode);
         code.setValue(faultValueImpl);
-        this.fault.setCode(code);
+        this.fault.setCode(code);*/
+
+        org.apache.axis2.soap.SOAPFactory soapFactory = DOOMAbstractFactory.getSOAP11Factory();
+        SOAPFaultCode fCode = soapFactory.createSOAPFaultCode(fault);
+        SOAPFaultValue fValue = soapFactory.createSOAPFaultValue(fCode);
+        fCode.setValue(fValue);
+        fValue.setText(faultCode);
+
+        this.fault.setCode(fCode);
+
+        /*try {
+            {
+                System.err.println("########################## Fault Code #########");
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                fCode.serialize(baos);
+                String xml2 = new String(baos.toByteArray());
+                System.out.println(xml2);
+                System.err.println("##########################");
+            }
+            System.err.println("########################## Fault -------");
+            ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+            fault.serialize(baos2);
+            String xml3 = new String(baos2.toByteArray());
+            System.out.println(xml3);
+            System.err.println("##########################-----------");
+        } catch (XMLStreamException e) {
+            e.printStackTrace();
+        }*/
     }
 
-    /* (non-Javadoc)
-      * @see javax.xml.soap.SOAPFault#getFaultCode()
-      */
+    /**
+     * Gets the fault code for this <CODE>SOAPFault</CODE>
+     * object.
+     *
+     * @return a <CODE>String</CODE> with the fault code
+     * @see #setFaultCode(java.lang.String) setFaultCode(java.lang.String)
+     */
     public String getFaultCode() {
         return this.fault.getCode().getValue().getText();
     }
@@ -94,11 +139,38 @@
                 reason.setSOAPText(text);
             }
         } else {
-            SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault);
-            SOAPFaultText text = new SOAP11FaultTextImpl(reason);
-            text.setText(faultString);
-            reason.setSOAPText(text);
-            this.fault.setReason(reason);
+            /*SOAPFaultReason fReason = new SOAP11FaultReasonImpl(this.fault);
+            SOAPFaultText fText = new SOAP11FaultTextImpl(fReason);
+            fText.setText(faultString);
+            fReason.setSOAPText(fText);
+            this.fault.setReason(fReason);*/
+
+            org.apache.axis2.soap.SOAPFactory soapFactory = DOOMAbstractFactory.getSOAP11Factory();
+            SOAPFaultReason fReason = soapFactory.createSOAPFaultReason(fault);
+            SOAPFaultText fText = soapFactory.createSOAPFaultText(fReason);
+            fText.setText(faultString);
+            fReason.setSOAPText(fText);
+
+            this.fault.setReason(fReason);
+
+            try {
+              /*  System.err.println("########################## Fault String ######");
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                fReason.serialize(baos);
+                String xml2 = new String(baos.toByteArray());
+                System.out.println(xml2);
+                System.err.println("##########################");*/
+
+                System.err.println("########################## Fault -------");
+                ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+                fault.serialize(baos2);
+                String xml3 = new String(baos2.toByteArray());
+                System.out.println(xml3);
+                System.err.println("##########################-----------");
+
+            } catch (XMLStreamException e) {
+                e.printStackTrace();
+            }
         }
     }
 
@@ -128,8 +200,7 @@
     public Detail addDetail() throws SOAPException {
         SOAP11FaultDetailImpl omDetail = new SOAP11FaultDetailImpl(this.fault);
         this.fault.setDetail(omDetail);
-        Detail detail = new DetailImpl(omDetail);
-        return detail;
+        return new DetailImpl(omDetail);
     }
 
     /* (non-Javadoc)

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPMessageImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPMessageImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPMessageImpl.java Mon Jan  2 01:40:44 2006
@@ -20,11 +20,11 @@
 
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MimeHeader;
+import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPBody;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -245,7 +245,7 @@
      */
     public void saveChanges() throws SOAPException {
         // TODO not sure of the implementation
-        throw new UnsupportedOperationException("TODO");
+//        throw new UnsupportedOperationException("TODO");
     }
 
     /**
@@ -290,6 +290,7 @@
             //the writeTo method forces the elements to be built!!!
             ((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMEnvelope().serialize(out, format);
         } catch (Exception e) {
+            e.printStackTrace();
             throw new SOAPException(e);
         }
     }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPPartImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPPartImpl.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPPartImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPPartImpl.java Mon Jan  2 01:40:44 2006
@@ -15,11 +15,10 @@
  */
 package org.apache.axis2.saaj2;
 
-import org.apache.axis2.om.impl.dom.DocumentImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.util.SessionUtils;
+import org.apache.axis2.util.SessionUtils2;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
@@ -58,7 +57,7 @@
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         SOAPEnvelopeImpl soapEnvelope) {
 
-        setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, SessionUtils.generateSessionId());
+        setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, SessionUtils2.generateSessionId());
         setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
 
         soapMessage = parentSoapMsg;
@@ -69,7 +68,7 @@
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         InputStream inputStream) throws SOAPException {
 
-        setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, SessionUtils.generateSessionId());
+        setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, SessionUtils2.generateSessionId());
         setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
 
         soapMessage = parentSoapMsg;

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/TextImplEx.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/TextImplEx.java?rev=365323&r1=365322&r2=365323&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/TextImplEx.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/TextImplEx.java Mon Jan  2 01:40:44 2006
@@ -15,12 +15,11 @@
  */
 package org.apache.axis2.saaj2;
 
+import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.OMContainer;
 import org.apache.axis2.om.OMException;
-import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.om.impl.dom.TextImpl;
-import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
 import org.w3c.dom.DOMException;
 
 import javax.xml.soap.Text;
@@ -272,7 +271,7 @@
         return textNode.getData();
     }
 
-    public String toString(){
+    public String toString() {
         return getValue();
     }
 }

Added: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/SAAJUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/SAAJUtil.java?rev=365323&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/SAAJUtil.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/util/SAAJUtil.java Mon Jan  2 01:40:44 2006
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2004,2005 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.
+ */
+
+package org.apache.axis2.saaj2.util;
+
+import org.apache.axis2.om.DOOMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.soap.SOAP11Constants;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.xml.security.utils.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * Utility class for the Axis2-WSS4J Module
+ */
+public class SAAJUtil {
+
+    /**
+     * Create a DOM Document using the org.apache.axis2.soap.SOAPEnvelope
+     *
+     * @param env An org.apache.axis2.soap.SOAPEnvelope instance
+     * @return the DOM Document of the given SOAP Envelope
+     */
+    public static Document getDocumentFromSOAPEnvelope(org.apache.axis2.soap.SOAPEnvelope env) {
+        env.build();
+
+        //Check the namespace and find SOAP version and factory
+        String nsURI;
+        SOAPFactory factory;
+        if (env.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+            nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            factory = DOOMAbstractFactory.getSOAP11Factory();
+        } else {
+            nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            factory = DOOMAbstractFactory.getSOAP11Factory();
+        }
+
+        StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
+        SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
+        envelope.build();
+
+        Element envElem = (Element) envelope;
+        return envElem.getOwnerDocument();
+    }
+
+     /**
+     * Create a DOM Document using the org.apache.axis2.soap.SOAPEnvelope
+     *
+     * @param env An org.apache.axis2.soap.SOAPEnvelope instance
+     * @return the org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl of the given SOAP Envelope
+     */
+    public static org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl
+             toDOOMSOAPEnvelope(org.apache.axis2.soap.SOAPEnvelope env) {
+        env.build();
+
+        //Check the namespace and find SOAP version and factory
+        String nsURI;
+        SOAPFactory factory;
+        if (env.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+            nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            factory = DOOMAbstractFactory.getSOAP11Factory();
+        } else {
+            nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            factory = DOOMAbstractFactory.getSOAP11Factory();
+        }
+
+        StAXSOAPModelBuilder stAXSOAPModelBuilder =
+                new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
+        SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
+        envelope.build();
+
+        return (org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl) envelope;
+    }
+
+    public static SOAPEnvelope getSOAPEnvelopeFromDOOMDocument(DocumentImpl doc) {
+        OMElement docElem = (OMElement) doc.getDocumentElement();
+        StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(docElem.getXMLStreamReader(), null);
+        return stAXSOAPModelBuilder.getSOAPEnvelope();
+    }
+
+
+    public static SOAPEnvelope toOMSOAPEnvelope(Element elem) {
+        OMElement docElem = (OMElement) elem;
+        StAXSOAPModelBuilder stAXSOAPModelBuilder =
+                new StAXSOAPModelBuilder(docElem.getXMLStreamReader(), null);
+        return stAXSOAPModelBuilder.getSOAPEnvelope();
+    }
+
+    /**
+     * Convert a given DOM Element to an OMElement
+     *
+     * @param element
+     * @return
+     */
+    public static OMElement toOM(Element element) throws XMLStreamException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        XMLUtils.outputDOM(element, os, true);
+
+        ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(is);
+
+        StAXOMBuilder builder = new StAXOMBuilder(reader);
+        builder.setCache(true);
+
+        return builder.getDocumentElement();
+    }
+
+
+    /**
+     * Convert a given OMElement to a DOM Element
+     *
+     * @param element
+     * @return
+     */
+    public static Element toDOM(OMElement element) throws Exception {
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        element.serialize(baos);
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        return factory.newDocumentBuilder().parse(bais).getDocumentElement();
+    }
+}

Added: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/Echo.aar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/Echo.aar?rev=365323&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/Echo.aar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream