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 2005/12/23 10:40:56 UTC

svn commit: r358784 [1/4] - in /webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2: src/org/apache/axis2/saaj2/ test-resources/ test/org/apache/axis2/saaj2/

Author: ruchithf
Date: Fri Dec 23 01:40:17 2005
New Revision: 358784

URL: http://svn.apache.org/viewcvs?rev=358784&view=rev
Log:
Patch from Azeez for AXIS2-306

Added:
    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/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/SOAPEnvelopeImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFactoryImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test-resources/axis.jpg   (with props)
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/AttachmentSerializationTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/AttachmentTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/EnvelopeTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/HeadersTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/JUnitTestAttachmentIntegration.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/PrefixesTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/Readme.txt
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/SOAPBodyTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/SOAPElementTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/SOAPFaultDetailTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/SOAPFaultsTest.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/test/org/apache/axis2/saaj2/TextTest.java
Modified:
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailEntryImpl.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/MimeHeadersEx.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/PrefixedQName.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/SOAPElementImpl.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/SOAPHeaderElementImpl.java
    webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderImpl.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

Added: 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=358784&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/AttachmentPartImpl.java Fri Dec 23 01:40:17 2005
@@ -0,0 +1,366 @@
+/*                                                                             
+ * 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;
+
+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.transport.http.HTTPConstants;
+
+import javax.activation.DataHandler;
+import javax.activation.UnsupportedDataTypeException;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * 
+ */
+public class AttachmentPartImpl extends AttachmentPart {
+
+    private DataHandler dataHandler;
+
+    /**
+     * Field mimeHeaders.
+     */
+    private MimeHeaders mimeHeaders = new MimeHeaders();
+
+    private OMText omText;
+
+    /**
+     * Check whether at least one of the headers of this object matches a provided header
+     *
+     * @param headers
+     * @return <b>true</b> if at least one header of this AttachmentPart matches
+     *         a header in the provided <code>headers</code> parameter,
+     *         <b>false</b> if none of the headers of this AttachmentPart matches
+     *         at least one of the header in the provided <code>headers</code> parameter
+     */
+    public boolean matches(MimeHeaders headers) {
+        for (Iterator i = headers.getAllHeaders(); i.hasNext();) {
+            MimeHeader hdr = (javax.xml.soap.MimeHeader) i.next();
+            String values[] = mimeHeaders.getHeader(hdr.getName());
+            boolean found = false;
+            if (values != null) {
+                for (int j = 0; j < values.length; j++) {
+                    if (!hdr.getValue().equalsIgnoreCase(values[j])) {
+                        continue;
+                    }
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Returns the number of bytes in this <CODE>
+     * AttachmentPart</CODE> object.
+     *
+     * @return the size of this <CODE>AttachmentPart</CODE> object
+     *         in bytes or -1 if the size cannot be determined
+     * @throws javax.xml.soap.SOAPException if the content of this
+     *                                      attachment is corrupted of if there was an exception
+     *                                      while trying to determine the size.
+     */
+    public int getSize() throws SOAPException {
+        if (dataHandler == null) {
+            return -1;
+        }
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        try {
+            dataHandler.writeTo(bout);
+        } catch (java.io.IOException ex) {
+            throw new SOAPException(ex);
+        }
+        return bout.size();
+    }
+
+    /**
+     * Clears out the content of this <CODE>
+     * AttachmentPart</CODE> object. The MIME header portion is left
+     * untouched.
+     */
+    public void clearContent() {
+        dataHandler = null;
+		omText = null;
+    }
+
+    /**
+     * Gets the content of this <code>AttachmentPart</code> object as a Java
+     * object. The type of the returned Java object depends on
+     * <ol>
+     * <li> the
+     * <code>DataContentHandler</code> object that is used to interpret the bytes
+     * </li>
+     * <li> the <code>Content-Type</code> given in the header</li>
+     * </ol>
+     * <p/>
+     * For the MIME content types "text/plain", "text/html" and "text/xml", the
+     * <code>DataContentHandler</code> object does the conversions to and
+     * from the Java types corresponding to the MIME types.
+     * For other MIME types,the <code>DataContentHandler</code> object
+     * can return an <code>InputStream</code> object that contains the content data
+     * as raw bytes.
+     * <p/>
+     * A JAXM-compliant implementation must, as a minimum, return a
+     * <code>java.lang.String</code> object corresponding to any content
+     * stream with a <code>Content-Type</code> value of
+     * <code>text/plain</code>, a
+     * <code>javax.xml.transform.StreamSource</code> object corresponding to a
+     * content stream with a <code>Content-Type</code> value of
+     * <code>text/xml</code>, a <code>java.awt.Image</code> object
+     * corresponding to a content stream with a
+     * <code>Content-Type</code> value of <code>image/gif</code> or
+     * <code>image/jpeg</code>.  For those content types that an
+     * installed <code>DataContentHandler</code> object does not understand, the
+     * <code>DataContentHandler</code> object is required to return a
+     * <code>java.io.InputStream</code> object with the raw bytes.
+     *
+     * @return a Java object with the content of this <CODE>
+     *         AttachmentPart</CODE> object
+     * @throws javax.xml.soap.SOAPException if there is no content set
+     *                                      into this <CODE>AttachmentPart</CODE> object or if there
+     *                                      was a data transformation error
+     */
+    public Object getContent() throws SOAPException {
+        if (dataHandler == null) {
+            throw new SOAPException("No content is present in this AttachmentPart");
+        }
+        try {
+            String ContentType = dataHandler.getContentType();
+            if (ContentType.equals("text/plain") ||
+                ContentType.equals("text/xml") ||
+                ContentType.equals("text/html")) {
+
+                //For these content types underlying DataContentHandler surely does
+                //the conversion to appropriate java object and we will return that java object
+                return dataHandler.getContent();
+            } else {
+                try {
+                    return dataHandler.getContent();
+                } catch (UnsupportedDataTypeException e) {
+
+                    //If the underlying DataContentHandler can't handle the object contents,
+                    //we will return an inputstream of raw bytes represneting the content data
+                    return dataHandler.getDataSource().getInputStream();
+                }
+            }
+        } catch (IOException e) {
+            throw new SOAPException(e);
+        }
+    }
+
+    /**
+     * Sets the content of this attachment part to that of the
+     * given <CODE>Object</CODE> and sets the value of the <CODE>
+     * Content-Type</CODE> header to the given type. The type of the
+     * <CODE>Object</CODE> should correspond to the value given for
+     * the <CODE>Content-Type</CODE>. This depends on the particular
+     * set of <CODE>DataContentHandler</CODE> objects in use.
+     *
+     * @param object      the Java object that makes up
+     *                    the content for this attachment part
+     * @param contentType the MIME string that
+     *                    specifies the type of the content
+     * @throws IllegalArgumentException if
+     *                                  the contentType does not match the type of the content
+     *                                  object, or if there was no <CODE>
+     *                                  DataContentHandler</CODE> object for this content
+     *                                  object
+     * @see #getContent()
+     */
+    public void setContent(Object object, String contentType) {
+
+        //TODO: need to check whether the type of the content object matches contentType
+        //TODO: need to check whether there is a DataContentHandler for this object
+        setDataHandler(new DataHandler(object, contentType));
+    }
+
+    /**
+     * Gets the <CODE>DataHandler</CODE> object for this <CODE>
+     * AttachmentPart</CODE> object.
+     *
+     * @return the <CODE>DataHandler</CODE> object associated with
+     *         this <CODE>AttachmentPart</CODE> object
+     * @throws javax.xml.soap.SOAPException if there is
+     *                                      no data in this <CODE>AttachmentPart</CODE> object
+     */
+    public DataHandler getDataHandler() throws SOAPException {
+        if (getContent() == null) {
+            throw new SOAPException("No Content present in the Attachment part");
+        }
+        return dataHandler;
+    }
+
+    /**
+     * Sets the given <CODE>DataHandler</CODE> object as the
+     * data handler for this <CODE>AttachmentPart</CODE> object.
+     * Typically, on an incoming message, the data handler is
+     * automatically set. When a message is being created and
+     * populated with content, the <CODE>setDataHandler</CODE>
+     * method can be used to get data from various data sources into
+     * the message.
+     *
+     * @param datahandler <CODE>DataHandler</CODE> object to
+     *                    be set
+     * @throws IllegalArgumentException if
+     *                                  there was a problem with the specified <CODE>
+     *                                  DataHandler</CODE> object
+     */
+    public void setDataHandler(DataHandler datahandler) {
+        if (datahandler != null) {
+            this.dataHandler = datahandler;
+            setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, datahandler.getContentType());
+            omText = DOOMAbstractFactory.getOMFactory().createText(dataHandler, true);
+        }
+    }
+
+    /**
+     * Removes all MIME headers that match the given name.
+     *
+     * @param header - the string name of the MIME
+     *               header/s to be removed
+     */
+    public void removeMimeHeader(String header) {
+        mimeHeaders.removeHeader(header);
+    }
+
+    /**
+     * Removes all the MIME header entries.
+     */
+    public void removeAllMimeHeaders() {
+        mimeHeaders.removeAllHeaders();
+    }
+
+    /**
+     * Gets all the values of the header identified by the given
+     * <CODE>String</CODE>.
+     *
+     * @param name the name of the header; example:
+     *             "Content-Type"
+     * @return a <CODE>String</CODE> array giving the value for the
+     *         specified header
+     * @see #setMimeHeader(String, String) setMimeHeader(java.lang.String, java.lang.String)
+     */
+    public String[] getMimeHeader(String name) {
+        return mimeHeaders.getHeader(name);
+    }
+
+    /**
+     * Changes the first header entry that matches the given name
+     * to the given value, adding a new header if no existing
+     * header matches. This method also removes all matching
+     * headers but the first.
+     * <p/>
+     * <P>Note that RFC822 headers can only contain US-ASCII
+     * characters.</P>
+     *
+     * @param name  a <CODE>String</CODE> giving the
+     *              name of the header for which to search
+     * @param value a <CODE>String</CODE> giving the
+     *              value to be set for the header whose name matches the
+     *              given name
+     * @throws IllegalArgumentException if
+     *                                  there was a problem with the specified mime header name
+     *                                  or value
+     */
+    public void setMimeHeader(String name, String value) {
+        mimeHeaders.setHeader(name, value);
+    }
+
+    /**
+     * Adds a MIME header with the specified name and value to
+     * this <CODE>AttachmentPart</CODE> object.
+     * <p/>
+     * <P>Note that RFC822 headers can contain only US-ASCII
+     * characters.</P>
+     *
+     * @param name  a <CODE>String</CODE> giving the
+     *              name of the header to be added
+     * @param value a <CODE>String</CODE> giving the
+     *              value of the header to be added
+     * @throws IllegalArgumentException if
+     *                                  there was a problem with the specified mime header name
+     *                                  or value
+     */
+    public void addMimeHeader(String name, String value) {
+        mimeHeaders.addHeader(name, value);
+    }
+
+    /**
+     * Retrieves all the headers for this <CODE>
+     * AttachmentPart</CODE> object as an iterator over the <CODE>
+     * MimeHeader</CODE> objects.
+     *
+     * @return an <CODE>Iterator</CODE> object with all of the Mime
+     *         headers for this <CODE>AttachmentPart</CODE> object
+     */
+    public Iterator getAllMimeHeaders() {
+        return mimeHeaders.getAllHeaders();
+    }
+
+    /**
+     * Retrieves all <CODE>MimeHeader</CODE> objects that match
+     * a name in the given array.
+     *
+     * @param names a <CODE>String</CODE> array with
+     *              the name(s) of the MIME headers to be returned
+     * @return all of the MIME headers that match one of the names
+     *         in the given array as an <CODE>Iterator</CODE>
+     *         object
+     */
+    public Iterator getMatchingMimeHeaders(String names[]) {
+        return mimeHeaders.getMatchingHeaders(names);
+    }
+
+    /**
+     * Retrieves all <CODE>MimeHeader</CODE> objects whose name
+     * does not match a name in the given array.
+     *
+     * @param names a <CODE>String</CODE> array with
+     *              the name(s) of the MIME headers not to be returned
+     * @return all of the MIME headers in this <CODE>
+     *         AttachmentPart</CODE> object except those that match one
+     *         of the names in the given array. The nonmatching MIME
+     *         headers are returned as an <CODE>Iterator</CODE>
+     *         object.
+     */
+    public Iterator getNonMatchingMimeHeaders(String names[]) {
+        return mimeHeaders.getNonMatchingHeaders(names);
+    }
+
+    /**
+     * Retrieve the OMText
+     *
+     * @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;
+	}
+}

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailEntryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailEntryImpl.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailEntryImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/DetailEntryImpl.java Fri Dec 23 01:40:17 2005
@@ -15,17 +15,22 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.DetailEntry;
-
 import org.apache.axis2.om.impl.dom.ElementImpl;
 
+import javax.xml.soap.DetailEntry;
+
+/**
+ * The content for a Detail object, giving details for a SOAPFault object.
+ * A DetailEntry object, which carries information about errors related to the
+ * SOAPBody  object that contains it, is application-specific.
+ */
 public class DetailEntryImpl extends SOAPElementImpl implements DetailEntry {
 
-	/**
-	 * @param element
-	 */
-	public DetailEntryImpl(ElementImpl element) {
-		super(element);
-	}
+    /**
+     * @param element
+     */
+    public DetailEntryImpl(ElementImpl element) {
+        super(element);
+    }
 
 }

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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -27,6 +27,34 @@
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.soap.SOAPFaultDetail;
 
+/**
+ * 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>
+ * 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
+ * <code>DetailEntry</code> object and also automatically adds it to
+ * 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>
+ * 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
+ * <code>DetailEntry</code> objects in <i>d</i>. The code also creates a
+ * <code>Name</code> object to pass to the method <code>addDetailEntry</code>.
+ * The variable <i>se</i>, used to create the <code>Name</code> object,
+ * is a <code>SOAPEnvelope</code> object.
+ * <PRE>
+ * Detail d = sf.getDetail();
+ * Name name = se.createName("GetLastTradePrice", "WOMBAT",
+ * "http://www.wombat.org/trader");
+ * d.addDetailEntry(name);
+ * Iterator it = d.getDetailEntries();
+ * </PRE>
+ */
 public class DetailImpl extends SOAPFaultElementImpl implements Detail {
 
 	SOAPFaultDetail faultDetail;
@@ -36,24 +64,32 @@
 	 */
 	public DetailImpl(SOAPFaultDetail element) {
 		super((ElementImpl)element);
-		this.faultDetail = element;
+		faultDetail = element;
 	}
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.Detail#addDetailEntry(javax.xml.soap.Name)
-	 */
+	/**
+     * Creates a new <code>DetailEntry</code> object with the given
+     * name and adds it to this <code>Detail</code> object.
+     *
+     * @param name a <code>Name</code> object identifying the new <code>DetailEntry</code> object
+     * @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)this.addChildElement(name);
+		SOAPElementImpl childElement = (SOAPElementImpl)addChildElement(name);
 		DetailEntryImpl detailEntryImpl = new DetailEntryImpl(childElement.element);
-		this.faultDetail.addDetailEntry((OMElement)detailEntryImpl);
+		faultDetail.addDetailEntry((OMElement)detailEntryImpl);
 		return detailEntryImpl;
 	}
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.Detail#getDetailEntries()
-	 */
+	/**
+     * 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 this.faultDetail.getAllDetailEntries();
+		return faultDetail.getAllDetailEntries();
 	}
 
 }

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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -15,31 +15,140 @@
  */
 package org.apache.axis2.saaj2;
 
-import java.io.IOException;
-import java.io.InputStream;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
 
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
+import java.io.IOException;
+import java.io.InputStream;
 
+/**
+ * <P>A factory for creating <CODE>SOAPMessage</CODE> objects.</P>
+ * <p/>
+ * <P>A JAXM client performs the following steps to create a
+ * message.</P>
+ * <p/>
+ * <UL>
+ * <LI>
+ * Creates a <CODE>MessageFactory</CODE> object from a <CODE>
+ * ProviderConnection</CODE> object (<CODE>con</CODE> in the
+ * following line of code). The <CODE>String</CODE> passed to
+ * the <CODE>createMessageFactory</CODE> method is the name of
+ * of a messaging profile, which must be the URL for the
+ * schema.
+ * <PRE>
+ * MessageFactory mf = con.createMessageFactory(schemaURL);
+ * </PRE>
+ * </LI>
+ * <p/>
+ * <LI>
+ * Calls the method <CODE>createMessage</CODE> on the <CODE>
+ * MessageFactory</CODE> object. All messages produced by this
+ * <CODE>MessageFactory</CODE> object will have the header
+ * information appropriate for the messaging profile that was
+ * specified when the <CODE>MessageFactory</CODE> object was
+ * created.
+ * <PRE>
+ * SOAPMessage m = mf.createMessage();
+ * </PRE>
+ * </LI>
+ * </UL>
+ * It is also possible to create a <CODE>MessageFactory</CODE>
+ * object using the method <CODE>newInstance</CODE>, as shown in
+ * the following line of code.
+ * <PRE>
+ * MessageFactory mf = MessageFactory.newInstance();
+ * </PRE>
+ * A standalone client (a client that is not running in a
+ * container) can use the <CODE>newInstance</CODE> method to
+ * create a <CODE>MessageFactory</CODE> object.
+ * <p/>
+ * <P>All <CODE>MessageFactory</CODE> objects, regardless of how
+ * they are created, will produce <CODE>SOAPMessage</CODE> objects
+ * that have the following elements by default:</P>
+ * <p/>
+ * <UL>
+ * <LI>A <CODE>SOAPPart</CODE> object</LI>
+ * <p/>
+ * <LI>A <CODE>SOAPEnvelope</CODE> object</LI>
+ * <p/>
+ * <LI>A <CODE>SOAPBody</CODE> object</LI>
+ * <p/>
+ * <LI>A <CODE>SOAPHeader</CODE> object</LI>
+ * </UL>
+ * If a <CODE>MessageFactory</CODE> object was created using a
+ * <CODE>ProviderConnection</CODE> object, which means that it was
+ * initialized with a specified profile, it will produce messages
+ * that also come prepopulated with additional entries in the
+ * <CODE>SOAPHeader</CODE> object and the <CODE>SOAPBody</CODE>
+ * object. The content of a new <CODE>SOAPMessage</CODE> object
+ * depends on which of the two <CODE>MessageFactory</CODE> methods
+ * is used to create it.
+ * <p/>
+ * <UL>
+ * <LI><CODE>createMessage()</CODE> -- message has no
+ * content<BR>
+ * This is the method clients would normally use to create a
+ * request message.</LI>
+ * <p/>
+ * <LI><CODE>createMessage(MimeHeaders,
+ * java.io.InputStream)</CODE> -- message has content from the
+ * <CODE>InputStream</CODE> object and headers from the <CODE>
+ * MimeHeaders</CODE> object<BR>
+ * This method can be used internally by a service
+ * implementation to create a message that is a response to a
+ * request.</LI>
+ * </UL>
+ */
 public class MessageFactoryImpl extends MessageFactory {
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.MessageFactory#createMessage()
-	 */
-	public SOAPMessage createMessage() throws SOAPException {
-		// TODO TODO
-		throw new UnsupportedOperationException("TODO");
-	}
+    /**
+     * Creates a new <CODE>SOAPMessage</CODE> object with the
+     * default <CODE>SOAPPart</CODE>, <CODE>SOAPEnvelope</CODE>,
+     * <CODE>SOAPBody</CODE>, and <CODE>SOAPHeader</CODE> objects.
+     * Profile-specific message factories can choose to
+     * prepopulate the <CODE>SOAPMessage</CODE> object with
+     * profile-specific headers.
+     * <p/>
+     * <P>Content can be added to this message's <CODE>
+     * SOAPPart</CODE> object, and the message can be sent "as is"
+     * when a message containing only a SOAP part is sufficient.
+     * Otherwise, the <CODE>SOAPMessage</CODE> object needs to
+     * create one or more <CODE>AttachmentPart</CODE> objects and
+     * add them to itself. Any content that is not in XML format
+     * must be in an <CODE>AttachmentPart</CODE> object.</P>
+     *
+     * @return a new <CODE>SOAPMessage</CODE> object
+     * @throws SOAPException if a SOAP error occurs
+     */
+    public SOAPMessage createMessage() throws SOAPException {
+        final SOAPEnvelopeImpl soapEnvelope =
+                new SOAPEnvelopeImpl(new SOAP11Factory().getDefaultEnvelope());
+        return new SOAPMessageImpl(soapEnvelope);
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.MessageFactory#createMessage(javax.xml.soap.MimeHeaders, java.io.InputStream)
-	 */
-	public SOAPMessage createMessage(MimeHeaders mimeheaders,
-			InputStream inputstream) throws IOException, SOAPException {
-		// TODO TODO
-		throw new UnsupportedOperationException("TODO");
-	}
+    /**
+     * Internalizes the contents of the given <CODE>
+     * InputStream</CODE> object into a new <CODE>SOAPMessage</CODE>
+     * object and returns the <CODE>SOAPMessage</CODE> object.
+     *
+     * @param mimeheaders the transport-specific headers
+     *                    passed to the message in a transport-independent fashion
+     *                    for creation of the message
+     * @param inputstream the <CODE>InputStream</CODE> object
+     *                    that contains the data for a message
+     * @return a new <CODE>SOAPMessage</CODE> object containing the
+     *         data from the given <CODE>InputStream</CODE> object
+     * @throws IOException   if there is a
+     *                       problem in reading data from the input stream
+     * @throws SOAPException if the message is invalid
+     */
+    public SOAPMessage createMessage(MimeHeaders mimeheaders,
+                                     InputStream inputstream) throws IOException, SOAPException {
+        return new SOAPMessageImpl(inputstream, mimeheaders);
+    }
 
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MimeHeadersEx.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MimeHeadersEx.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MimeHeadersEx.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/MimeHeadersEx.java Fri Dec 23 01:40:17 2005
@@ -22,21 +22,11 @@
     public MimeHeadersEx() {
     }
 
-    public MimeHeadersEx(javax.xml.soap.MimeHeaders h) {
-        Iterator iterator = h.getAllHeaders();
+    public MimeHeadersEx(javax.xml.soap.MimeHeaders mimeHeaders) {
+        Iterator iterator = mimeHeaders.getAllHeaders();
         while (iterator.hasNext()) {
             MimeHeader hdr = (MimeHeader) iterator.next();
             addHeader(hdr.getName(), hdr.getValue());
         }
-    }
-
-    private int getHeaderSize() {
-        int size = 0;
-        Iterator iterator = getAllHeaders();
-        while (iterator.hasNext()) {
-            iterator.next();
-            size++;
-        }
-        return size;
     }
 }

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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -15,77 +15,137 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.Node;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-
 import org.apache.axis2.om.OMContainer;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNode;
 import org.apache.axis2.om.impl.dom.NodeImpl;
 
+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
+ * that provides some tree manipulation methods.
+ * This interface provides methods for getting the value of a node, for
+ * getting and setting the parent of a node, and for removing a node.
+ */
 public abstract class NodeImplEx extends NodeImpl implements Node {
 
-	private SOAPElement parentElement;
-	
-	public void detachNode() {
-		this.detach();
-	}
-
-	public SOAPElement getParentElement() {
-		return this.parentElement;
-	}
-	
-	public OMContainer getParent() {
-		return (OMContainer)this.parentElement;
-	}
-
-	public String getValue() {
-		if(this.getNodeType() == Node.TEXT_NODE) {
-			return this.getNodeValue();
-		} else if(this.getType() == Node.TEXT_NODE) {
-			return ((NodeImplEx)(((OMElement)this).getFirstOMChild())).getValue();
-		} else {
-			return null;
-		}
-	}
+    private SOAPElement parentElement;
 
-	public void recycleNode() {
+    /**
+     * Removes this <code>Node</code> object from the tree. Once
+     * removed, this node can be garbage collected if there are no
+     * application references to it.
+     */
+    public void detachNode() {
+        this.detach();
+    }
+
+    /**
+     * Removes this <code>Node</code> object from the tree. Once
+     * removed, this node can be garbage collected if there are no
+     * application references to it.
+     */
+    public SOAPElement getParentElement() {
+        return this.parentElement;
+    }
+
+    public OMContainer getParent() {
+        return (OMContainer) this.parentElement;
+    }
+
+    /* public OMNode getOMNode() {
+        return omNode;
+    }*/
+
+    /**
+     * Returns the the value of the immediate child of this <code>Node</code>
+     * object if a child exists and its valu e is text.
+     *
+     * @return a <code>String</code> with the text of the immediate child of
+     *         this <code>Node</code> object if (1) there is a child and
+     *         (2) the child is a <code>Text</code> object;
+     *         <code>null</code> otherwise
+     */
+    public String getValue() {
+        if (this.getNodeType() == Node.TEXT_NODE) {
+            return this.getNodeValue();
+        } else if (this.getNodeType() == Node.ELEMENT_NODE) {
+            return ((NodeImplEx) (((OMElement) this).getFirstOMChild())).getValue();
+        }
+        return null;
+    }
+
+    /**
+     * Notifies the implementation that this <code>Node</code>
+     * object is no longer being used by the application and that the
+     * implementation is free to reuse this object for nodes that may
+     * be created later.
+     * <p/>
+     * Calling the method <code>recycleNode</code> implies that the method
+     * <code>detachNode</code> has been called previously.
+     */
+    public void recycleNode() {
         // No corresponding implementation in OM
         // There is no implementation in Axis 1.2 also
-	}
-
-	public void setParentElement(SOAPElement parent) throws SOAPException {
-		this.parentElement = parent;
-	}
-
-	public void setValue(String value) {
-		if(this.getNodeType() == Node.TEXT_NODE) {
-			this.setNodeValue(value);
-		} else if(this.getNodeType() == Node.ELEMENT_NODE) {
-			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
-				//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");
-			}
-			
-			
-		}
-	}
-
-	public void setType(int nodeType) throws OMException {
-		throw new UnsupportedOperationException("TODO");
-	}
-
-	public int getType() {
-		return this.getNodeType();
-	}
+    }
 
+    /**
+     * Sets the parent of this <code>Node</code> object to the given
+     * <code>SOAPElement</code> object.
+     *
+     * @param parent the <code>SOAPElement</code> object to be set as
+     *               the parent of this <code>Node</code> object
+     * @throws SOAPException if there is a problem in setting the
+     *                       parent to the given element
+     * @see #getParentElement() getParentElement()
+     */
+    public void setParentElement(SOAPElement parent) throws SOAPException {
+        this.parentElement = parent;
+    }
+
+    /**
+     * If this is a Text node then this method will set its value, otherwise it
+     * sets the value of the immediate (Text) child of this node. The value of
+     * the immediate child of this node can be set only if, there is one child
+     * node and that node is a Text node, or if there are no children in which
+     * case a child Text node will be created.
+     *
+     * @param value the text to set
+     * @throws IllegalStateException if the 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
+     */
+    public void setValue(String value) {
+        if (this.getNodeType() == Node.TEXT_NODE) {
+            this.setNodeValue(value);
+        } else if (this.getNodeType() == Node.ELEMENT_NODE) {
+            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
+                //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");
+            }
+
+
+        }
+    }
+
+    public void setType(int nodeType) throws OMException {
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    public int getType() {
+        return this.getNodeType();
+    }
 }

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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -22,6 +22,14 @@
 import java.util.Collections;
 import java.util.List;
 
+/**
+ * The <code>NodeList</code> interface provides the abstraction of an ordered
+ * collection of nodes, without defining or constraining how this collection
+ * is implemented. <code>NodeList</code> objects in the DOM are live.
+ * <p>The items in the <code>NodeList</code> are accessible via an integral
+ * index, starting from 0.
+ * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
+ */
 public class NodeListImpl implements NodeList {
 
     List mNodes;
@@ -52,10 +60,13 @@
     }
 
     /**
-     * Interface Implemented
-     *
-     * @param index
-     * @return
+     * 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.
      */
     public Node item(int index) {
         if (mNodes != null && mNodes.size() > index) {
@@ -65,6 +76,10 @@
         }
     }
 
+    /**
+     * The number of nodes in the list. The range of valid child node indices
+     * is 0 to <code>length-1</code> inclusive.
+     */
     public int getLength() {
         return mNodes.size();
     }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/PrefixedQName.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/PrefixedQName.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/PrefixedQName.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/PrefixedQName.java Fri Dec 23 01:40:17 2005
@@ -27,7 +27,7 @@
     /**
      * comment/shared empty string
      */
-    private static final String emptyString = "".intern();
+    private static final String EMPTY_STRING = "".intern();
 
     /**
      * Field prefix
@@ -43,13 +43,13 @@
      *
      * @param uri
      * @param localName
-     * @param pre
+     * @param prefix
      */
-    public PrefixedQName(String uri, String localName, String pre) {
+    public PrefixedQName(String uri, String localName, String prefix) {
         qName = new QName(uri, localName);
-        prefix = (pre == null)
-                ? emptyString
-                : pre.intern();
+        this.prefix = (prefix == null)
+                      ? EMPTY_STRING
+                      : prefix.intern();
     }
 
     /**
@@ -60,55 +60,53 @@
      */
     public PrefixedQName(QName qname) {
         this.qName = qname;
-        prefix = emptyString;
+        prefix = EMPTY_STRING;
     }
 
     /**
-     * Method getLocalName
+     * Gets the local name part of the XML name that this <code>Name</code>
+     * object represents.
      *
-     * @return
+     * @return a string giving the local name
      */
     public String getLocalName() {
         return qName.getLocalPart();
     }
 
     /**
-     * Method getQualifiedName
+     * Gets the namespace-qualified name of the XML name that this
+     * <code>Name</code> object represents.
      *
-     * @return
+     * @return the namespace-qualified name as a string
      */
     public String getQualifiedName() {
         StringBuffer buf = new StringBuffer(prefix);
-        if (!prefix.equals(emptyString))
+        if (!prefix.equals(EMPTY_STRING))
             buf.append(':');
         buf.append(qName.getLocalPart());
         return buf.toString();
     }
 
     /**
-     * Method getURI
+     * Returns the URI of the namespace for the XML
+     * name that this <code>Name</code> object represents.
      *
-     * @return
+     * @return the URI as a string
      */
     public String getURI() {
         return qName.getNamespaceURI();
     }
 
     /**
-     * Method getPrefix
+     * Returns the prefix associated with the namespace for the XML
+     * name that this <code>Name</code> object represents.
      *
-     * @return
+     * @return the prefix as a string
      */
     public String getPrefix() {
         return prefix;
     }
 
-    /**
-     * Method equals
-     *
-     * @param obj
-     * @return
-     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -122,20 +120,10 @@
         return prefix.equals(((PrefixedQName) obj).prefix);
     }
 
-    /**
-     * Method hasCode
-     *
-     * @return
-     */
     public int hashCode() {
         return prefix.hashCode() + qName.hashCode();
     }
 
-    /**
-     * Method toString
-     *
-     * @return
-     */
     public String toString() {
         return qName.toString();
     }

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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -19,8 +19,7 @@
 
 import org.apache.axis2.om.impl.dom.ElementImpl;
 
-public class SOAPBodyElementImpl extends SOAPElementImpl implements
-		SOAPBodyElement {
+public class SOAPBodyElementImpl extends SOAPElementImpl implements SOAPBodyElement {
 
 	/**
 	 * @param 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=358784&r1=358783&r2=358784&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 Fri Dec 23 01:40:17 2005
@@ -15,96 +15,150 @@
  */
 package org.apache.axis2.saaj2;
 
-import java.util.Locale;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultImpl;
+import org.w3c.dom.Document;
 
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPBodyElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
-
-import org.apache.axis2.om.impl.dom.ElementImpl;
-import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultImpl;
-import org.w3c.dom.Document;
+import java.util.Locale;
 
 public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody {
 
     private org.apache.axis2.soap.SOAPBody omSOAPBody;
-    
-	/**
-	 * @param element
-	 */
-	public SOAPBodyImpl(org.apache.axis2.soap.SOAPBody omSOAPBody) {
-		super((ElementImpl)omSOAPBody);
-		this.omSOAPBody = omSOAPBody;
-	}
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#addFault()
-	 */
-	public SOAPFault addFault() throws SOAPException {
-		SOAP11FaultImpl fault = new SOAP11FaultImpl(omSOAPBody);
-		this.omSOAPBody.addFault(fault);
-		return new SOAPFaultImpl(fault);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#hasFault()
-	 */
-	public boolean hasFault() {
-		return this.omSOAPBody.hasFault();
-	}
+    /**
+     * @param omSOAPBody
+     */
+    public SOAPBodyImpl(org.apache.axis2.soap.SOAPBody omSOAPBody) {
+        super((ElementImpl) omSOAPBody);
+        this.omSOAPBody = omSOAPBody;
+    }
+
+    /**
+     * Creates a new <code>SOAPFault</code> object and adds it to
+     * this <code>SOAPBody</code> object.
+     *
+     * @return the new <code>SOAPFault</code> object
+     * @throws SOAPException if there is a SOAP error
+     */
+    public SOAPFault addFault() throws SOAPException {
+        SOAP11FaultImpl fault = new SOAP11FaultImpl(omSOAPBody);
+        omSOAPBody.addFault(fault);
+        return new SOAPFaultImpl(fault);
+    }
+
+    /**
+     * Indicates whether a <code>SOAPFault</code> object exists in
+     * this <code>SOAPBody</code> object.
+     *
+     * @return <code>true</code> if a <code>SOAPFault</code> object exists in
+     *         this <code>SOAPBody</code> object; <code>false</code>
+     *         otherwise
+     */
+    public boolean hasFault() {
+        return omSOAPBody.hasFault();
+    }
+
+    /**
+     * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+     * object.
+     *
+     * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+     *         object
+     */
+    public SOAPFault getFault() {
+        if (omSOAPBody.hasFault()) {
+            return new SOAPFaultImpl(omSOAPBody.getFault());
+        }
+        return null;
+    }
+
+    /**
+     * Creates a new <code>SOAPBodyElement</code> object with the
+     * specified name and adds it to this <code>SOAPBody</code> object.
+     *
+     * @param name a <code>Name</code> object with the name for the new
+     *             <code>SOAPBodyElement</code> object
+     * @return the new <code>SOAPBodyElement</code> object
+     * @throws SOAPException if a SOAP error occurs
+     */
+    public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
+        SOAPElementImpl elem = (SOAPElementImpl) addChildElement(name);
+        return new SOAPBodyElementImpl(elem.element);
+    }
+
+    /**
+     * Creates a new <code>SOAPFault</code> object and adds it to this
+     * <code>SOAPBody</code> object. The new <code>SOAPFault</code> will have a
+     * <code>faultcode</code> element that is set to the <code>faultCode</code>
+     * parameter and a <code>faultstring</code> set to <code>faultstring</code>
+     * and localized to <code>locale</code>.
+     *
+     * @param faultCode   a <code>Name</code> object giving the fault code to be
+     *                    set; must be one of the fault codes defined in the SOAP 1.1
+     *                    specification and of type QName
+     * @param faultString a <code>String</code> giving an explanation of the
+     *                    fault
+     * @param locale      a <code>Locale</code> object indicating the native language
+     *                    of the <ocde>faultString</code>
+     * @return the new <code>SOAPFault</code> object
+     * @throws SOAPException if there is a SOAP error
+     */
+    public SOAPFault addFault(Name faultCode, String faultString, Locale locale) throws SOAPException {
+        SOAP11FaultImpl fault = new SOAP11FaultImpl(omSOAPBody, new Exception(faultString));
+        SOAPFaultImpl faultImpl = new SOAPFaultImpl(fault);
+        faultImpl.setFaultCode(faultCode);
+        if (locale != null) {
+            faultImpl.setFaultString(faultString, locale);
+        } else {
+            faultImpl.setFaultString(faultString);
+        }
+
+        return faultImpl;
+    }
+
+    /**
+     * Creates a new <code>SOAPFault</code> object and adds it to this
+     * <code>SOAPBody</code> object. The new <code>SOAPFault</code> will have a
+     * <code>faultcode</code> element that is set to the <code>faultCode</code>
+     * parameter and a <code>faultstring</code> set to <code>faultstring</code>.
+     *
+     * @param faultCode   a <code>Name</code> object giving the fault code to be
+     *                    set; must be one of the fault codes defined in the SOAP 1.1
+     *                    specification and of type QName
+     * @param faultString a <code>String</code> giving an explanation of the
+     *                    fault
+     * @return the new <code>SOAPFault</code> object
+     * @throws SOAPException if there is a SOAP error
+     */
+    public SOAPFault addFault(Name faultCode, String faultString) throws SOAPException {
+        return addFault(faultCode, faultString, null);
+    }
+
+    /**
+     * Adds the root node of the DOM <code>Document</code> to this
+     * <code>SOAPBody</code> object.
+     * <p/>
+     * Calling this method invalidates the <code>document</code> parameter. The
+     * client application should discard all references to this
+     * <code>Document</code> and its contents upon calling
+     * <code>addDocument</code>. The behavior of an application that continues
+     * to use such references is undefined.
+     *
+     * @param document the <code>Document</code> object whose root node will be
+     *                 added to this <code>SOAPBody</code>
+     * @return the <code>SOAPBodyElement</code> that represents the root node
+     *         that was added
+     * @throws SOAPException if the <code>Document</code> cannot be added
+     */
+    public SOAPBodyElement addDocument(Document document) throws SOAPException {
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#getFault()
-	 */
-	public SOAPFault getFault() {
-		if(this.omSOAPBody.hasFault()) {
-			return new SOAPFaultImpl(this.omSOAPBody.getFault());
-		}
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#addBodyElement(javax.xml.soap.Name)
-	 */
-	public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
-		SOAPElementImpl elem = (SOAPElementImpl)this.addChildElement(name);
-		return new SOAPBodyElementImpl(elem.element);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String, java.util.Locale)
-	 */
-	public SOAPFault addFault(Name faultCode, String faultString, Locale locale) throws SOAPException {
-		SOAP11FaultImpl fault = new SOAP11FaultImpl(this.omSOAPBody, new Exception(faultString));
-		SOAPFaultImpl faultImpl = new SOAPFaultImpl(fault);
-		faultImpl.setFaultCode(faultCode);
-		if(locale != null) {
-			faultImpl.setFaultString(faultString, locale);
-		} else {
-			faultImpl.setFaultString(faultString);
-		}
-		
-		return faultImpl;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String)
-	 */
-	public SOAPFault addFault(Name faultCode, String faultString) throws SOAPException {
-		return this.addFault(faultCode, faultString, null);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPBody#addDocument(org.w3c.dom.Document)
-	 */
-	public SOAPBodyElement addDocument(Document document) throws SOAPException {
-		
-		SOAPElementImpl elem = new SOAPElementImpl((ElementImpl)document.getDocumentElement());
-		return new SOAPBodyElementImpl(elem.element);
+        SOAPElementImpl elem = new SOAPElementImpl((ElementImpl) document.getDocumentElement());
+        return new SOAPBodyElementImpl(elem.element);
 		
 	}
-
-
 }

Added: 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=358784&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionFactoryImpl.java Fri Dec 23 01:40:17 2005
@@ -0,0 +1,36 @@
+/*                                                                             
+ * 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;
+
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+
+/**
+ * 
+ */
+public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
+    /**
+     * Create a new <CODE>SOAPConnection</CODE>.
+     *
+     * @return the new <CODE>SOAPConnection</CODE> object.
+     * @throws javax.xml.soap.SOAPException if there was an exception
+     *                                      creating the <CODE>SOAPConnection</CODE> object.
+     */
+    public SOAPConnection createConnection() throws SOAPException {
+        return new SOAPConnectionImpl();
+    }
+}

Added: 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=358784&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPConnectionImpl.java Fri Dec 23 01:40:17 2005
@@ -0,0 +1,216 @@
+/*                                                                             
+ * 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;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Call;
+import org.apache.axis2.client.Options;
+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.ElementImpl;
+import org.apache.axis2.util.SessionUtils;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+/**
+ * 
+ */
+public class SOAPConnectionImpl extends SOAPConnection {
+    /**
+     * Sends the given message to the specified endpoint and
+     * blocks until it has returned the response.
+     *
+     * @param request  the <CODE>SOAPMessage</CODE>
+     *                 object to be sent
+     * @param endpoint an <code>Object</code> that identifies
+     *                 where the message should be sent. It is required to
+     *                 support Objects of type
+     *                 <code>java.lang.String</code>,
+     *                 <code>java.net.URL</code>, and when JAXM is present
+     *                 <code>javax.xml.messaging.URLEndpoint</code>
+     * @return the <CODE>SOAPMessage</CODE> object that is the
+     *         response to the message that was sent
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public SOAPMessage call(SOAPMessage request, Object endpoint) throws SOAPException {
+        try {
+            OMElement envelope =
+                    ((SOAPEnvelopeImpl) request.getSOAPPart().getEnvelope()).getOMEnvelope();
+
+            //parse the omEnvelope element and stuff it with the attachment
+            //specific omText nodes
+            insertAttachmentNodes(envelope, request);
+
+            Call call = new Call();
+            URL url = new URL(endpoint.toString());
+
+            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);
+
+            SOAPMessageImpl sMsg = new SOAPMessageImpl(response);
+            extractAttachmentNodes(responseEnv, sMsg);
+            return sMsg;
+
+        } catch (MalformedURLException mue) {
+            throw new SOAPException(mue);
+        } catch (AxisFault af) {
+            throw new SOAPException(af);
+        }
+    }
+
+    /**
+     * Closes this <CODE>SOAPConnection</CODE> object.
+     *
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public void close() throws SOAPException {
+        //TODO: Method implementation
+
+    }
+
+    /**
+     * 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 soapMsg
+     */
+    private void insertAttachmentNodes(OMElement element, SOAPMessage soapMsg) throws SOAPException {
+        Iterator childIter = element.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);
+                child.build();
+                child.removeAttribute(hrefAttr);
+                child.addChild(omText);
+
+            } else { //possibly there can be references in the children of this element
+                //so recurse through.
+                insertAttachmentNodes(child, soapMsg);
+            }
+        }
+    }
+
+    /**
+     * The method recursively looks for the binary text nodes and adds them as attachment
+     * to soapMessage at the same time removing them from soapEnv and putting appropriate
+     * contentId
+     *
+     * @param element
+     * @param soapMsg
+     */
+    private void extractAttachmentNodes(OMElement element, SOAPMessage soapMsg) {
+        Iterator childIter = element.getChildren();
+        while (childIter.hasNext()) {
+            OMNode child = (OMNode) childIter.next();
+            if (child instanceof OMText) {
+                OMText binaryNode = (OMText) child;
+                DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
+                if (actualDH != null) {
+                    AttachmentPart ap = soapMsg.createAttachmentPart(actualDH);
+                    String contentId = SessionUtils.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);
+                    parent.addAttribute(attr);
+                    binaryNode.detach();
+                    soapMsg.addAttachmentPart(ap);
+                }
+            } else {
+                if (child instanceof OMElement) {
+                    OMElement childElement = (OMElement) child;
+                    extractAttachmentNodes(childElement, soapMsg);
+                }
+            }
+        }
+    }
+
+    /**
+     * This method checks the value of attribute and if it is a valid CID then
+     * returns the contentID (with cid: prefix stripped off) or else returns null.
+     * A null return value can be assumed that this attribute is not an attachment
+     * referencing attribute
+     */
+    private String validateHref(OMAttribute attr) {
+        String contentId;
+        if (attr != null) {
+            contentId = attr.getAttributeValue();
+        } else {
+            return null;
+        }
+
+        if (contentId.startsWith("cid:")) {
+            contentId = contentId.substring(4);
+            return contentId;
+        }
+        return null;
+    }
+
+    /**
+     * This method looks up the attachment part corresponding to the given contentId and
+     * returns the OMText node thta has the content of the attachment.
+     *
+     * @param contentId
+     * @param soapMsg
+     * @return OMText
+     */
+    private OMText getOMTextForReferencedAttachment(String contentId, SOAPMessage soapMsg) throws SOAPException {
+        Iterator attachIter = soapMsg.getAttachments();
+        while (attachIter.hasNext()) {
+            AttachmentPart attachment = (AttachmentPart) attachIter.next();
+            if (attachment.getContentId().equals(contentId)) {
+                try {
+                    return ((AttachmentPartImpl) attachment).getOMText();
+                } catch (Exception e) {
+                    throw new SOAPException(e);
+                }
+            }
+        }
+        throw new SOAPException("No attachment found with the given contentID");
+    }
+}