axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r513354 [1/2] - in /webservices/axis2/trunk/java/modules: saaj-api/src/javax/xml/soap/ saaj/src/org/apache/axis2/saaj/ saaj/test/org/apache/axis2/saaj/
Date Thu, 01 Mar 2007 14:49:46 GMT
Author: dims
Date: Thu Mar  1 06:49:44 2007
New Revision: 513354

URL: http://svn.apache.org/viewvc?view=rev&rev=513354
Log:
Fix for AXIS2-1956 - SAAJ 1.3 implementation (Removed implementation code from saap-api module. fixed Base64 check.Code clean up.)

Modified:
    webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/MessageFactory.java
    webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SAAJResult.java
    webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java
    webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SAAJMetaFactoryImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPEnvelopeTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPFactoryTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java

Modified: webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/MessageFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/MessageFactory.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/MessageFactory.java (original)
+++ webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/MessageFactory.java Thu Mar  1 06:49:44 2007
@@ -17,8 +17,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
 
 /**
  * <P>A factory for creating <CODE>SOAPMessage</CODE> objects.</P>
@@ -172,28 +170,8 @@
 
     public static MessageFactory newInstance(String soapVersion)
             throws SOAPException {
-    	
-    	if(!(SOAPConstants.SOAP_1_1_PROTOCOL.equals(soapVersion) ||
-    			SOAPConstants.SOAP_1_2_PROTOCOL.equals(soapVersion) ||
-    				SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(soapVersion))){
-    		throw new SOAPException("Invalid SOAP Protocol Version");
-    	}
-    	
-        MessageFactory factory = newInstance();
-        if(factory.getClass().getName().equals(DEFAULT_MESSAGE_FACTORY)){
-            try {
-                Method m = factory.getClass().getMethod("setSOAPVersion", new Class[]{String.class});
-                m.invoke(factory, new Object[]{soapVersion});
-            } catch (IllegalAccessException e) {
-                throw new SOAPException(e);
-            } catch (InvocationTargetException e) {
-                throw new SOAPException(e);
-            } catch (NoSuchMethodException e) {
-                throw new SOAPException(e);
-            }
-        }
-        return factory;
-    }
+        return SAAJMetaFactory.getInstance().newMessageFactory(soapVersion);
+    }        
 
     private static final String DEFAULT_MESSAGE_FACTORY =
             "org.apache.axis2.saaj.MessageFactoryImpl";

Modified: webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SAAJResult.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SAAJResult.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SAAJResult.java (original)
+++ webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SAAJResult.java Thu Mar  1 06:49:44 2007
@@ -1,61 +1,59 @@
-/*
- * 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 javax.xml.soap;
-
-import javax.xml.transform.dom.DOMResult;
-
-public class SAAJResult extends DOMResult {
-
-    public SAAJResult()
-            throws SOAPException {
-        this(MessageFactory.newInstance().createMessage());
-        org.w3c.dom.Node node = this.getNode();
-        node.removeChild(node.getFirstChild());
-        this.setNode(null);
-    }
-
-    public SAAJResult(String s)
-            throws SOAPException {
-        this(MessageFactory.newInstance(s).createMessage());
-    }
-
-    public SAAJResult(SOAPMessage soapmessage) {
-        super(soapmessage.getSOAPPart());
-    }
-
-    public SAAJResult(SOAPElement soapelement) {
-        super(soapelement);
-    }
-
-    public javax.xml.soap.Node getResult() {
-        org.w3c.dom.Node node = super.getNode();
-        //When using SAAJResult saajResult = new SAAJResult();
-        if (node == null){
-        	return null;
-        }
-        if(node instanceof SOAPPart){
-            try {
-                return ((SOAPPart)node).getEnvelope();
-            } catch (SOAPException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return (javax.xml.soap.Node) node.getFirstChild();
-    }
-
-    
-}
+/*
+ * 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 javax.xml.soap;
+
+import javax.xml.transform.dom.DOMResult;
+
+public class SAAJResult extends DOMResult {
+
+    public SAAJResult()
+            throws SOAPException {
+        this(MessageFactory.newInstance().createMessage());
+        org.w3c.dom.Node node = this.getNode();
+        node.removeChild(node.getFirstChild());
+        this.setNode(null);
+    }
+
+    public SAAJResult(String s)
+            throws SOAPException {
+        this(MessageFactory.newInstance(s).createMessage());
+    }
+
+    public SAAJResult(SOAPMessage soapmessage) {
+        super(soapmessage.getSOAPPart());
+    }
+
+    public SAAJResult(SOAPElement soapelement) {
+        super(soapelement);
+    }
+
+    public javax.xml.soap.Node getResult() {
+        org.w3c.dom.Node node = super.getNode();
+        //When using SAAJResult saajResult = new SAAJResult();
+        if (node == null){
+        	return null;
+        }
+        if(node instanceof SOAPPart){
+            try {
+                return ((SOAPPart)node).getEnvelope();
+            } catch (SOAPException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return (javax.xml.soap.Node) node.getFirstChild();
+    }
+}

Modified: webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java (original)
+++ webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java Thu Mar  1 06:49:44 2007
@@ -15,11 +15,6 @@
  */
 package javax.xml.soap;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
 /**
  * A point-to-point connection that a client can use for sending messages
  * directly to a remote party (represented by a URL, for instance).
@@ -73,26 +68,8 @@
      * @return the SOAPMessage object that is the response to the get message request
      * @throws SOAPException - if there is a SOAP error
      */
-    public SOAPMessage get(Object to)
+    public SOAPMessage get(Object obj)
             throws SOAPException {
-    	URL url = null;
-    	try 
-    	{
-    		url = (to instanceof URL) ? (URL) to : new URL(to.toString());
-    		if(url != null){
-    			//InputStream in = url.openStream();
-    			//TODO : setting null for mime headers
-    			// close the connection??
-    			SOAPMessage soapMessage = null;
-    			//new SOAPMessageImpl(in,null);
-    			return soapMessage;
-    		}
-    		return null;
-    	}catch (MalformedURLException e) {
-    		throw new SOAPException(e);
-    	}catch (IOException e) {
-    		throw new SOAPException(e);
-    	}    	
-    	
+        throw new UnsupportedOperationException();
     }
 }

Modified: webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java (original)
+++ webservices/axis2/trunk/java/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java Thu Mar  1 06:49:44 2007
@@ -160,21 +160,10 @@
      * @throws SOAPException - if there is an error creating the specified SOAPFactory
      * @see <CODE>SAAJMetaFactory</CODE>
      */
-    public static SOAPFactory newInstance(String protocol) throws SOAPException {
-        try {
-        	if(SOAPConstants.DEFAULT_SOAP_PROTOCOL.equals(protocol) 
-        			|| SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)
-        			|| SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)){
-        		SAAJMetaFactory saajMetaFactory = SAAJMetaFactory.getInstance();
-        		return saajMetaFactory.newSOAPFactory(protocol);
-        	}else{
-        		throw new SOAPException("Unknown protocol :"+protocol);
-        	}
-        } catch (Exception exception) {
-            throw new SOAPException("Unable to create SOAP Factory: "
-                    + exception.getMessage());
-        }
+    public static SOAPFactory newInstance(String s) throws SOAPException {
+        return SAAJMetaFactory.getInstance().newSOAPFactory(s);
     }
+
 
     /**
      * Creates a SOAPElement object from an existing DOM Element. If the DOM Element that is

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java Thu Mar  1 06:49:44 2007
@@ -16,15 +16,14 @@
 package org.apache.axis2.saaj;
 
 import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringReader;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
 import java.util.Iterator;
 
 import javax.activation.DataHandler;
-import javax.activation.UnsupportedDataTypeException;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MimeHeader;
 import javax.xml.soap.MimeHeaders;
@@ -35,6 +34,7 @@
 import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axiom.om.util.Base64;
 import org.apache.axis2.saaj.util.SAAJDataSource;
 import org.apache.axis2.transport.http.HTTPConstants;
 
@@ -164,29 +164,24 @@
         }
         try {
             String contentType = dataHandler.getContentType();
-           	if (contentType.equals("text/xml")) {
-           		StringReader stringReader = new StringReader((String)dataHandler.getContent());
-            	StreamSource streamSource = new StreamSource(stringReader);
+           	if (contentType.equals(HTTPConstants.MEDIA_TYPE_TEXT_XML) || contentType.equals(HTTPConstants.MEDIA_TYPE_APPLICATION_XML)) {
+            	StreamSource streamSource = new StreamSource();
    	        	streamSource.setInputStream(dataHandler.getInputStream());
             	return streamSource;
-            	
-                //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 if(contentType.equals("text/plain") ||
             			contentType.equals("text/html")){
             	return (String)dataHandler.getContent();
             }else {
                 try {
-                    return dataHandler.getContent();
-                } catch (UnsupportedDataTypeException e) {
+                	return dataHandler.getContent();
+                } catch (Exception e) {
                     //If the underlying DataContentHandler can't handle the object contents,
-                    //we will return an inputstream of raw bytes represneting the content data
+                    //we will return an inputstream of raw bytes representing the content data
                     return dataHandler.getDataSource().getInputStream();
                 }
             }
         } catch (IOException e) {
-            throw new SOAPException(e);
+            throw new SOAPException(e.getMessage());
         }
     }
 
@@ -221,7 +216,7 @@
                         SAAJDataSource.MAX_MEMORY_DISK_CACHED,
                         contentType, true);
                 extractFilename(source);
-                dataHandler = new DataHandler(source);
+                this.dataHandler = new DataHandler(source);
                 contentObject = object;
             } catch (java.io.IOException io) {
                 throw new java.lang.IllegalArgumentException("Illegal Argument");
@@ -233,7 +228,7 @@
                         SAAJDataSource.MIN_MEMORY_DISK_CACHED,
                         contentType, true);
                 extractFilename(source);
-                dataHandler = new DataHandler(source);
+                this.dataHandler = new DataHandler(source);
                 contentObject = null; // the stream has been consumed
             } catch (java.io.IOException io) {
                 throw new java.lang.IllegalArgumentException("Illegal Argument");
@@ -244,17 +239,17 @@
                         SAAJDataSource.MAX_MEMORY_DISK_CACHED,
                         contentType, true);
                 extractFilename(source);
-                dataHandler = new DataHandler(source);
+                this.dataHandler = new DataHandler(source);
                 contentObject = null; // the stream has been consumed
             } catch (java.io.IOException io) {
                 throw new java.lang.IllegalArgumentException("Illegal Argument");
             }
         }else if (object instanceof BufferedImage) {
             try {
-                dataHandler = new DataHandler(object,contentType);
+            	this.dataHandler = new DataHandler(object,contentType);
                 contentObject = null; // the stream has been consumed
             } catch (Exception e) {
-            	throw new java.lang.IllegalArgumentException(e);
+            	throw new java.lang.IllegalArgumentException(e.getMessage());
             }
         }
         else if (object instanceof byte[]) {
@@ -266,10 +261,10 @@
                         contentType, true);
                 extractFilename(source);
                 
-                dataHandler = new DataHandler(source);
+                this.dataHandler = new DataHandler(source);
                 contentObject = object;
             } catch (Exception e) {
-            	throw new java.lang.IllegalArgumentException(e);
+            	throw new java.lang.IllegalArgumentException(e.getMessage());
             }
         }
         else {
@@ -317,7 +312,7 @@
         if (datahandler != null) {
             this.dataHandler = datahandler;
             setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, datahandler.getContentType());
-            omText = DOOMAbstractFactory.getOMFactory().createOMText(dataHandler, true);
+            omText = DOOMAbstractFactory.getOMFactory().createOMText(datahandler, true);
         } else {
             throw new IllegalArgumentException("Cannot set null DataHandler");
         }
@@ -514,8 +509,16 @@
     		throw new SOAPException("Content is null");
     	}
     	try {
-    		if(isValidBase64Encoding(content)){
-    			setContent(content, contentType);		
+    		int size = content.available();
+    		PushbackInputStream pushbackInputStream;
+    		if(size > 0){
+    			pushbackInputStream = new PushbackInputStream(content,size);
+    		}else{
+    			pushbackInputStream = new PushbackInputStream(content);
+    		}
+    		
+    		if(isValidBase64Encoding(pushbackInputStream)){
+    			setContent(pushbackInputStream, contentType);		
     		}else{
     			throw new SOAPException("Not a valid Base64 encoding");
     		}
@@ -527,20 +530,26 @@
     /*
      * check if the given InputStream contains valid Base64 Encoding
      */
-    private boolean isValidBase64Encoding (InputStream content) {
-    	//TODO need to add more checks
+    private boolean isValidBase64Encoding (PushbackInputStream pushbackInputStream) {
     	int size;
-		try {
-			size = content.available();
-	    	if (size%4 != 0){
-	    		//Length of Base64 encoded input string is not a multiple of 4
-	    		return false;
-	    	}else{
-	    		return true;
-	    	}
-		} catch (IOException e) {
-			return false;
-		}
+    	try {
+    		size = pushbackInputStream.available();
+    		if(size == 0){
+    			return true;
+    		}
+    		byte[] buffer = new byte[size];
+    		int read = pushbackInputStream.read(buffer, 0, size);
+    		
+    		OutputStream outputStream = new ByteArrayOutputStream();  		
+    		outputStream.write(buffer);
+    		String contentString = outputStream.toString();			
+    		outputStream.close();
+    		pushbackInputStream.unread(buffer,0,read);
+    		
+    		return Base64.isValidBase64Encoding(contentString);
+    	} catch (Exception e) {
+    		return false;
+    	}
     }
     
     /**
@@ -555,9 +564,7 @@
      *         
      */
     public void setRawContent(InputStream content, String contentType) throws SOAPException {
-    	//TODO check
     	if(content == null){
-    		//throw new NullPointerException("content is null"); 
     		throw new SOAPException("content is null");
     	}
     	setContent(content, contentType);
@@ -630,8 +637,6 @@
     }
 
     private void extractFilename(SAAJDataSource source) {
-
-        //check for there being a file
         if (source.getDiskCacheFile() != null) {
             String path = source.getDiskCacheFile().getAbsolutePath();
             setAttachmentFile(path);

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java Thu Mar  1 06:49:44 2007
@@ -39,47 +39,38 @@
     }
 
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
-    	//TODO - check
     	return super.addAttribute(qname, value);
     }
 
     public SOAPElement addChildElement(QName qname) throws SOAPException {
-    	//TODO - check
     	return super.addChildElement(qname);
     }
 
     public QName createQName(String localName, String prefix) throws SOAPException {
-    	//TODO - check
     	return super.createQName(localName, prefix);
     }
 
     public Iterator getAllAttributesAsQNames() {
-    	//TODO - check
     	return super.getAllAttributesAsQNames();
     }
 
     public String getAttributeValue(QName qname) {
-    	//TODO - check
     	return super.getAttributeValue(qname);
     }
 
     public Iterator getChildElements(QName qname) {
-    	//TODO - check
     	return super.getChildElements(qname);
     }
 
     public QName getElementQName() {
-    	//TODO - check
     	return super.getElementQName();
     }
 
     public boolean removeAttribute(QName qname) {
-    	//TODO - check
     	return super.removeAttribute(qname);
     }
 
     public SOAPElement setElementQName(QName newName) throws SOAPException {
-    	//TODO - check
     	return super.setElementQName(newName);
     }
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java Thu Mar  1 06:49:44 2007
@@ -113,47 +113,38 @@
     }
 
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
-    	//TODO - check
     	return super.addAttribute(qname, value);
     }
 
     public SOAPElement addChildElement(QName qname) throws SOAPException {
-    	//TODO - check
     	return super.addChildElement(qname);
     }
 
     public QName createQName(String localName, String prefix) throws SOAPException {
-    	//TODO - check
     	return super.createQName(localName, prefix);
     }
 
     public Iterator getAllAttributesAsQNames() {
-    	//TODO - check
     	return super.getAllAttributesAsQNames();
     }
 
     public String getAttributeValue(QName qname) {
-    	//TODO - check
         return super.getAttributeValue(qname);
     }
 
     public Iterator getChildElements(QName qname) {
-    	//TODO - check
         return super.getChildElements(qname);
     }
 
     public QName getElementQName() {
-    	//TODO - check
     	return super.getElementQName();
     }
 
     public boolean removeAttribute(QName qname) {
-    	//TODO - check
     	return super.removeAttribute(qname);
     }
 
     public SOAPElement setElementQName(QName newName) throws SOAPException {
-    	//TODO - check
     	return super.setElementQName(newName);
     }
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java Thu Mar  1 06:49:44 2007
@@ -15,18 +15,17 @@
  */
 package org.apache.axis2.saaj;
 
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
-import org.apache.axis2.saaj.util.IDGenerator;
+import java.io.IOException;
+import java.io.InputStream;
 
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPConstants;
 
-import java.io.IOException;
-import java.io.InputStream;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
 
 /**
  * <P>A factory for creating <CODE>SOAPMessage</CODE> objects.</P>
@@ -137,7 +136,8 @@
                     new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)
                             new SOAP12Factory().getDefaultEnvelope());
         }else if(soapVersion.equals(SOAPConstants.DYNAMIC_SOAP_PROTOCOL)){
-        	throw new UnsupportedOperationException("createMessage() is not supported for DYNAMIC_SOAP_PROTOCOL");
+        	throw new UnsupportedOperationException("createMessage() is not supported for " +
+        			"DYNAMIC_SOAP_PROTOCOL");
         }else {
         	//SOAP 1.1
             soapEnvelope =

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SAAJMetaFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SAAJMetaFactoryImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SAAJMetaFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SAAJMetaFactoryImpl.java Thu Mar  1 06:49:44 2007
@@ -1,20 +1,31 @@
-package org.apache.axis2.saaj;
-
-import javax.xml.soap.SAAJMetaFactory;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
-
-public class SAAJMetaFactoryImpl extends SAAJMetaFactory {
-    protected MessageFactory newMessageFactory(String s) throws SOAPException {
-        MessageFactoryImpl factory = new  MessageFactoryImpl();
-        factory.setSOAPVersion(s);
-        return factory;
-    }
-
-    protected SOAPFactory newSOAPFactory(String s) throws SOAPException {
-        SOAPFactoryImpl factory = new SOAPFactoryImpl();
-        factory.setSOAPVersion(s);
-        return factory;
-    }
-}
+package org.apache.axis2.saaj;
+
+import javax.xml.soap.SAAJMetaFactory;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+
+public class SAAJMetaFactoryImpl extends SAAJMetaFactory {
+    protected MessageFactory newMessageFactory(String soapVersion) throws SOAPException {
+    	if(!(SOAPConstants.SOAP_1_1_PROTOCOL.equals(soapVersion) ||
+    			SOAPConstants.SOAP_1_2_PROTOCOL.equals(soapVersion) ||
+    				SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(soapVersion))){
+    		throw new SOAPException("Invalid SOAP Protocol Version");
+    	}    	
+        MessageFactoryImpl factory = new  MessageFactoryImpl();
+        factory.setSOAPVersion(soapVersion);
+        return factory;
+    }
+
+    protected SOAPFactory newSOAPFactory(String soapVersion) throws SOAPException {
+    	if(!(SOAPConstants.SOAP_1_1_PROTOCOL.equals(soapVersion) ||
+    			SOAPConstants.SOAP_1_2_PROTOCOL.equals(soapVersion) ||
+    				SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(soapVersion))){
+    		throw new SOAPException("Invalid SOAP Protocol Version");
+    	}    	
+        SOAPFactoryImpl factory = new SOAPFactoryImpl();
+        factory.setSOAPVersion(soapVersion);
+        return factory;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java Thu Mar  1 06:49:44 2007
@@ -42,47 +42,38 @@
     }
 
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
-    	//TODO - check
     	return super.addAttribute(qname, value);
     }
 
     public SOAPElement addChildElement(QName qname) throws SOAPException {
-    	//TODO - check
     	return super.addChildElement(qname);
     }
 
     public QName createQName(String localName, String prefix) throws SOAPException {
-    	//TODO - check
     	return super.createQName(localName, prefix);
     }
 
     public Iterator getAllAttributesAsQNames() {
-    	//TODO - check
     	return super.getAllAttributesAsQNames();
     }
 
     public String getAttributeValue(QName qname) {
-    	//TODO - check
     	return super.getAttributeValue(qname);
     }
 
     public Iterator getChildElements(QName qname) {
-    	//TODO - check
     	return super.getChildElements(qname);
     }
 
     public QName getElementQName() {
-    	//TODO - check
     	return super.getElementQName();
     }
 
     public boolean removeAttribute(QName qname) {
-    	//TODO - check
     	return super.removeAttribute(qname);
     }
 
     public SOAPElement setElementQName(QName newName) throws SOAPException {
-    	//TODO - check
     	return super.setElementQName(newName);
     }
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java Thu Mar  1 06:49:44 2007
@@ -28,7 +28,6 @@
 import javax.xml.soap.Node;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPBodyElement;
-import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
@@ -39,16 +38,11 @@
 import org.apache.axiom.om.impl.dom.ElementImpl;
 import org.apache.axiom.om.impl.dom.NamespaceImpl;
 import org.apache.axiom.om.impl.dom.NodeImpl;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl;
-import org.apache.axis2.namespace.Constants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -169,17 +163,12 @@
         if (isBodyElementAdded) {
             throw new SOAPException("A SOAPBodyElement has been already added to this SOAPBody");
         }
-        //TODO : check, added soap version check
-        OMNamespace omNamespace = omSOAPBody.getNamespace();
         SOAPFaultImpl saajSOAPFault = null;
 
-        if (omNamespace.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI) &&
-            omNamespace.getPrefix().equals(SOAP11Constants.SOAP_DEFAULT_NAMESPACE_PREFIX)) {
+        if(this.element.getOMFactory() instanceof SOAP11Factory){
             SOAP11FaultImpl fault = new SOAP11FaultImpl(omSOAPBody, (SOAPFactory) this.element.getOMFactory());
             saajSOAPFault = new SOAPFaultImpl(fault);
-        } else
-        if (omNamespace.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI) &&
-            omNamespace.getPrefix().equals(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX)) {
+        }else if (this.element.getOMFactory() instanceof SOAP12Factory){
             SOAP12FaultImpl fault = new SOAP12FaultImpl(omSOAPBody, (SOAPFactory) this.element.getOMFactory());
             saajSOAPFault = new SOAPFaultImpl(fault);
         }
@@ -244,24 +233,25 @@
      * @throws SOAPException if there is a SOAP error
      */
     public SOAPFault addFault(Name faultCode, String faultString, Locale locale)
-            throws SOAPException {
-        org.apache.axiom.soap.SOAPFault fault;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            fault = new SOAP11FaultImpl(omSOAPBody, new Exception(
-                    faultString), (SOAPFactory) this.element.getOMFactory());
-        } else {
-            fault = new SOAP12FaultImpl(omSOAPBody, new Exception(
-                    faultString), (SOAPFactory) this.element.getOMFactory());
-        }
-        SOAPFaultImpl faultImpl = new SOAPFaultImpl(fault);
-        faultImpl.setFaultCode(faultCode);
-        if (locale != null) {
-            faultImpl.setFaultString(faultString, locale);
-        } else {
-            faultImpl.setFaultString(faultString);
-        }
+    		throws SOAPException {
+    	org.apache.axiom.soap.SOAPFault fault;
+    	if (this.element.getOMFactory() instanceof SOAP11Factory) {
+    		fault = new SOAP11FaultImpl(omSOAPBody, new Exception(
+    				faultString), (SOAPFactory) this.element.getOMFactory());
+    	}else{
+    		fault = new SOAP12FaultImpl(omSOAPBody, new Exception(
+    				faultString), (SOAPFactory) this.element.getOMFactory());
+    	}
+    	SOAPFaultImpl faultImpl = new SOAPFaultImpl(fault);
+    	faultImpl.setFaultCode(faultCode);
+    	
+    	if(locale != null) {
+    		faultImpl.setFaultString(faultString, locale);
+    	}else{
+    		faultImpl.setFaultString(faultString);
+    	}
 
-        return faultImpl;
+    	return faultImpl;
     }
 
     /**
@@ -318,7 +308,6 @@
      * @throws SOAPException if a SOAP error occurs
      */
     public SOAPBodyElement addBodyElement(QName qname) throws SOAPException {
-        //TODO : check
         return (SOAPBodyElement) addChildElement(qname);
     }
 
@@ -344,14 +333,13 @@
      */
     public SOAPFault addFault(QName faultCode, String faultString, Locale locale)
             throws SOAPException {
-        //TODO : check
         SOAPFaultImpl faultImpl = null;
 
-        if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))) {
+        if(this.element.getOMFactory() instanceof SOAP11Factory){
             SOAP11FaultImpl fault = new SOAP11FaultImpl(omSOAPBody, new Exception(
                     faultString), (SOAPFactory) this.element.getOMFactory());
             faultImpl = new SOAPFaultImpl(fault);
-        } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))) {
+        }else if(this.element.getOMFactory() instanceof SOAP12Factory){
             SOAP12FaultImpl fault = new SOAP12FaultImpl(omSOAPBody, new Exception(
                     faultString), (SOAPFactory) this.element.getOMFactory());
             faultImpl = new SOAPFaultImpl(fault);
@@ -376,7 +364,6 @@
      * @throws SOAPException - if there is not exactly one child SOAPElement of the SOAPBody.
      */
     public Document extractContentAsDocument() throws SOAPException {
-        //TODO - check
         Iterator childElements = this.getChildElements();
         org.w3c.dom.Node domNode = null;
         int childCount = 0;
@@ -398,15 +385,10 @@
         try {
             DocumentBuilder builder = factory.newDocumentBuilder();
             document = builder.newDocument();
-            //Element element = document.createElement(domNode.getLocalName());
-            //TODO: WIP
-            //element.setAttribute(domNode.getNodeName(), domNode.getNodeValue());
             Element element = document.createElementNS(domNode.getNamespaceURI(), domNode.getLocalName());
             element.setNodeValue(domNode.getNodeValue());
             document.appendChild(element);
-
-
-        } catch (ParserConfigurationException e) {
+        }catch (ParserConfigurationException e){
             throw new SOAPException(e);
         }
         return document;
@@ -431,7 +413,6 @@
         String localname;
         if (indexOfColon != -1) {
             localname = domEle.getTagName().substring(indexOfColon + 1);
-
             ns = new NamespaceImpl(domEle.getNamespaceURI(),
                                    domEle.getTagName().substring(0, indexOfColon));
         } else {
@@ -481,13 +462,12 @@
     }
 
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
-        //TODO - check
         OMNamespace omNamespace = null;
         SOAPFactory soapFactory;
-        if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))) {
+        if (this.element.getOMFactory() instanceof SOAP11Factory) {
             soapFactory = new SOAP11Factory();
             omNamespace = soapFactory.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
-        } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))) {
+        }else if (this.element.getOMFactory() instanceof SOAP12Factory) {
             soapFactory = new SOAP12Factory();
             omNamespace = soapFactory.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
         }
@@ -496,7 +476,6 @@
     }
 
     public SOAPElement addChildElement(QName qname) throws SOAPException {
-        //TODO - check
         if (omSOAPBody.hasFault()) {
             throw new SOAPException("A SOAPFault has been already added to this SOAPBody");
         }
@@ -507,10 +486,12 @@
         } else {
             childEle = new SOAPBodyElementImpl(
                     (ElementImpl) getOwnerDocument().createElementNS(qname.getNamespaceURI(),
-                                                                     qname.getPrefix() + ":" + qname.getLocalPart()));
+                    		qname.getPrefix() + ":" + qname.getLocalPart()));
         }
         childEle.element.setUserData(SAAJ_NODE, childEle, null);
-        childEle.element.setNamespace(childEle.element.declareNamespace(qname.getNamespaceURI(), qname.getPrefix()));
+        childEle.element.setNamespace(childEle.element.declareNamespace(
+        		qname.getNamespaceURI(), qname.getPrefix()));
+
         element.appendChild(childEle.element);
         ((NodeImpl) childEle.element.getParentNode()).setUserData(SAAJ_NODE, this, null);
         isBodyElementAdded = true;
@@ -519,50 +500,41 @@
     }
 
     public QName createQName(String localName, String prefix) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-        	return super.createQName(localName, prefix);
-        }
-        else if(this.element.getOMFactory() instanceof SOAP12Factory) {
-        {
-        	if(this.element.findNamespaceURI(prefix) == null){
-        		throw new SOAPException("Only Namespace Qualified elements are allowed");
-        	}else{
-        		return super.createQName(localName, prefix);
-        	}
-        }
-        }else{
-        	throw new UnsupportedOperationException();
-        }
+    	if (this.element.getOMFactory() instanceof SOAP11Factory) {
+    		return super.createQName(localName, prefix);
+    	}else if(this.element.getOMFactory() instanceof SOAP12Factory) {
+    		if(this.element.findNamespaceURI(prefix) == null){
+    			throw new SOAPException("Only Namespace Qualified elements are allowed");
+    		}else{
+    			return super.createQName(localName, prefix);
+    		}
+    	}else{
+    		throw new UnsupportedOperationException();
+    	}
     }
 
 
     public Iterator getAllAttributesAsQNames() {
-        //TODO : check
         return super.getAllAttributesAsQNames();
     }
 
     public String getAttributeValue(QName qname) {
-        //TODO : check
         return super.getAttributeValue(qname);
     }
 
     public Iterator getChildElements(QName qname) {
-        //TODO : check
         return super.getChildElements(qname);
     }
 
     public QName getElementQName() {
-        //TODO : check
         return super.getElementQName();
     }
 
     public boolean removeAttribute(QName qname) {
-        //TODO : check
         return super.removeAttribute(qname);
     }
 
     public SOAPElement setElementQName(QName qname) throws SOAPException {
-        //TODO : check
         return super.setElementQName(qname);
     }
 

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java Thu Mar  1 06:49:44 2007
@@ -17,6 +17,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Collection;
@@ -24,11 +25,13 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringTokenizer;
 
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPConnection;
 import javax.xml.soap.SOAPElement;
@@ -40,7 +43,6 @@
 
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.impl.llom.OMTextImpl;
@@ -54,8 +56,7 @@
 import org.apache.axis2.saaj.util.IDGenerator;
 import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
 
 /**
  *
@@ -70,7 +71,7 @@
     private ServiceClient serviceClient;
     private HashMap unaccessedAttachments = new HashMap();
 
-	private static final Log log = LogFactory.getLog(SOAPConnectionImpl.class);
+
 
     /**
      * Sends the given message to the specified endpoint and
@@ -90,7 +91,6 @@
      *                                      or this SOAPConnection is already closed
      */
     public SOAPMessage call(SOAPMessage request, Object endpoint) throws SOAPException {
-
         if (closed) {
             throw new SOAPException("SOAPConnection closed");
         }
@@ -100,7 +100,7 @@
         try {
             url = (endpoint instanceof URL) ? (URL) endpoint : new URL(endpoint.toString());
         } catch (MalformedURLException e) {
-            throw new SOAPException(e);
+            throw new SOAPException(e.getMessage());
         }
 
         // initialize and set Options
@@ -156,10 +156,9 @@
             opClient.execute(true);
 
             MessageContext msgCtx = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-            //TODO: get attachments
             return getSOAPMessage(msgCtx.getEnvelope());
         } catch (AxisFault e) {
-            throw new SOAPException(e);
+            throw new SOAPException(e.getMessage());
         }
     }
 
@@ -171,57 +170,56 @@
      * @throws SOAPException If an exception occurs during this conversion
      */
     private SOAPMessage getSOAPMessage(org.apache.axiom.soap.SOAPEnvelope respOMSoapEnv)
-            throws SOAPException {
+    throws SOAPException {
 
-        // Create the basic SOAP Message
-        MessageFactory mf = MessageFactory.newInstance();
-        SOAPMessage response = mf.createMessage();
-        SOAPPart sPart = response.getSOAPPart();
-        javax.xml.soap.SOAPEnvelope env = sPart.getEnvelope();
-        SOAPBody body = env.getBody();
-        SOAPHeader header = env.getHeader();
-
-        // Convert all header blocks
-		org.apache.axiom.soap.SOAPHeader header2 = respOMSoapEnv.getHeader();
-		if (header2 != null) {
-			for (Iterator hbIter = header2.examineAllHeaderBlocks(); hbIter.hasNext();) {
-
-				// Converting a single OM SOAP HeaderBlock to a SAAJ SOAP
-				// HeaderBlock
-				org.apache.axiom.soap.SOAPHeaderBlock hb = (org.apache.axiom.soap.SOAPHeaderBlock) hbIter
-						.next();
-				final QName hbQName = hb.getQName();
-				final SOAPHeaderElement headerEle = header.addHeaderElement(env.createName(hbQName
-						.getLocalPart(), hbQName.getPrefix(), hbQName.getNamespaceURI()));
-				for (Iterator attribIter = hb.getAllAttributes(); attribIter.hasNext();) {
-					OMAttribute attr = (OMAttribute) attribIter.next();
-					final QName attrQName = attr.getQName();
-					headerEle.addAttribute(env.createName(attrQName.getLocalPart(), attrQName
-							.getPrefix(), attrQName.getNamespaceURI()), attr.getAttributeValue());
-				}
-				final String role = hb.getRole();
-				if (role != null) {
-					headerEle.setActor(role);
-				}
-				headerEle.setMustUnderstand(hb.getMustUnderstand());
-
-				toSAAJElement(headerEle, hb, response);
-			}
-		}
-
-        // Convert the body
-        toSAAJElement(body, respOMSoapEnv.getBody(), response);
-        // if there are unrefferenced attachments, add that to response
-        if(!unaccessedAttachments.isEmpty()){
-        	Collection attachments = unaccessedAttachments.values();
-        	Iterator attachementsIterator = attachments.iterator();
-        	while (attachementsIterator.hasNext()) {
-				AttachmentPart  attachment = (AttachmentPart) attachementsIterator.next();
-				response.addAttachmentPart(attachment);
-			}
-        }
+    	// Create the basic SOAP Message
+    	MessageFactory mf = MessageFactory.newInstance();
+    	SOAPMessage response = mf.createMessage();
+    	SOAPPart sPart = response.getSOAPPart();
+    	javax.xml.soap.SOAPEnvelope env = sPart.getEnvelope();
+    	SOAPBody body = env.getBody();
+    	SOAPHeader header = env.getHeader();
+
+    	// Convert all header blocks
+    	org.apache.axiom.soap.SOAPHeader header2 = respOMSoapEnv.getHeader();
+    	if (header2 != null) {
+    		for (Iterator hbIter = header2.examineAllHeaderBlocks(); hbIter.hasNext();) {
+    			// Converting a single OM SOAP HeaderBlock to a SAAJ SOAP
+    			// HeaderBlock
+    			org.apache.axiom.soap.SOAPHeaderBlock hb = (org.apache.axiom.soap.SOAPHeaderBlock) 
+    							hbIter.next();
+    			final QName hbQName = hb.getQName();
+    			final SOAPHeaderElement headerEle = header.addHeaderElement(env.createName(hbQName
+    					.getLocalPart(), hbQName.getPrefix(), hbQName.getNamespaceURI()));
+    			for (Iterator attribIter = hb.getAllAttributes(); attribIter.hasNext();) {
+    				OMAttribute attr = (OMAttribute) attribIter.next();
+    				final QName attrQName = attr.getQName();
+    				headerEle.addAttribute(env.createName(attrQName.getLocalPart(), attrQName
+    						.getPrefix(), attrQName.getNamespaceURI()), attr.getAttributeValue());
+    			}
+    			final String role = hb.getRole();
+    			if (role != null) {
+    				headerEle.setActor(role);
+    			}
+    			headerEle.setMustUnderstand(hb.getMustUnderstand());
+
+    			toSAAJElement(headerEle, hb, response);
+    		}
+    	}
+
+    	// Convert the body
+    	toSAAJElement(body, respOMSoapEnv.getBody(), response);
+    	// if there are unrefferenced attachments, add that to response
+    	if(!unaccessedAttachments.isEmpty()){
+    		Collection attachments = unaccessedAttachments.values();
+    		Iterator attachementsIterator = attachments.iterator();
+    		while (attachementsIterator.hasNext()) {
+    			AttachmentPart  attachment = (AttachmentPart) attachementsIterator.next();
+    			response.addAttachmentPart(attachment);
+    		}
+    	}
 
-        return response;
+    	return response;
     }
 
     /**
@@ -300,7 +298,7 @@
 
         final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
                 SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
-        System.err.println("#### req OM Soap Env=" + omSOAPEnv);
+
 
         Map attachmentMap = new HashMap();
         final Iterator attachments = saajSOAPMsg.getAttachments();
@@ -416,55 +414,80 @@
      * overrided SOAPConnection's get() method 
      */
 	
-	public SOAPMessage get(Object to) throws SOAPException {
+    public SOAPMessage get(Object to) throws SOAPException {
     	URL url = null;
-    	try 
-    	{
+    	try{
     		url = (to instanceof URL) ? (URL) to : new URL(to.toString());
-    		if(url != null){
-    			InputStream in = url.openStream();
-    			//TODO : setting null for mime headers
-    			// close the connection??
-    			SOAPMessage soapMessage = new SOAPMessageImpl(in,null);
-    			return soapMessage;
-    		}
-    		return null;
     	}catch (MalformedURLException e) {
     		throw new SOAPException(e);
+    	}
+
+    	int responseCode;
+    	boolean isFailure = false;
+    	HttpURLConnection httpCon = null;
+    	try {
+    		httpCon = (HttpURLConnection) url.openConnection();
+    		httpCon.setDoOutput(true);
+    		httpCon.setDoInput(true);
+    		httpCon.setUseCaches(false);
+    		httpCon.setRequestMethod("GET");
+    		HttpURLConnection.setFollowRedirects(true);
+
+    		httpCon.connect();
+    		responseCode = httpCon.getResponseCode();
+    		// 500 is allowed for SOAP faults
+    		if (responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
+    			isFailure = true;
+    		} else if ((responseCode / 100) != 2) {
+    			throw new SOAPException("Error response: ("+responseCode 
+    					+ httpCon.getResponseMessage());
+    		}
     	}catch (IOException e) {
     		throw new SOAPException(e);
-    	}catch (OMException e){
-    		throw new SOAPException(e);
     	}
-    	
-	}
 
-    
-
-    
-    /* private void printOMSOAPEnvelope(final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try {
-            omSOAPEnv.serialize(baos);
-            log.info("---------------------------------------------------------------------------");
-            log.info(baos);
-            log.info("---------------------------------------------------------------------------");
-            System.err.println("---------------------------------------------------------------------------");
-            System.err.println(baos);
-            System.err.println("---------------------------------------------------------------------------");
-        } catch (XMLStreamException e) {
-            e.printStackTrace();
-        }
+    	//Construct the soapmessage from http response
+    	SOAPMessage soapMessage = null;
+    	if (responseCode == HttpURLConnection.HTTP_OK) {
+    		try {
+    			//read http headers & load mimeheaders
+    			MimeHeaders mimeHeaders = new MimeHeaders();
+    			String key, value;
+    			// skip status line
+    			int i = 1;
+    			while (true) {
+    				key = httpCon.getHeaderFieldKey(i);
+    				value = httpCon.getHeaderField(i);
+    				if (key == null && value == null){
+    					break;
+    				}
+
+    				if (key != null) {
+    					StringTokenizer values = new StringTokenizer(value, ",");
+    					while (values.hasMoreTokens()){
+    						mimeHeaders.addHeader(key, values.nextToken().trim());
+    					}
+    				}
+    				i++;
+    			}
+    			InputStream httpInputStream;
+    			if(isFailure){
+    				httpInputStream = httpCon.getErrorStream();
+    			}else{
+    				httpInputStream = httpCon.getInputStream();
+    			}
+
+    			soapMessage = new SOAPMessageImpl(httpInputStream,mimeHeaders);
+    			httpInputStream.close();
+    			httpCon.disconnect();
+
+    		} catch (SOAPException e) {
+    			throw e;
+    		} catch (Exception e) {
+    			throw new SOAPException(e.getMessage());
+    		}
+    	}
+    	return soapMessage;
     }
 
-    private String printSAAJSOAPMessage(final SOAPMessage msg) throws SOAPException, IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        msg.writeTo(baos);
-        String responseStr = baos.toString();
-
-        System.out.println("\n\n----------------------SAAJ Message-------------------------\n" +
-                           responseStr);
-        System.out.println("-------------------------------------------------------\n\n");
-        return responseStr;
-    }*/
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java Thu Mar  1 06:49:44 2007
@@ -15,6 +15,8 @@
  */
 package org.apache.axis2.saaj;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -38,11 +40,8 @@
 import org.apache.axiom.om.impl.dom.TextImpl;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
@@ -386,21 +385,21 @@
         return returnList.iterator();
     }
 
+    
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
-    	//TODO - check
         if (qname.getNamespaceURI() == null || qname.getNamespaceURI().trim().length() == 0) {
             element.setAttribute(qname.getLocalPart(), value);
         } else {
-            element.setAttributeNS(qname.getNamespaceURI(), qname.getPrefix() + ":" + qname.getLocalPart(), value);
+            element.setAttributeNS(qname.getNamespaceURI(), qname.getPrefix() + ":" + 
+            		qname.getLocalPart(), value);
         }
         return this;
-        
     }
 
     public SOAPElement addChildElement(QName qname) throws SOAPException {
-    	//TODO - check
         String prefix = qname.getPrefix();
-        return addChildElement(qname.getLocalPart(), "".equals(prefix) ? null : prefix  , qname.getNamespaceURI());
+        return addChildElement(qname.getLocalPart(), "".equals(prefix) ? 
+        		null : prefix  , qname.getNamespaceURI());
     }
 
     /**
@@ -422,17 +421,16 @@
     		throw new SOAPException("Invalid prefix");
     	}
     	QName qname = null;
-    	if(SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	if(this.element.getOMFactory() instanceof SOAP11Factory){
     		qname = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,localName,prefix);   		
     	}
-    	else if(SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	else if(this.element.getOMFactory() instanceof SOAP12Factory){
     		qname = new QName(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,localName,prefix);
     	}
     	return qname;
     }
 
     public Iterator getAllAttributesAsQNames() {
-    	//TODO - check,test ok
     	final Iterator attribIter = element.getAllAttributes();
         Collection attributesAsQNames = new ArrayList();
         Attr attr;
@@ -447,7 +445,6 @@
     }
 
     public String getAttributeValue(QName qname) {
-    	//TODO - check,test ok
         final OMAttribute attribute = element.getAttribute(qname);
         if (attribute == null) {
         	return null;
@@ -456,7 +453,6 @@
     }
 
     public Iterator getChildElements(QName qname) {
-    	//TODO - check,test ok
         Iterator childIter = element.getChildrenWithName(qname);
         Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
@@ -466,12 +462,10 @@
     }
 
     public QName getElementQName() {
-    	//TODO - check
         return element.getQName();
     }
 
     public boolean removeAttribute(QName qname) {
-    	//TODO - check
         org.apache.axiom.om.OMAttribute attr = element.getAttribute(qname);
         if (attr != null) {
         	element.removeAttribute(attr);
@@ -481,7 +475,6 @@
     }
 
     public SOAPElement setElementQName(QName newName) throws SOAPException {
-        //TODO - check
     	String localName = this.element.getLocalName();
     	if(org.apache.axiom.soap.SOAPConstants.BODY_LOCAL_NAME.equals(localName)
     			|| org.apache.axiom.soap.SOAPConstants.HEADER_LOCAL_NAME.equals(localName)
@@ -540,11 +533,17 @@
      */
     public void setEncodingStyle(String encodingStyle) throws SOAPException {
     	if(this.element.getOMFactory() instanceof SOAP11Factory){
-        	if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
-            	throw new IllegalArgumentException("Invalid Encoding style : " + encodingStyle);
-            }else{
-            	((DocumentImpl) getOwnerDocument()).setCharsetEncoding(encodingStyle);
-            }
+    		try{
+    			URI uri = new URI(encodingStyle);
+	        	//if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
+	            //	throw new IllegalArgumentException("Invalid Encoding style : " + encodingStyle);
+	            //}else{
+	            ((DocumentImpl) getOwnerDocument()).setCharsetEncoding(encodingStyle);
+	            //}				
+			} catch (URISyntaxException e) {
+				throw new IllegalArgumentException("Invalid Encoding style : " 
+						+ encodingStyle+":"+e);
+			} 
     	}else if(this.element.getOMFactory() instanceof SOAP12Factory){
     		if(SOAPConstants.URI_NS_SOAP_1_2_ENCODING.equals(encodingStyle)){
     			throw new SOAPException("Illegal value : "+SOAPConstants.URI_NS_SOAP_1_2_ENCODING);
@@ -839,26 +838,4 @@
     public NamedNodeMap getAttributes() {
         return element.getAttributes();
     }
-    
-    /**
-     * @param rootElement
-     * @return SOAP version of the element using SOAPConstants.SOAP_1_1_PROTOCOL
-     * 		   or SOAPConstants.SOAP_1_2_PROTOCOL
-     */
-    //TODO : check 
-    protected String getSOAPVersion(ElementImpl rootElement){
-    	OMNamespace omNamespace = rootElement.getNamespace();
-        if(omNamespace.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI) &&
-        		omNamespace.getPrefix().equals(SOAP11Constants.SOAP_DEFAULT_NAMESPACE_PREFIX))
-        {
-        	return SOAPConstants.SOAP_1_1_PROTOCOL;
-        }
-        else if(omNamespace.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI) &&
-        		omNamespace.getPrefix().equals(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX))
-        {
-        	return SOAPConstants.SOAP_1_2_PROTOCOL;
-        }
-    	return null;
-    }
-    
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java Thu Mar  1 06:49:44 2007
@@ -207,13 +207,10 @@
     }
 
     public SOAPElement addTextNode(String text) throws SOAPException {
-
-        //TODO: Method implementation
         Node firstChild = element.getFirstChild();
         if (firstChild instanceof org.w3c.dom.Text) {
             ((org.w3c.dom.Text) firstChild).setData(text);
         } else {
-
             // Else this is a header
             TextImpl doomText = new TextImpl(text, this.element.getOMFactory());
             doomText.setNextOMSibling((NodeImpl) firstChild);
@@ -254,9 +251,7 @@
 	 * SOAP 1.2 should not allow element to be added after body element
 	 */
 	public SOAPElement addChildElement(Name name) throws SOAPException {
-		//TODO : complete
         if(this.element.getOMFactory() instanceof SOAP12Factory) {
-        	//return super.addChildElement(name);
         	throw new SOAPException("Cannot add elements after body element");
         }else if(this.element.getOMFactory() instanceof SOAP11Factory){
         	//Let elements to be added any where.
@@ -264,7 +259,4 @@
         }
 		return null;
 	}  
-    
-    
-	
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java Thu Mar  1 06:49:44 2007
@@ -57,9 +57,11 @@
         String uri = name.getURI();
         OMElement omElement = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName, uri, prefix);
+            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName
+            		, uri, prefix);
         } else {
-            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName, uri, prefix);
+            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName
+            		, uri, prefix);
         }
         DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
         return new SOAPElementImpl((ElementImpl) omElement);
@@ -102,12 +104,15 @@
      * @throws javax.xml.soap.SOAPException if there is an error in creating the
      *                                      <code>SOAPElement</code> object
      */
-    public SOAPElement createElement(String localName, String prefix, String uri) throws SOAPException {
+    public SOAPElement createElement(String localName, String prefix, String uri) 
+    throws SOAPException {
         OMElement omElement = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName, uri, prefix);
+            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName
+            		, uri, prefix);
         } else {
-            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName, uri, prefix);
+            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName
+            		, uri, prefix);
         }
         return new SOAPElementImpl((ElementImpl) omElement);
     }
@@ -173,8 +178,6 @@
 	 * @throws SOAPException - if there is a SOAP error 
      */
     public SOAPFault createFault() throws SOAPException {
-        //TODO - check
-    	OMDOMFactory omdomFactory = null;
     	org.apache.axiom.soap.SOAPFactory soapFactory;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
         	soapFactory = DOOMAbstractFactory.getSOAP12Factory();
@@ -194,15 +197,21 @@
      * @throws: SOAPException - if there is a SOAP error
      */
     public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
-        //TODO - check
     	SOAPFault soapFault;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-        	soapFault =  new SOAPFaultImpl(DOOMAbstractFactory.getSOAP12Factory().createSOAPFault());
+        	soapFault =  new SOAPFaultImpl(DOOMAbstractFactory.getSOAP12Factory()
+        			.createSOAPFault());
         } else {
-        	soapFault =  new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory().createSOAPFault());
+        	soapFault =  new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory()
+        			.createSOAPFault());
         }
     	soapFault.setFaultCode(faultCode);
-    	soapFault.addFaultReasonText(reasonText, Locale.getDefault());
+    	try{
+    		soapFault.addFaultReasonText(reasonText, Locale.getDefault());
+    	}catch(UnsupportedOperationException e){
+    		throw new SOAPException(e.getMessage());
+    	}
+    	
     	return soapFault;
     }
 
@@ -215,7 +224,8 @@
         String localName = qname.getLocalPart();
         String prefix = qname.getPrefix();
         String uri = qname.getNamespaceURI();
-        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName
+        		, uri, prefix);
         return new SOAPElementImpl((ElementImpl) omElement);
 	}
 
@@ -226,12 +236,10 @@
         } else {
             omdomFactory = (OMDOMFactory) DOOMAbstractFactory.getSOAP11Factory();
         }
-        OMNamespace ns = omdomFactory.createOMNamespace(element.getNamespaceURI(),element.getPrefix());
+        OMNamespace ns = omdomFactory.createOMNamespace(element.getNamespaceURI()
+        		,element.getPrefix());
         OMElement omElement = omdomFactory.createOMElement(element.getLocalName(), ns);
         return new SOAPElementImpl((ElementImpl) omElement);
 	}
-    
-	
-	
     
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java Thu Mar  1 06:49:44 2007
@@ -405,7 +405,6 @@
      *        the SOAP 1.2 concept of Fault Reason.
      */
     public void addFaultReasonText(String text, Locale locale) throws SOAPException {
-        //TODO - check
     	if(locale == null){
     		throw new SOAPException("Received null for locale");
     	}
@@ -417,7 +416,6 @@
     		if(existingReasonText == null)
     		{
         		org.apache.axiom.soap.SOAPFactory soapFactory = null;
-        		//soapFactory = DOOMAbstractFactory.getSOAP12Factory();
         		soapFactory = (SOAP12Factory)this.element.getOMFactory();
             	if(this.fault.getReason() == null){
             		SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason(this.fault);
@@ -459,17 +457,16 @@
      */
     
     public void appendFaultSubcode(QName subcode) throws SOAPException {
-        //TODO - check
     	org.apache.axiom.soap.SOAPFactory soapFactory = null;
     	SOAPFaultSubCode soapFaultSubCode = null;
     	
     	if(subcode.getNamespaceURI() == null || subcode.getNamespaceURI().trim().length() == 0){
     		throw new SOAPException("Unqualified QName object : "+subcode);
     	}
-    	if(SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	if(this.element.getOMFactory() instanceof SOAP11Factory){
     		throw new UnsupportedOperationException();    		
     	}
-    	else if(SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	else if(this.element.getOMFactory() instanceof SOAP12Factory){
     		soapFactory = DOOMAbstractFactory.getSOAP12Factory();
     	}
     	
@@ -510,7 +507,6 @@
      * <p/>
      */
     public QName getFaultCodeAsQName() {
-        //TODO - check
     	SOAPFaultCode soapFaultCode = this.fault.getCode();
     	if(soapFaultCode != null){
             String prefix = "";
@@ -740,7 +736,6 @@
         if (factory instanceof SOAP11Factory) {
         	throw new UnsupportedOperationException();
         } else {
-        	//TODO : sumedha complete
         	fault.getCode().getSubCode().detach();
         }
     }
@@ -797,11 +792,11 @@
     		
     public void setFaultNode(String s) throws SOAPException {
     	org.apache.axiom.soap.SOAPFactory soapFactory = null;
-    	if(SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	if(this.element.getOMFactory() instanceof SOAP11Factory){
     		throw new UnsupportedOperationException("message does not support " +
     				"the SOAP 1.2 concept of Fault Node");    		
     	}
-    	else if(SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	else if(this.element.getOMFactory() instanceof SOAP12Factory){
     		soapFactory = DOOMAbstractFactory.getSOAP12Factory();
     	}
         SOAPFaultNode soapFaultNode = soapFactory.createSOAPFaultNode(this.fault);
@@ -820,11 +815,10 @@
      */
     public void setFaultRole(String uri) throws SOAPException {
     	org.apache.axiom.soap.SOAPFactory soapFactory = null;
-    	if(SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	if(this.element.getOMFactory() instanceof SOAP11Factory){
     		throw new UnsupportedOperationException("message does not support the " +
     				"SOAP 1.2 concept of Fault Role");   		
-    	}
-    	else if(SOAPConstants.SOAP_1_2_PROTOCOL.equals(getSOAPVersion(this.element))){
+    	}else if(this.element.getOMFactory() instanceof SOAP12Factory){
     		soapFactory = DOOMAbstractFactory.getSOAP12Factory();
     	}
         SOAPFaultRole soapFaultRole = soapFactory.createSOAPFaultRole(this.fault);

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java Thu Mar  1 06:49:44 2007
@@ -76,7 +76,8 @@
     /* (non-Javadoc)
     * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
     */
-    public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException {
+    public SOAPElement addChildElement(String localName, String prefix, String uri) 
+    throws SOAPException {
         OMNamespace ns = new NamespaceImpl(uri, prefix);
         SOAPHeaderBlock headerBlock = null;
         if (this.element.getOMFactory() instanceof SOAP11Factory) {
@@ -271,7 +272,8 @@
     }
 
     public SOAPHeaderElement addHeaderElement(QName qname) throws SOAPException {
-        return (SOAPHeaderElement) addChildElement(qname.getLocalPart(), qname.getPrefix(), qname.getNamespaceURI());
+        return (SOAPHeaderElement) addChildElement(qname.getLocalPart(), qname.getPrefix()
+        		, qname.getNamespaceURI());
     }
 
     
@@ -325,15 +327,15 @@
 				SOAP11HeaderBlockImpl supportedEnvelop = 
 					new SOAP11HeaderBlockImpl(Constants.ELEM_SUPPORTEDENVELOPE,
 							namespace,(SOAPFactory) this.element.getOMFactory());
-				supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix+index+":"+Constants.ELEM_ENVELOPE, null);
+				supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix+index+":"
+						+Constants.ELEM_ENVELOPE, null);
 		    	upgrade.addChild(supportedEnvelop);
-	        }
-	        else 
-	        {
+	        }else{
 				SOAP12HeaderBlockImpl supportedEnvelop = 
 					new SOAP12HeaderBlockImpl(Constants.ELEM_SUPPORTEDENVELOPE,
 							namespace,(SOAPFactory) this.element.getOMFactory());
-				supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix+index+":"+Constants.ELEM_ENVELOPE, null);
+				supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix+index+":"
+						+Constants.ELEM_ENVELOPE, null);
 		    	upgrade.addChild(supportedEnvelop);
 	        }
 		}

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java Thu Mar  1 06:49:44 2007
@@ -35,6 +35,8 @@
 import javax.xml.soap.SOAPPart;
 
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
 import org.apache.axis2.transport.http.HTTPConstants;
 
 public class SOAPMessageImpl extends SOAPMessage {
@@ -48,27 +50,48 @@
 
     public SOAPMessageImpl(SOAPEnvelopeImpl soapEnvelope) {
         String contentType = null;
+        
+        
         if (mimeHeaders != null) {
-            String contentTypes[] = mimeHeaders.getHeader("Content-Type");
+            String contentTypes[] = mimeHeaders.getHeader(HTTPConstants.CONTENT_TYPE);
             contentType = (contentTypes != null) ? contentTypes[0] : null;
+        }else{
+        	this.mimeHeaders = new MimeHeadersEx();   
+        	if(soapEnvelope.getOMFactory() instanceof SOAP11Factory){
+        		contentType = HTTPConstants.MEDIA_TYPE_TEXT_XML;
+        		this.mimeHeaders.addHeader("content-type", contentType);
+        	}else if(soapEnvelope.getOMFactory() instanceof SOAP12Factory){
+        		contentType = HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML;
+        		this.mimeHeaders.addHeader("content-type", contentType);        		
+        	}
         }
 
         setCharsetEncoding(contentType);
         soapPart = new SOAPPartImpl(this, soapEnvelope);
-        this.mimeHeaders = new MimeHeadersEx();
     }
 
     public SOAPMessageImpl(InputStream inputstream,javax.xml.soap.MimeHeaders mimeHeaders) 
-    		throws SOAPException 
+    throws SOAPException 
     {
     	String contentType = null;
+    	String tmpContentType = "";
     	if (mimeHeaders != null) {
-    		String contentTypes[] = mimeHeaders.getHeader("Content-Type");
-    		contentType = (contentTypes != null) ? contentTypes[0] : null;
+    		String contentTypes[] = mimeHeaders.getHeader(HTTPConstants.CONTENT_TYPE);
+    		if(contentTypes != null && contentTypes.length > 0){
+    			tmpContentType = contentTypes[0];
+    			//tmpContentType can be like 'application/soap+xml; charset=UTF-8;'
+    			//Only the first part is important
+    			if(tmpContentType.indexOf(";") > -1){
+    				contentType = tmpContentType.substring(0, tmpContentType.indexOf(";"));    			
+    			}else{
+    				contentType = tmpContentType;
+    			}
+    		}
     	}
-
-    	setCharsetEncoding(contentType);
-    	if (contentType != null && contentType.indexOf("multipart/related;") == 0) {
+    	//Setting the whole content-type string to CharsetEncoding.
+    	//Is this correct?
+    	setCharsetEncoding(tmpContentType);
+    	if (contentType != null) {    		
     		soapPart = new SOAPPartImpl(this, inputstream, mimeHeaders);
     	} else {
     		soapPart = new SOAPPartImpl(this, inputstream);
@@ -196,7 +219,7 @@
     public void addAttachmentPart(AttachmentPart attachmentPart) {
         if (attachmentPart != null) {
             attachmentParts.add(attachmentPart);
-            mimeHeaders.setHeader("Content-Type", "multipart/related");
+            mimeHeaders.setHeader(HTTPConstants.CONTENT_TYPE, "multipart/related");
         }
     }
 
@@ -379,8 +402,8 @@
             	attachmentPart = (AttachmentPartImpl) iterator.next();
             	String[] contentIds = attachmentPart.getMimeHeader("Content-Id");
             	
-            	//References can be made via an href attribute as described in SOAP Messages with Attachments
-            	//or via a single Text child node containing a URI          	
+            	//References can be made via an href attribute as described in SOAP Messages 
+            	//with Attachments or via a single Text child node containing a URI          	
             	String reference = soapelement.getAttribute("href");
             	if(reference == null || reference.trim().length() == 0){
             		reference = soapelement.getValue();

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java?view=diff&rev=513354&r1=513353&r2=513354
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java Thu Mar  1 06:49:44 2007
@@ -40,6 +40,8 @@
 
 import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
@@ -74,10 +76,9 @@
 
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         SOAPEnvelopeImpl soapEnvelope) {
-
-        setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, IDGenerator.generateID());
-        setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
-
+        //setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, IDGenerator.generateID());
+        //setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
+        this.mimeHeaders = (MimeHeadersEx)parentSoapMsg.getMimeHeaders();
         soapMessage = parentSoapMsg;
         envelope = soapEnvelope;
         document = soapEnvelope.getOwnerDocument();
@@ -86,28 +87,38 @@
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         InputStream inputStream,javax.xml.soap.MimeHeaders mimeHeaders
                         ) throws SOAPException {
-    	boolean mimeHeaderSet = true;
+    	String contentType = ""; 
+    	String fullContentTypeStr = "";
     	if(mimeHeaders == null){
-    		mimeHeaderSet = false;
-        	mimeHeaders = new MimeHeaders();
-        	mimeHeaders.addHeader("Content-ID", IDGenerator.generateID());
-        	mimeHeaders.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
+    		//TODO : read string from constants
+    		mimeHeaders = new MimeHeaders();
+    		mimeHeaders.addHeader("Content-ID", IDGenerator.generateID());
+    		mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
+    	}else{
+    		String contentTypes[] = mimeHeaders.getHeader(HTTPConstants.CONTENT_TYPE);
+    		if(contentTypes != null && contentTypes.length > 0){
+    			fullContentTypeStr = contentTypes[0];
+    			//tmpContentType can be like 'application/soap+xml; charset=UTF-8;'
+    			//Only the first part is important
+    			if(fullContentTypeStr.indexOf(";") > -1){
+    				contentType = fullContentTypeStr.substring(0, fullContentTypeStr.indexOf(";"));    			
+    			}else{
+    				contentType = fullContentTypeStr;
+    			}
+    		}    		
     	}
     	
     	Iterator mimeHeaderIterator = mimeHeaders.getAllHeaders();
-    	String contentType = "";
     	while (mimeHeaderIterator.hasNext()) {
 			MimeHeader mimeHeader = (MimeHeader) mimeHeaderIterator.next();
 			String value = mimeHeader.getValue();
-			if("content-type".equals(mimeHeader.getName())){
-				contentType = value;
-			}
 			setMimeHeader(mimeHeader.getName(), value);
 		}
     	InputStream modifiedInputStream = null;
-    	if(mimeHeaderSet){
+    	if(contentType.indexOf("multipart/related") == 0){
+    		//This contains attachements
         	try {
-                Attachments attachments = new Attachments(inputStream, contentType,false, "","");
+                Attachments attachments = new Attachments(inputStream,fullContentTypeStr,false, "","");
                 modifiedInputStream = attachments.getSOAPPartInputStream();
       		} catch (Exception e) {
 	            throw new SOAPException(e);
@@ -119,10 +130,27 @@
 
         try {
             InputStreamReader isReader = new InputStreamReader(modifiedInputStream);
-            StAXSOAPModelBuilder builder =
-                    new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
-                                             new SOAP11Factory(),
-                                             null);
+            StAXSOAPModelBuilder builder = null;
+            
+            if(HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(contentType)){
+                builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+                        new SOAP11Factory(),
+                        SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+            	
+            }else if(HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML.equals(contentType)){
+                builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+                        new SOAP12Factory(),
+                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+            	
+            }else if(HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED.equals(contentType)){
+                builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+                        new SOAP11Factory(),
+                        null);            	
+            }else{
+                builder = new StAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(isReader),
+                        new SOAP11Factory(),
+                        null);             	
+            }
             org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder.getSOAPEnvelope();
             envelope = new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
             envelope.element.build();
@@ -315,13 +343,16 @@
 			
 			StAXSOAPModelBuilder builder1 = null;
 			if(this.envelope.element.getOMFactory() instanceof SOAP11Factory){
-				builder1 = new StAXSOAPModelBuilder(reader,(SOAP11Factory)this.envelope.element.getOMFactory(),null);
+				builder1 = new StAXSOAPModelBuilder(reader,
+						(SOAP11Factory)this.envelope.element.getOMFactory(),null);
 			}else if(this.envelope.element.getOMFactory() instanceof SOAP12Factory){
-				builder1 = new StAXSOAPModelBuilder(reader,(SOAP12Factory)this.envelope.element.getOMFactory(),null);
+				builder1 = new StAXSOAPModelBuilder(reader,
+						(SOAP12Factory)this.envelope.element.getOMFactory(),null);
 			}
 
             org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder1.getSOAPEnvelope();
-            envelope = new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
+            envelope = new SOAPEnvelopeImpl(
+            		(org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
             envelope.element.build();
             this.document = envelope.getOwnerDocument();
 		} catch (Exception e) {
@@ -455,7 +486,8 @@
      *                      illegal character.
      *                      <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
      */
-    public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
+    public ProcessingInstruction createProcessingInstruction(String target, String data) 
+    throws DOMException {
         return document.createProcessingInstruction(target, data);
     }
 
@@ -778,7 +810,6 @@
         // TODO - Fixme.
     	//return ((DeferredDocumentImpl)(((DOMSource)this.source).getNode())).getInputEncoding();
     	return this.envelope.getEncodingStyle();
-        //throw new UnsupportedOperationException("TODO");
     }
 
     public String getXmlEncoding() {
@@ -1310,7 +1341,8 @@
 
     public String getValue() {
         return null;  //TODO - Not yet implemented
-    }
+    }    	//if(mimeHeaderSet){
+
 
     public void setParentElement(SOAPElement parent) throws SOAPException {
         //TODO - Not yet implemented



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message