axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1029125 [1/2] - in /axis/axis2/java/core/branches/1_5: ./ modules/distribution/ modules/kernel/src/org/apache/axis2/transport/http/util/ modules/kernel/test/org/apache/axis2/transport/http/util/ modules/parent/ modules/saaj/ modules/saaj/s...
Date Sat, 30 Oct 2010 17:26:28 GMT
Author: veithen
Date: Sat Oct 30 17:26:27 2010
New Revision: 1029125

URL: http://svn.apache.org/viewvc?rev=1029125&view=rev
Log:
Merged a first set of SAAJ fixes from the trunk to the 1.5 branch.

Merged revisions: 732539,732541,732873,732877,733293,733295,733304,733306,733348,733354,733394,733399,733463,733464,733533,733676

Issues fixed: AXIS2-4202, AXIS2-4203

Note: The merge of r733533 effectively reverts r958099, which was a fix for AXIS2-4752. This fix has been replaced by manually merging a piece of code from r793382 (which needs review, also on the trunk).

Added:
    axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/SwAmessage.bin
      - copied unchanged from r732539, webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
      - copied unchanged from r732539, webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
Removed:
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/MimeHeadersEx.java
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/integration/EchoService.java
Modified:
    axis/axis2/java/core/branches/1_5/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/distribution/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java   (props changed)
    axis/axis2/java/core/branches/1_5/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java   (props changed)
    axis/axis2/java/core/branches/1_5/modules/parent/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/saaj/pom.xml
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
    axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
    axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/message.bin
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/SOAPFaultTest.java
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
    axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/pom.xml   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/java/org/apache/axis2/handlers/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/resources/META-INF/module.xml   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/applet/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/servlet/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/transport/http/pom.xml   (props changed)
    axis/axis2/java/core/branches/1_5/modules/transport/http/src/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/transport/local/   (props changed)
    axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AdminAgent.java   (props changed)
    axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AxisAdminServlet.java   (props changed)

Propchange: axis/axis2/java/core/branches/1_5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 30 17:26:27 2010
@@ -1,2 +1,2 @@
 /axis/axis2/java/core/trunk:922914,922941,922983,935169,935174,935338,944347,944915,951385,960693,960976,960978,960984,960995,961012,961964,962844,963081,963147,965032,965036,965056,965068,965074,965213,965268,965277,965302,965454,966371,966401,966428,979882-979883,979886,981036,981038,981095,981188,981220-981221,981237,981262,981278,981293,981306,981311,981985,982387,982393,982795,982800,983101,983110,983114,983119-983120,983128,983185,983236,983270,983276,983280,983316,983363,983370,983372,985458,985464,985626,985634,985661,985715,985717,985744,985748,985752,985763,985791,985796,985851,986844,986889,987313,987712-987715,987783,987832,987873,987883,987913,987935,990350,990369,990377,990384,990394,990398,990404,990434,990449,1001279,1001452
-/webservices/axis2/trunk/java:728674,731798,732924,732927,732939,733539,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980
+/webservices/axis2/trunk/java:728674,731798,732539,732541,732873,732877,732924,732927,732939,733293,733295,733304,733306,733348,733354,733394,733399,733463-733464,733533,733539,733676,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980

Propchange: axis/axis2/java/core/branches/1_5/modules/distribution/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 30 17:26:27 2010
@@ -1,2 +1,2 @@
 /axis/axis2/java/core/trunk/modules/distribution:922914,922941,922983,935169,935174,935338,936434,944347,944915,951385,960693,960976,960978,960984,960995,961012,961964,962844,963081,963147,965032,965036,965056,965068,965074,965213,965268,965277,965302,965454,966371,966401,966428,979882-979883,979886,981036,981038,981095,981188,981220-981221,981237,981262,981278,981293,981306,981311,981985,982387,982393,982795,982800,983101,983110,983114,983119-983120,983128,983185,983236,983270,983276,983280,983316,983363,983370,983372,985458,985464,985626,985634,985661,985715,985717,985744,985748,985752,985763,985791,985796,985851,986844,986889,987313,987712-987715,987783,987832,987873,987883,987913,987935,990350,990369,990377,990384,990394,990398,990404,990434,990449,1001279,1001452
-/webservices/axis2/trunk/java/modules/distribution:728674,731798,732924,732927,732939,733539,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980
+/webservices/axis2/trunk/java/modules/distribution:728674,731798,732539,732541,732873,732877,732924,732927,732939,733293,733295,733304,733306,733348,733354,733394,733399,733463-733464,733533,733539,733676,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980

Propchange: axis/axis2/java/core/branches/1_5/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 30 17:26:27 2010
@@ -1,2 +1,2 @@
 /axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java:922914,922941,922983,935169,935174,935338,944347,944915,951385,960693,960976,960978,960984,960995,961012,961964,962844,963081,963147,965032,965036,965056,965068,965074,965213,965268,965277,965302,965454,966371,966401,966428,979882-979883,979886,981036,981038,981095,981188,981220-981221,981237,981262,981278,981293,981306,981311,981985,982387,982393,982795,982800,983101,983110,983114,983119-983120,983128,983185,983236,983270,983276,983280,983316,983363,983370,983372,985458,985464,985626,985634,985661,985715,985717,985744,985748,985752,985763,985791,985796,985851,986844,986889,987313,987712-987715,987783,987832,987873,987883,987913,987935,990350,990369,990377,990384,990394,990398,990404,990434,990449,1001279,1001452
-/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java:728674,731798,733539,751964,761709,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980
+/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java:728674,731798,732539,732541,732873,732877,733293,733295,733304,733306,733348,733354,733394,733399,733463-733464,733533,733539,733676,751964,761709,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980

Propchange: axis/axis2/java/core/branches/1_5/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 30 17:26:27 2010
@@ -1,2 +1,2 @@
 /axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java:922914,922941,922983,935169,935174,935338,944347,944915,951385,960693,960976,960978,960984,960995,961012,961964,962844,963081,963147,965032,965036,965056,965068,965074,965213,965268,965277,965302,965454,966371,966401,966428,979882-979883,979886,981036,981038,981095,981188,981220-981221,981237,981262,981278,981293,981306,981311,981985,982387,982393,982795,982800,983101,983110,983114,983119-983120,983128,983185,983236,983270,983276,983280,983316,983363,983370,983372,985458,985464,985626,985634,985661,985715,985717,985744,985748,985752,985763,985791,985796,985851,986844,986889,987313,987712-987715,987783,987832,987873,987883,987913,987935,990350,990369,990377,990384,990394,990398,990404,990434,990449,1001279,1001452
-/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java:728674,731798,733539,751964,761709,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980
+/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java:728674,731798,732539,732541,732873,732877,733293,733295,733304,733306,733348,733354,733394,733399,733463-733464,733533,733539,733676,751964,761709,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980

Propchange: axis/axis2/java/core/branches/1_5/modules/parent/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 30 17:26:27 2010
@@ -1,2 +1,2 @@
 /axis/axis2/java/core/trunk/modules/parent:922914,922941,922983,935169,935174,935338,936434,944347,944915,951385,960693,960976,960978,960984,960995,961012,961964,962844,963081,963147,965032,965036,965056,965068,965074,965213,965268,965277,965302,965454,966371,966401,966428,979882-979883,979886,981036,981038,981095,981188,981220-981221,981237,981262,981278,981293,981306,981311,981985,982387,982393,982795,982800,983101,983110,983114,983119-983120,983128,983185,983236,983270,983276,983280,983316,983363,983370,983372,985458,985464,985626,985634,985661,985715,985717,985744,985748,985752,985763,985791,985796,985851,986844,986889,987313,987712-987715,987783,987832,987873,987883,987913,987935,990350,990369,990377,990384,990394,990398,990404,990434,990449,1001279,1001452
-/webservices/axis2/trunk/java/modules/parent:728674,731798,732924,732927,732939,733539,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980
+/webservices/axis2/trunk/java/modules/parent:728674,731798,732539,732541,732873,732877,732924,732927,732939,733293,733295,733304,733306,733348,733354,733394,733399,733463-733464,733533,733539,733676,733776,741873,748761,751964,754458,754467,754503,757151-757153,759488,759507,759878,759968,761025,761044,761709,761770,761952,763148,765102,771051,777648,777882,777897,777934,778060,780546,783479,795431,801630,803725,805578,805981,805999,806085,806331,807160,807487,807512,816740,816804,816812,816891,817965,821686,821689,834058,834175,902271,904660,904780,905980

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/pom.xml?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/pom.xml (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/pom.xml Sat Oct 30 17:26:27 2010
@@ -67,6 +67,18 @@
             <artifactId>log4j</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.sun.xml.messaging.saaj</groupId>
+            <artifactId>saaj-impl</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.xml.soap</groupId>
+                    <artifactId>saaj-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
     <build>
         <sourceDirectory>src</sourceDirectory>

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java Sat Oct 30 17:26:27 2010
@@ -192,7 +192,6 @@ public class AttachmentPartImpl extends 
     public void setContent(Object object, String contentType) {
         SAAJDataSource source;
         setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType);
-        Object contentObject;
         if (object instanceof String) {
             try {
                 String s = (String)object;
@@ -202,7 +201,6 @@ public class AttachmentPartImpl extends 
                                             contentType, true);
                 extractFilename(source);
                 this.dataHandler = new DataHandler(source);
-                contentObject = object;
             } catch (java.io.IOException io) {
                 throw new java.lang.IllegalArgumentException("Illegal Argument");
             }
@@ -214,7 +212,6 @@ public class AttachmentPartImpl extends 
                                             contentType, true);
                 extractFilename(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");
             }
@@ -225,20 +222,17 @@ public class AttachmentPartImpl extends 
                                             contentType, true);
                 extractFilename(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 {
                 this.dataHandler = new DataHandler(object, contentType);
-                contentObject = null; // the stream has been consumed
             } catch (Exception e) {
                 throw new java.lang.IllegalArgumentException(e.getMessage());
             }
         } else if (object instanceof byte[]) {
             try {
-                contentObject = null;
                 java.io.ByteArrayInputStream bais =
                         new java.io.ByteArrayInputStream((byte[])object);
                 source = new SAAJDataSource(bais,
@@ -247,7 +241,6 @@ public class AttachmentPartImpl extends 
                 extractFilename(source);
 
                 this.dataHandler = new DataHandler(source);
-                contentObject = object;
             } catch (Exception e) {
                 throw new java.lang.IllegalArgumentException(e.getMessage());
             }

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java Sat Oct 30 17:26:27 2010
@@ -19,6 +19,7 @@
 
 package org.apache.axis2.saaj;
 
+import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
@@ -33,6 +34,7 @@ import org.apache.axis2.client.ServiceCl
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.DispatchPhase;
+import org.apache.axis2.engine.Phase;
 import org.apache.axis2.saaj.util.IDGenerator;
 import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.saaj.util.UnderstandAllHeadersHandler;
@@ -56,12 +58,10 @@ import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.StringTokenizer;
 
 
@@ -74,8 +74,6 @@ public class SOAPConnectionImpl extends 
     private boolean closed = false;
 
     private ServiceClient serviceClient;
-    private HashMap unaccessedAttachments = new HashMap();
-
 
     /**
      * Sends the given message to the specified endpoint and blocks until it has returned the
@@ -122,12 +120,77 @@ public class SOAPConnectionImpl extends 
 
         opClient.setOptions(options);
 
-        if (request.countAttachments() != 0) { // SOAPMessage with attachments
-            opClient.getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
-                                              Constants.VALUE_TRUE);
-            return handleSOAPMessage(request, opClient);
-        } else { // simple SOAPMessage
-            return handleSOAPMessage(request, opClient);
+        MessageContext requestMsgCtx = new MessageContext();
+        org.apache.axiom.soap.SOAPEnvelope envelope =
+                SAAJUtil.toOMSOAPEnvelope(request.getSOAPPart().getDocumentElement());
+        if (isMTOM(request)) {
+            Map<String,DataHandler> attachmentMap = new HashMap<String,DataHandler>();
+            for (Iterator it = request.getAttachments(); it.hasNext(); ) {
+                AttachmentPart attachment = (AttachmentPart)it.next();
+                String contentId = attachment.getContentId();
+                if (contentId != null) {
+                    DataHandler dh = attachment.getDataHandler();
+                    if (dh == null) {
+                        throw new SOAPException("Attachment with NULL DataHandler");
+                    }
+                    attachmentMap.put(contentId, dh);
+                }
+            }
+            insertAttachmentNodes(attachmentMap, envelope);
+            options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        } else if (request.countAttachments() != 0) { // SOAPMessage with attachments
+            Attachments attachments = requestMsgCtx.getAttachmentMap();
+            for (Iterator it = request.getAttachments(); it.hasNext(); ) {
+                AttachmentPart attachment = (AttachmentPart)it.next();
+                String contentId = attachment.getContentId();
+                // Axiom currently doesn't support attachments without Content-ID
+                // (see WSCOMMONS-418); generate one if necessary.
+                if (contentId == null) {
+                    contentId = IDGenerator.generateID();
+                }
+                attachments.addDataHandler(contentId, attachment.getDataHandler());
+            }
+            options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
+        }
+        
+        MessageContext responseMsgCtx;
+        try {
+            requestMsgCtx.setEnvelope(envelope);
+            opClient.addMessageContext(requestMsgCtx);
+            opClient.execute(true);
+            responseMsgCtx =
+                    opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        } catch (AxisFault ex) {
+            throw new SOAPException(ex.getMessage(), ex);
+        }
+        
+        SOAPMessage response = getSOAPMessage(responseMsgCtx.getEnvelope());
+        Attachments attachments = requestMsgCtx.getAttachmentMap();
+        for (String contentId : attachments.getAllContentIDs()) {
+            if (!contentId.equals(attachments.getSOAPPartContentID())) {
+                AttachmentPart ap = response.createAttachmentPart(
+                        attachments.getDataHandler(contentId));
+                ap.setContentId(contentId);
+                response.addAttachmentPart(ap);
+            }
+        }
+
+        try {
+            requestMsgCtx.getTransportOut().getSender().cleanup(requestMsgCtx);
+        } catch (AxisFault axisFault) {
+            // log error
+        }
+
+        return response;
+    }
+
+    private static boolean isMTOM(SOAPMessage soapMessage) {
+        SOAPPart soapPart = soapMessage.getSOAPPart();
+        String[] contentTypes = soapPart.getMimeHeader("Content-Type");
+        if (contentTypes != null && contentTypes.length > 0) {
+            return SAAJUtil.normalizeContentType(contentTypes[0]).equals("application/xop+xml");
+        } else {
+            return false;
         }
     }
 
@@ -147,10 +210,8 @@ public class SOAPConnectionImpl extends 
         }
     }
     
-    private static DispatchPhase getDispatchPhase(List phases) {
-        Iterator iter = phases.iterator();
-        while(iter.hasNext()) {
-            Object phase = iter.next();
+    private static DispatchPhase getDispatchPhase(List<Phase> phases) {
+        for (Phase phase : phases) {
             if (phase instanceof DispatchPhase) {
                 return (DispatchPhase)phase;
             }
@@ -178,29 +239,6 @@ public class SOAPConnectionImpl extends 
         closed = true;
     }
 
-    private SOAPMessage handleSOAPMessage(SOAPMessage request,
-                                          OperationClient opClient) throws SOAPException {
-
-        MessageContext requestMsgCtx = new MessageContext();
-        try {
-            requestMsgCtx.setEnvelope(toOMSOAPEnvelope(request));
-            opClient.addMessageContext(requestMsgCtx);
-            opClient.execute(true);
-
-            MessageContext msgCtx =
-                    opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-            return getSOAPMessage(msgCtx.getEnvelope());
-        } catch (Exception e) {
-            throw new SOAPException(e.getMessage(), e);
-        } finally {
-            try {
-                requestMsgCtx.getTransportOut().getSender().cleanup(requestMsgCtx);      
-            } catch (Exception e) {
-                // ignore the error, better to log somewhere if possible.
-            }
-        }
-    }
-
     /**
      * This method handles the conversion of an OM SOAP Envelope to a SAAJ SOAPMessage
      *
@@ -248,15 +286,6 @@ public class SOAPConnectionImpl extends 
 
         // 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;
     }
@@ -327,61 +356,14 @@ public class SOAPConnectionImpl extends 
     }
 
     /**
-     * Converts a SAAJ SOAPMessage to an OM SOAPEnvelope
-     *
-     * @param saajSOAPMsg
-     * @return
-     * @throws SOAPException
-     */
-    protected org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(SOAPMessage saajSOAPMsg)
-            throws SOAPException {
-
-        final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
-                SAAJUtil.toOMSOAPEnvelope(saajSOAPMsg.getSOAPPart().getDocumentElement());
-
-
-        Map attachmentMap = new HashMap();
-        final Iterator attachments = saajSOAPMsg.getAttachments();
-        while (attachments.hasNext()) {
-            final AttachmentPart attachment = (AttachmentPart)attachments.next();
-            if (attachment.getContentId() == null ||
-                    attachment.getContentId().trim().length() == 0) {
-                attachment.setContentId(IDGenerator.generateID());
-            }
-            if (attachment.getDataHandler() == null) {
-                throw new SOAPException("Attachment with NULL DataHandler");
-            }
-            attachmentMap.put(attachment.getContentId(), attachment);
-        }
-
-        //Get keys of attachments to a hashmap
-        //This hashmap will be updated when attachment is accessed atleast once.
-        //Doing this here instead of inside insertAttachmentNodes()is much simpler
-        //as insertAttachmentNodes() has recursive calls
-        Set keySet = attachmentMap.keySet();
-        Iterator keySetItr = keySet.iterator();
-        HashMap keyAccessStatus = new HashMap();
-        while (keySetItr.hasNext()) {
-            String key = (String)keySetItr.next();
-            keyAccessStatus.put(key, "not-accessed");
-        }
-
-        insertAttachmentNodes(attachmentMap, omSOAPEnv, keyAccessStatus);
-        unaccessedAttachments =
-                getUnReferencedAttachmentNodes(attachmentMap, omSOAPEnv, keyAccessStatus);
-
-        return omSOAPEnv;
-    }
-
-    /**
      * Inserts the attachments in the proper places
      *
      * @param attachments
      * @param omEnvelope
      * @throws SOAPException
      */
-    private void insertAttachmentNodes(Map attachments,
-                                       OMElement omEnvelope, HashMap keyAccessStatus)
+    private void insertAttachmentNodes(Map<String,DataHandler> attachments,
+                                       OMElement omEnvelope)
             throws SOAPException {
 
         Iterator childIter = omEnvelope.getChildElements();
@@ -392,43 +374,18 @@ public class SOAPConnectionImpl extends 
 
             if (contentID != null) {//This is an omEnvelope referencing an attachment
                 child.build();
-                AttachmentPart ap = ((AttachmentPart)attachments.get(contentID.trim()));
+                DataHandler dh = attachments.get(contentID.trim());
                 //update the key status as accessed
-                keyAccessStatus.put(contentID.trim(), "accessed");
-                OMText text = new OMTextImpl(ap.getDataHandler(), true,
+                OMText text = new OMTextImpl(dh, true,
                                              omEnvelope.getOMFactory());
                 child.removeAttribute(hrefAttr);
                 child.addChild(text);
             } else {
                 //possibly there can be references in the children of this omEnvelope
                 //so recurse through.
-                insertAttachmentNodes(attachments, child, keyAccessStatus);
-            }
-        }
-    }
-
-
-    private HashMap getUnReferencedAttachmentNodes(Map attachments,
-                                                   OMElement omEnvelope, HashMap keyAccessStatus)
-            throws SOAPException {
-
-        HashMap unaccessedAttachments = new HashMap();
-        //now check for unaccessed keys
-        Set keySet = keyAccessStatus.keySet();
-        Iterator keySetItr = keySet.iterator();
-        while (keySetItr.hasNext()) {
-            String key = (String)keySetItr.next();
-            String keyStatus = (String)keyAccessStatus.get(key);
-            if ("not-accessed".equals(keyStatus)) {
-                //The value for this key has not been accessed in the
-                //referencing attachment scenario.Hence it must be an
-                //unreferenced one.
-                AttachmentPart ap = ((AttachmentPart)attachments.get(key));
-                unaccessedAttachments.put(key, ap);
-                keyAccessStatus.put(key, "accessed");
+                insertAttachmentNodes(attachments, child);
             }
         }
-        return unaccessedAttachments;
     }
 
     /**

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java Sat Oct 30 17:26:27 2010
@@ -27,6 +27,7 @@ import org.apache.axiom.soap.SOAP12Const
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
+import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.transport.http.HTTPConstants;
 
 import javax.activation.DataHandler;
@@ -55,30 +56,19 @@ public class SOAPMessageImpl extends SOA
 
     private SOAPPart soapPart;
     private Collection<AttachmentPart> attachmentParts = new ArrayList<AttachmentPart>();
-    private MimeHeadersEx mimeHeaders;
+    private MimeHeaders mimeHeaders;
 
-    private Map props = new Hashtable();
+    private Map<String,Object> props = new Hashtable<String,Object>();
     private boolean saveRequired;
 
     public SOAPMessageImpl(SOAPEnvelopeImpl soapEnvelope) {
-        String contentType = null;
-
-
-        if (mimeHeaders != null) {
-            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);
-            }
+        this.mimeHeaders = new MimeHeaders();
+        if (soapEnvelope.getOMFactory() instanceof SOAP11Factory) {
+            this.mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_TEXT_XML);
+        } else if (soapEnvelope.getOMFactory() instanceof SOAP12Factory) {
+            this.mimeHeaders.addHeader("content-type",
+                    HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
         }
-
-        setCharsetEncoding(contentType);
         soapPart = new SOAPPartImpl(this, soapEnvelope);
     }
 
@@ -90,18 +80,10 @@ public class SOAPMessageImpl extends SOA
             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;
-                }
+                contentType = SAAJUtil.normalizeContentType(tmpContentType);
             }
         }
-        //Setting the whole content-type string to CharsetEncoding.
-        //Is this correct?
-        setCharsetEncoding(tmpContentType);
+        initCharsetEncodingFromContentType(tmpContentType);
         if (contentType != null) {
             soapPart = new SOAPPartImpl(this, inputstream, mimeHeaders);
         } else {
@@ -109,8 +91,8 @@ public class SOAPMessageImpl extends SOA
         }
 
         this.mimeHeaders = (mimeHeaders == null) ?
-                new MimeHeadersEx() :
-                new MimeHeadersEx(mimeHeaders);
+                new MimeHeaders() :
+                SAAJUtil.copyMimeHeaders(mimeHeaders);
     }
 
     /**
@@ -193,7 +175,7 @@ public class SOAPMessageImpl extends SOA
      *         header that matches one of the given headers
      */
     public Iterator getAttachments(javax.xml.soap.MimeHeaders headers) {
-        Collection matchingAttachmentParts = new ArrayList();
+        Collection<AttachmentPart> matchingAttachmentParts = new ArrayList<AttachmentPart>();
         Iterator iterator = getAttachments();
         {
             AttachmentPartImpl part;
@@ -439,14 +421,10 @@ public class SOAPMessageImpl extends SOA
      * @since SAAJ 1.3
      */
     public void removeAttachments(MimeHeaders headers) {
-        Collection newAttachmentParts = new ArrayList();
-        Iterator attachmentPartsItr = attachmentParts.iterator();
-        for (Iterator iter = attachmentPartsItr; iter.hasNext();) {
-            AttachmentPart attachmentPart = (AttachmentPart)iter.next();
-
+        Collection<AttachmentPart> newAttachmentParts = new ArrayList<AttachmentPart>();
+        for (AttachmentPart attachmentPart : attachmentParts) {
             //Get all the headers
-            Iterator allMIMEHeaders = headers.getAllHeaders();
-            for (Iterator iterator = allMIMEHeaders; iterator.hasNext();) {
+            for (Iterator iterator = headers.getAllHeaders(); iterator.hasNext();) {
                 MimeHeader mimeHeader = (MimeHeader)iterator.next();
                 String[] headerValues = attachmentPart.getMimeHeader(mimeHeader.getName());
                 //if values for this header name, do not remove it
@@ -487,7 +465,7 @@ public class SOAPMessageImpl extends SOA
      *
      * @param contentType
      */
-    private void setCharsetEncoding(final String contentType) {
+    private void initCharsetEncodingFromContentType(final String contentType) {
         if (contentType != null) {
             int delimiterIndex = contentType.lastIndexOf("charset");
             if (delimiterIndex > 0) {

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java Sat Oct 30 17:26:27 2010
@@ -31,6 +31,7 @@ import org.apache.axiom.soap.impl.dom.so
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
 import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.saaj.util.IDGenerator;
+import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -52,7 +53,6 @@ import org.w3c.dom.ProcessingInstruction
 import org.w3c.dom.Text;
 import org.w3c.dom.UserDataHandler;
 
-import javax.xml.soap.MimeHeader;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPEnvelope;
@@ -73,7 +73,6 @@ import javax.xml.transform.stream.Stream
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.util.Iterator;
 
 public class SOAPPartImpl extends SOAPPart {
@@ -83,15 +82,13 @@ public class SOAPPartImpl extends SOAPPa
     private Document document;
     private SOAPMessage soapMessage;
     private SOAPEnvelopeImpl envelope;
-    private MimeHeadersEx mimeHeaders = new MimeHeadersEx();
-
-    private Source source;
+    private final MimeHeaders mimeHeaders;
 
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         SOAPEnvelopeImpl soapEnvelope) {
         //setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, IDGenerator.generateID());
         //setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
-        this.mimeHeaders = (MimeHeadersEx)parentSoapMsg.getMimeHeaders();
+        this.mimeHeaders = parentSoapMsg.getMimeHeaders();
         soapMessage = parentSoapMsg;
         envelope = soapEnvelope;
         document = soapEnvelope.getOwnerDocument();
@@ -105,41 +102,31 @@ public class SOAPPartImpl extends SOAPPa
         String fullContentTypeStr = "";
         if (mimeHeaders == null) {
             //TODO : read string from constants
-            mimeHeaders = new MimeHeaders();
-            mimeHeaders.addHeader("Content-ID", IDGenerator.generateID());
-            mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
+            this.mimeHeaders = new MimeHeaders();
+            this.mimeHeaders.addHeader("Content-ID", IDGenerator.generateID());
+            this.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];
-                contentType = extractFirstPart(fullContentTypeStr);
+                contentType = SAAJUtil.normalizeContentType(fullContentTypeStr);
             }
+            this.mimeHeaders = SAAJUtil.copyMimeHeaders(mimeHeaders);
         }
 
-        Iterator mimeHeaderIterator = mimeHeaders.getAllHeaders();
-        while (mimeHeaderIterator.hasNext()) {
-            MimeHeader mimeHeader = (MimeHeader)mimeHeaderIterator.next();
-            String value = mimeHeader.getValue();
-            setMimeHeader(mimeHeader.getName(), value);
-        }
         soapMessage = parentSoapMsg;
 
         String knownEncoding = (String) soapMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
         XMLStreamReader xmlReader = null;
       
         
-        InputStream modifiedInputStream = null;
         StAXSOAPModelBuilder builder = null;
-        InputStreamReader isReader = null;
 
         if (contentType.indexOf("multipart/related") == 0) {
             //This contains attachements
             try {
                 Attachments attachments =
                         new Attachments(inputStream, fullContentTypeStr, false, "", "");
-                modifiedInputStream = attachments.getSOAPPartInputStream();
-               	isReader = new InputStreamReader(modifiedInputStream);
-               
 
                 String soapEnvelopeNamespaceURI =
                         BuilderUtil.getEnvelopeNamespace(fullContentTypeStr);
@@ -180,15 +167,13 @@ public class SOAPPartImpl extends SOAPPa
                 throw new SOAPException(e);
             }
         } else {
-            modifiedInputStream = inputStream;
             try {
-                isReader = new InputStreamReader(modifiedInputStream);
                 XMLStreamReader streamReader = null;
                 
                 if(knownEncoding != null){
-                	streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream, knownEncoding);
+                	streamReader = StAXUtils.createXMLStreamReader(inputStream, knownEncoding);
                 }else{
-                	streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream);                	
+                	streamReader = StAXUtils.createXMLStreamReader(inputStream);                	
                 }
 
                 if (HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(contentType)) {
@@ -201,10 +186,6 @@ public class SOAPPartImpl extends SOAPPa
                                                        new SOAP12Factory(),
                                                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
 
-                } else if (HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED.equals(contentType)) {
-                    builder = new StAXSOAPModelBuilder(streamReader,
-                                                       new SOAP11Factory(),
-                                                       null);
                 } else {
                     builder = new StAXSOAPModelBuilder(streamReader,
                                                        new SOAP11Factory(),
@@ -221,26 +202,11 @@ public class SOAPPartImpl extends SOAPPa
             envelope.element.build();
             this.document = envelope.getOwnerDocument();
             envelope.setSOAPPartParent(this);
-            javax.xml.transform.Source xmlSource =
-                    new javax.xml.transform.stream.StreamSource( isReader);
-            this.source = xmlSource;
         } catch (Exception e) {
             throw new SOAPException(e);
         }
     }
 
-    private String extractFirstPart(String fullContentTypeStr) {
-        String contentType;//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;
-        }
-        return contentType;
-    }
-
-
     public SOAPPartImpl(SOAPMessageImpl parentSoapMsg,
                         InputStream inputStream) throws SOAPException {
         this(parentSoapMsg, inputStream, null);
@@ -370,7 +336,6 @@ public class SOAPPartImpl extends SOAPPa
     }
 
     public void setContent(Source source) throws SOAPException {
-        this.source = source;
         try {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
@@ -422,9 +387,7 @@ public class SOAPPartImpl extends SOAPPa
      * @see #setContent(javax.xml.transform.Source) setContent(javax.xml.transform.Source)
      */
     public Source getContent() throws SOAPException {
-        DOMSource domSource = new DOMSource(this.document);
-        this.source = domSource;
-        return source;
+        return new DOMSource(this.document);
     }
 
     /**

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java Sat Oct 30 17:26:27 2010
@@ -30,8 +30,12 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
 
 /** Utility class for the Axis2-WSS4J Module */
 public class SAAJUtil {
@@ -131,4 +135,32 @@ public class SAAJUtil {
         factory.setNamespaceAware(true);
         return factory.newDocumentBuilder().parse(bais).getDocumentElement();
     }
+
+    /**
+     * Create a copy of an existing {@link MimeHeaders} object.
+     * 
+     * @param headers the object to copy
+     * @return a copy of the {@link MimeHeaders} object
+     */
+    public static MimeHeaders copyMimeHeaders(MimeHeaders headers) {
+        MimeHeaders result = new MimeHeaders();
+        Iterator iterator = headers.getAllHeaders();
+        while (iterator.hasNext()) {
+            MimeHeader hdr = (MimeHeader)iterator.next();
+            result.addHeader(hdr.getName(), hdr.getValue());
+        }
+        return result;
+    }
+
+    /**
+     * Normalize a content type specification. This removes all parameters
+     * from the content type and converts it to lower case.
+     * 
+     * @param contentType the content type to normalize
+     * @return the normalized content type
+     */
+    public static String normalizeContentType(String contentType) {
+        int idx = contentType.indexOf(";");
+        return (idx == -1 ? contentType : contentType.substring(0, idx)).trim().toLowerCase();
+    }
 }

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/message.bin
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/message.bin?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/message.bin (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/test-resources/message.bin Sat Oct 30 17:26:27 2010
@@ -1,14 +1,14 @@
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
-content-type: application/xop+xml; charset=UTF-8; type="text/xml";
-content-transfer-encoding: binary
-content-id: <0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>
-
-<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns-prefix:Header1 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header1</ns-prefix:Header1><ns-prefix:Header2 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header2</ns-prefix:Header2><ns-prefix:Header3 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header3</ns-prefix:Header3><ns-prefix:Header4 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header4</ns-prefix:Header4></soapenv:Header><soapenv:Body><ns-prefix:Body1 xmlns:ns-prefix="ns-uri"><ns-prefix:Child1>This is Child1</ns-prefix:Child1><ns-prefix:Child2>This is Child2</ns-prefix:Child2></ns-prefix:Body1><swa:echo xmlns:swa="http://fakeNamespace.org"><internal xmlns=""><text xmlns=""><xop:Include href="cid:1.urn:uuid:F02ECC18873CFB73E2114127489
 09349@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></text></internal></swa:echo></soapenv:Body></soapenv:Envelope>
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
-content-type: text/xml
-content-transfer-encoding: binary
-content-id: <1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>
-
-TATA
-
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307--
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
+content-type: application/xop+xml; charset=UTF-8; type="text/xml";
+content-transfer-encoding: binary
+content-id: <0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>
+
+<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns-prefix:Header1 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header1</ns-prefix:Header1><ns-prefix:Header2 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header2</ns-prefix:Header2><ns-prefix:Header3 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header3</ns-prefix:Header3><ns-prefix:Header4 xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header4</ns-prefix:Header4></soapenv:Header><soapenv:Body><ns-prefix:Body1 xmlns:ns-prefix="ns-uri"><ns-prefix:Child1>This is Child1</ns-prefix:Child1><ns-prefix:Child2>This is Child2</ns-prefix:Child2></ns-prefix:Body1><swa:echo xmlns:swa="http://fakeNamespace.org"><internal xmlns=""><text xmlns=""><xop:Include href="cid:1.urn:uuid:F02ECC18873CFB73E2114127489
 09349@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></text></internal></swa:echo></soapenv:Body></soapenv:Envelope>
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
+content-type: text/xml
+content-transfer-encoding: binary
+content-id: <1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>
+
+TATA
+
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307--

Modified: axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java?rev=1029125&r1=1029124&r2=1029125&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java (original)
+++ axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java Sat Oct 30 17:26:27 2010
@@ -21,11 +21,17 @@ package org.apache.axis2.saaj;
 
 import org.custommonkey.xmlunit.XMLTestCase;
 
+import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
 
 /**
  * 
@@ -127,4 +133,60 @@ public class MessageFactoryTest extends 
             fail("Exception: " + e);
         }
     }
+
+    // Unit tests for (unresolved) issue AXIS2-4189
+/*    
+    public void testParseMTOMMessage() throws Exception {
+        SAAJTestUtil.execute(new SAAJTestUtil.Test() {
+            public void execute(MessageFactory mf) throws Exception {
+                MimeHeaders headers = new MimeHeaders();
+                headers.addHeader("Content-Type",
+                        "multipart/related; " +
+                        "boundary=\"MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307\"; " +
+                        "type=\"application/xop+xml\"; " +
+                        "start=\"<0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>\"; " +
+                        "start-info=\"text/xml\"; " +
+                        "charset=UTF-8;" +
+                        "action=\"mtomSample\"");
+                InputStream in = new FileInputStream(System.getProperty("basedir", ".")
+                        + "/test-resources/message.bin");
+                SOAPMessage message = mf.createMessage(headers, in);
+                SOAPPart soapPart = message.getSOAPPart();
+                assertEquals("<0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>",
+                        soapPart.getContentId());
+                Iterator attachments = message.getAttachments();
+                assertTrue(attachments.hasNext());
+                AttachmentPart ap = (AttachmentPart)attachments.next();
+                assertEquals("<1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>",
+                        ap.getContentId());
+                assertFalse(attachments.hasNext());
+            }
+        });
+    }
+
+    public void testParseSwAMessage() throws Exception {
+        SAAJTestUtil.execute(new SAAJTestUtil.Test() {
+            public void execute(MessageFactory mf) throws Exception {
+                MimeHeaders headers = new MimeHeaders();
+                headers.addHeader("Content-Type",
+                        "multipart/related; " +
+                        "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616; " +
+                        "type=\"text/xml\"; " +
+                        "start=\"<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>\"");
+                InputStream in = new FileInputStream(System.getProperty("basedir", ".")
+                        + "/test-resources/SwAmessage.bin");
+                SOAPMessage message = mf.createMessage(headers, in);
+                SOAPPart soapPart = message.getSOAPPart();
+                assertEquals("<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>",
+                        soapPart.getContentId());
+                Iterator attachments = message.getAttachments();
+                assertTrue(attachments.hasNext());
+                AttachmentPart ap = (AttachmentPart)attachments.next();
+                assertEquals("<urn:uuid:E3F7CE4554928DA89B1231365678347>",
+                        ap.getContentId());
+                assertFalse(attachments.hasNext());
+            }
+        });
+    }
+*/
 }



Mime
View raw message