You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2007/04/26 10:21:06 UTC

svn commit: r532651 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ core/src/main/java/org/apache/cxf/attachment/ core/src/test/java/org/apache/cxf/attachment/

Author: ffang
Date: Thu Apr 26 01:21:05 2007
New Revision: 532651

URL: http://svn.apache.org/viewvc?view=rev&rev=532651
Log:
[CXF-605] extract boundary from message body in AttachmentDeserializer
 

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?view=diff&rev=532651&r1=532650&r2=532651
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Thu Apr 26 01:21:05 2007
@@ -30,6 +30,8 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
 import javax.xml.stream.XMLStreamWriter;
+import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
+
 
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -41,6 +43,8 @@
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
+
+
 /**
  * Sets up the outgoing chain to build a SAAJ tree instead of writing
  * directly to the output stream. First it will replace the XMLStreamWriter
@@ -89,8 +93,10 @@
             SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
 
             if (soapMessage != null) {
+                
                 OutputStream os = message.getContent(OutputStream.class);
                 try {
+                    setMessageContent(message, soapMessage);
                     soapMessage.writeTo(os);
                     os.flush();
                 } catch (IOException e) {
@@ -99,8 +105,28 @@
                 } catch (SOAPException e) {
                     throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, message.getVersion()
                         .getSender());
+                } catch (MessagingException e) {
+                    throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, message.getVersion()
+                        .getSender());
+                }
+            }
+        }
+
+        private void setMessageContent(SoapMessage message, SOAPMessage soapMessage) 
+            throws MessagingException, SOAPException {
+            
+            if (soapMessage.getAttachments().hasNext()) {
+                StringBuffer sb = new StringBuffer();
+                for (String str : soapMessage.getMimeHeaders().getHeader("Content-Type")) {
+                    sb.append(str);
+                }
+                String contentType = sb.toString();
+                if (contentType != null && contentType.length() > 0) {
+                    message.put(org.apache.cxf.message.Message.CONTENT_TYPE, contentType);
                 }
+                    
             }
+            
         }
 
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?view=diff&rev=532651&r1=532650&r2=532651
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java Thu Apr 26 01:21:05 2007
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.attachment;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PushbackInputStream;
@@ -32,6 +34,7 @@
 import javax.mail.internet.InternetHeaders;
 
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 
@@ -75,31 +78,21 @@
             throw new IllegalStateException("Content-Type can not be empty!");
         }
         
-        InputStream input = message.getContent(InputStream.class);
-        if (input == null) {
-            throw new IllegalStateException("An InputStream must be provided!");
-        }
+        
 
         if (contentType.toLowerCase().indexOf("multipart/related") != -1) {
-            int i = contentType.indexOf("boundary=\"");
-            int end;
-            int len;
-            if (i == -1) {
-                i = contentType.indexOf("boundary=");
-                end = contentType.indexOf(";", i + 9);
-                if (end == -1) {
-                    end = contentType.length();
-                }
-                len = 9;
-            } else {
-                end = contentType.indexOf("\"", i + 10);
-                len = 10;
-            }
-            if (i == -1 || end == -1) {
-                throw new IOException("Invalid content type: missing boundary! " + contentType);
+            boundary = findBoundry();
+            boundary = "--" + boundary;
+            
+            
+            InputStream input = message.getContent(InputStream.class);
+            if (input == null) {
+                throw new IllegalStateException("An InputStream must be provided!");
             }
-            boundary = "--" + contentType.substring(i + len, end);
-            stream = new PushbackInputStream(input, boundary.length());
+            stream = new PushbackInputStream(input, boundary.getBytes().length);
+            
+            
+            
             if (!readTillFirstBoundary(stream, boundary.getBytes())) {
                 throw new IOException("Couldn't find MIME boundary: " + boundary);
             }
@@ -116,6 +109,30 @@
         }
     }
 
+    private String findBoundry() {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            InputStream is = message.getContent(InputStream.class);
+            IOUtils.copy(is, bos);
+
+            is.close();
+            bos.close();
+            String msg = bos.toString();
+            message.setContent(InputStream.class, new ByteArrayInputStream(bos.toByteArray()));
+            if (msg.indexOf("----=_Part_") == -1) {
+                return null;
+            } else {
+                int begin = msg.indexOf("----=_Part_");
+                int end = msg.indexOf(".", begin) + 14;
+                return msg.substring(begin, end);
+            }
+
+        } catch (IOException e) {
+            throw new Fault(e);
+        }
+
+    }
+    
     public AttachmentImpl readNext() throws IOException {
         // Cache any mime parts that are currently being streamed
         cacheStreamedAttachments();

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?view=diff&rev=532651&r1=532650&r2=532651
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java Thu Apr 26 01:21:05 2007
@@ -84,6 +84,52 @@
         String ct = "multipart/related; type=\"text/xml\"; "
             + "start=\"<86048FF3556694F7DA1918466DDF8143>\";    "
             + "boundary=\"----=_Part_0_14158819.1167275505862\"";
+
+        
+        MessageImpl msg = new MessageImpl();
+        msg.put(Message.CONTENT_TYPE, ct);
+        msg.setContent(InputStream.class, is);
+        
+        AttachmentDeserializer deserializer = new AttachmentDeserializer(msg);
+        deserializer.initializeAttachments();
+        
+        InputStream attBody = msg.getContent(InputStream.class);
+        assertTrue(attBody != is);
+        assertTrue(attBody instanceof DelegatingInputStream);
+        
+        Collection<Attachment> atts = msg.getAttachments();
+        assertNotNull(atts);
+        
+        Iterator<Attachment> itr = atts.iterator();
+        assertTrue(itr.hasNext());
+        
+        Attachment a = itr.next();
+        assertNotNull(a);
+        
+        InputStream attIs = a.getDataHandler().getInputStream();
+        
+        assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof MimeBodyPartInputStream);
+        assertTrue(((DelegatingInputStream) attBody).getInputStream() instanceof ByteArrayInputStream);
+        
+        // check the cached output stream
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        IOUtils.copy(attBody, out);
+        assertTrue(out.toString().startsWith("<?xml"));
+        
+        // try streaming a character off the wire
+        assertTrue(attIs.read() == 'f');
+        assertTrue(attIs.read() == 'o');
+        assertTrue(attIs.read() == 'o');
+        assertTrue(attIs.read() == 'b');
+        assertTrue(attIs.read() == 'a');
+        assertTrue(attIs.read() == 'r');
+        assertTrue(attIs.read() == -1);
+    }
+    
+    public void testDeserializerSwAWithoutBoundryInContentType() throws Exception {
+        InputStream is = getClass().getResourceAsStream("swadata");
+        String ct = "multipart/related; type=\"text/xml\"; ";
+
         
         MessageImpl msg = new MessageImpl();
         msg.put(Message.CONTENT_TYPE, ct);



Re: svn commit: r532651 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ core/src/main/java/org/apache/cxf/attachment/ core/src/test/java/org/apache/cxf/attachment/

Posted by Peter Jones <pe...@iona.com>.
On Thu, May 03, 2007 at 02:00:47PM +0200, Dan Diephouse wrote:
> I don't think this is a very good thing either...  so I'm -1 on catching the
> Sun MessageException. Freeman, can you please change this so we aren't
> dependent on the Sun SAAJ impl?

It seems Freeman is on vacation.  The sun saaj should only be throwing
either an IOException or SOAPException (which we have catch clauses for) in
the spot where we catch the MessagingException.  I've removed the catch for
the sun MessagingException and everything continues to pass (actually, I'm
not seeing a MessagingException being thrown at all).  So I think I'll go
ahead and commit this change.  Let me know if this causes problems for
anyone...

Cheers,
Peter

> Thanks!
> - Dan
> 
> On 5/3/07, Peter Jones <pe...@iona.com> wrote:
> >
> >
> > Hi there,
> >
> > I had a question about this commit 532651.  The SAAJOutInterceptor.javanow
> > uses an internal sun saaj class, i.e., it catches
> >
> > com.sun.xml.messaging.saaj.packaging.mime.MessagingException
> >
> > I'm not sure if this is a "good thing".  The reason is you can't use the
> > ibm
> > jdk with the sun saaj implementation, because it has dependencies on some
> > sun jaxp classes - classes which can be found in the sun jdk, but are
> > missing from the ibm jdk.  Before this commit, I could compile with the
> > ibm
> > jdk and run the tests (although some tests would fail), by replacing the
> > sun
> > saaj dependencies with the axis2 saaj implementation for instance.  I'm
> > just
> > wondering if it would be better if we didn't add a hard dependency on the
> > sun saaj implementation like this - especially since it seems to be just
> > an
> > exception class we are catching...
> >
> > Does anyone have any thoughts?
> >
> > Cheers,
> > Peter
> >
> > On Thu, Apr 26, 2007 at 08:21:06AM -0000, ffang@apache.org wrote:
> > > Author: ffang
> > > Date: Thu Apr 26 01:21:05 2007
> > > New Revision: 532651
> > >
> > > URL: http://svn.apache.org/viewvc?view=rev&rev=532651
> > > Log:
> > > [CXF-605] extract boundary from message body in AttachmentDeserializer
> > >
> > >
> > > Modified:
> > >
> > incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> > >
> > incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
> > >
> > incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
> > >
> > > Modified:
> > incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> > > URL:
> > http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?view=diff&rev=532651&r1=532650&r2=532651
> > >
> > ==============================================================================
> > > ---
> > incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> > (original)
> > > +++
> > incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> > Thu Apr 26 01:21:05 2007
> > > @@ -30,6 +30,8 @@
> > >  import javax.xml.soap.SOAPMessage;
> > >  import javax.xml.soap.SOAPPart;
> > >  import javax.xml.stream.XMLStreamWriter;
> > > +import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
> > > +
> > >
> > >  import org.apache.cxf.binding.soap.SoapFault;
> > >  import org.apache.cxf.binding.soap.SoapMessage;
> > > @@ -41,6 +43,8 @@
> > >  import org.apache.cxf.phase.Phase;
> > >  import org.apache.cxf.staxutils.W3CDOMStreamWriter;
> > >
> > > +
> > > +
> > >  /**
> > >   * Sets up the outgoing chain to build a SAAJ tree instead of writing
> > >   * directly to the output stream. First it will replace the
> > XMLStreamWriter
> > > @@ -89,8 +93,10 @@
> > >              SOAPMessage soapMessage = message.getContent(
> > SOAPMessage.class);
> > >
> > >              if (soapMessage != null) {
> > > +
> > >                  OutputStream os = message.getContent(OutputStream.class
> > );
> > >                  try {
> > > +                    setMessageContent(message, soapMessage);
> > >                      soapMessage.writeTo(os);
> > >                      os.flush();
> > >                  } catch (IOException e) {
> > > @@ -99,8 +105,28 @@
> > >                  } catch (SOAPException e) {
> > >                      throw new SoapFault(new Message("SOAPEXCEPTION",
> > BUNDLE), e, message.getVersion()
> > >                          .getSender());
> > > +                } catch (MessagingException e) {
> > > +                    throw new SoapFault(new Message("SOAPEXCEPTION",
> > BUNDLE), e, message.getVersion()
> > > +                        .getSender());
> > > +                }
> > > +            }
> > > +        }
> > > +
> > > +        private void setMessageContent(SoapMessage message, SOAPMessage
> > soapMessage)
> > > +            throws MessagingException, SOAPException {
> > > +
> > > +            if (soapMessage.getAttachments().hasNext()) {
> > > +                StringBuffer sb = new StringBuffer();
> > > +                for (String str : soapMessage.getMimeHeaders().getHeader("Content-Type"))
> > {
> > > +                    sb.append(str);
> > > +                }
> > > +                String contentType = sb.toString();
> > > +                if (contentType != null && contentType.length() > 0) {
> > > +                    message.put(
> > org.apache.cxf.message.Message.CONTENT_TYPE, contentType);
> > >                  }
> > > +
> > >              }
> > > +
> > >          }
> > >
> > >      }
> > > [...]
> >
> > --
> > Peter Jones
> > IONA Technologies Inc.
> > E-Mail: mailto:peter.jones@iona.com
> > Tel: (w) 709-738-3725 x22 | Fax: 709-738-3745
> > 84-86 Elizabeth Ave. St. John's, NL A1A 1W7 Canada
> >
> 
> 
> 
> -- 
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog

-- 
Peter Jones
IONA Technologies Inc.
E-Mail: mailto:peter.jones@iona.com
Tel: (w) 709-738-3725 x22 | Fax: 709-738-3745
84-86 Elizabeth Ave. St. John's, NL A1A 1W7 Canada

Re: svn commit: r532651 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ core/src/main/java/org/apache/cxf/attachment/ core/src/test/java/org/apache/cxf/attachment/

Posted by Dan Diephouse <da...@envoisolutions.com>.
I don't think this is a very good thing either...  so I'm -1 on catching the
Sun MessageException. Freeman, can you please change this so we aren't
dependent on the Sun SAAJ impl?

Thanks!
- Dan

On 5/3/07, Peter Jones <pe...@iona.com> wrote:
>
>
> Hi there,
>
> I had a question about this commit 532651.  The SAAJOutInterceptor.javanow
> uses an internal sun saaj class, i.e., it catches
>
> com.sun.xml.messaging.saaj.packaging.mime.MessagingException
>
> I'm not sure if this is a "good thing".  The reason is you can't use the
> ibm
> jdk with the sun saaj implementation, because it has dependencies on some
> sun jaxp classes - classes which can be found in the sun jdk, but are
> missing from the ibm jdk.  Before this commit, I could compile with the
> ibm
> jdk and run the tests (although some tests would fail), by replacing the
> sun
> saaj dependencies with the axis2 saaj implementation for instance.  I'm
> just
> wondering if it would be better if we didn't add a hard dependency on the
> sun saaj implementation like this - especially since it seems to be just
> an
> exception class we are catching...
>
> Does anyone have any thoughts?
>
> Cheers,
> Peter
>
> On Thu, Apr 26, 2007 at 08:21:06AM -0000, ffang@apache.org wrote:
> > Author: ffang
> > Date: Thu Apr 26 01:21:05 2007
> > New Revision: 532651
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=532651
> > Log:
> > [CXF-605] extract boundary from message body in AttachmentDeserializer
> >
> >
> > Modified:
> >
> incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> >
> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
> >
> incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
> >
> > Modified:
> incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> > URL:
> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?view=diff&rev=532651&r1=532650&r2=532651
> >
> ==============================================================================
> > ---
> incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> (original)
> > +++
> incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> Thu Apr 26 01:21:05 2007
> > @@ -30,6 +30,8 @@
> >  import javax.xml.soap.SOAPMessage;
> >  import javax.xml.soap.SOAPPart;
> >  import javax.xml.stream.XMLStreamWriter;
> > +import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
> > +
> >
> >  import org.apache.cxf.binding.soap.SoapFault;
> >  import org.apache.cxf.binding.soap.SoapMessage;
> > @@ -41,6 +43,8 @@
> >  import org.apache.cxf.phase.Phase;
> >  import org.apache.cxf.staxutils.W3CDOMStreamWriter;
> >
> > +
> > +
> >  /**
> >   * Sets up the outgoing chain to build a SAAJ tree instead of writing
> >   * directly to the output stream. First it will replace the
> XMLStreamWriter
> > @@ -89,8 +93,10 @@
> >              SOAPMessage soapMessage = message.getContent(
> SOAPMessage.class);
> >
> >              if (soapMessage != null) {
> > +
> >                  OutputStream os = message.getContent(OutputStream.class
> );
> >                  try {
> > +                    setMessageContent(message, soapMessage);
> >                      soapMessage.writeTo(os);
> >                      os.flush();
> >                  } catch (IOException e) {
> > @@ -99,8 +105,28 @@
> >                  } catch (SOAPException e) {
> >                      throw new SoapFault(new Message("SOAPEXCEPTION",
> BUNDLE), e, message.getVersion()
> >                          .getSender());
> > +                } catch (MessagingException e) {
> > +                    throw new SoapFault(new Message("SOAPEXCEPTION",
> BUNDLE), e, message.getVersion()
> > +                        .getSender());
> > +                }
> > +            }
> > +        }
> > +
> > +        private void setMessageContent(SoapMessage message, SOAPMessage
> soapMessage)
> > +            throws MessagingException, SOAPException {
> > +
> > +            if (soapMessage.getAttachments().hasNext()) {
> > +                StringBuffer sb = new StringBuffer();
> > +                for (String str : soapMessage.getMimeHeaders().getHeader("Content-Type"))
> {
> > +                    sb.append(str);
> > +                }
> > +                String contentType = sb.toString();
> > +                if (contentType != null && contentType.length() > 0) {
> > +                    message.put(
> org.apache.cxf.message.Message.CONTENT_TYPE, contentType);
> >                  }
> > +
> >              }
> > +
> >          }
> >
> >      }
> > [...]
>
> --
> Peter Jones
> IONA Technologies Inc.
> E-Mail: mailto:peter.jones@iona.com
> Tel: (w) 709-738-3725 x22 | Fax: 709-738-3745
> 84-86 Elizabeth Ave. St. John's, NL A1A 1W7 Canada
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: svn commit: r532651 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ core/src/main/java/org/apache/cxf/attachment/ core/src/test/java/org/apache/cxf/attachment/

Posted by Peter Jones <pe...@iona.com>.
Hi there,

I had a question about this commit 532651.  The SAAJOutInterceptor.java now
uses an internal sun saaj class, i.e., it catches

com.sun.xml.messaging.saaj.packaging.mime.MessagingException

I'm not sure if this is a "good thing".  The reason is you can't use the ibm
jdk with the sun saaj implementation, because it has dependencies on some
sun jaxp classes - classes which can be found in the sun jdk, but are
missing from the ibm jdk.  Before this commit, I could compile with the ibm
jdk and run the tests (although some tests would fail), by replacing the sun
saaj dependencies with the axis2 saaj implementation for instance.  I'm just
wondering if it would be better if we didn't add a hard dependency on the
sun saaj implementation like this - especially since it seems to be just an
exception class we are catching...

Does anyone have any thoughts?

Cheers,
Peter

On Thu, Apr 26, 2007 at 08:21:06AM -0000, ffang@apache.org wrote:
> Author: ffang
> Date: Thu Apr 26 01:21:05 2007
> New Revision: 532651
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=532651
> Log:
> [CXF-605] extract boundary from message body in AttachmentDeserializer
>  
> 
> Modified:
>     incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
>     incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
>     incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
> 
> Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?view=diff&rev=532651&r1=532650&r2=532651
> ==============================================================================
> --- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java (original)
> +++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Thu Apr 26 01:21:05 2007
> @@ -30,6 +30,8 @@
>  import javax.xml.soap.SOAPMessage;
>  import javax.xml.soap.SOAPPart;
>  import javax.xml.stream.XMLStreamWriter;
> +import com.sun.xml.messaging.saaj.packaging.mime.MessagingException;
> +
>  
>  import org.apache.cxf.binding.soap.SoapFault;
>  import org.apache.cxf.binding.soap.SoapMessage;
> @@ -41,6 +43,8 @@
>  import org.apache.cxf.phase.Phase;
>  import org.apache.cxf.staxutils.W3CDOMStreamWriter;
>  
> +
> +
>  /**
>   * Sets up the outgoing chain to build a SAAJ tree instead of writing
>   * directly to the output stream. First it will replace the XMLStreamWriter
> @@ -89,8 +93,10 @@
>              SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
>  
>              if (soapMessage != null) {
> +                
>                  OutputStream os = message.getContent(OutputStream.class);
>                  try {
> +                    setMessageContent(message, soapMessage);
>                      soapMessage.writeTo(os);
>                      os.flush();
>                  } catch (IOException e) {
> @@ -99,8 +105,28 @@
>                  } catch (SOAPException e) {
>                      throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, message.getVersion()
>                          .getSender());
> +                } catch (MessagingException e) {
> +                    throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, message.getVersion()
> +                        .getSender());
> +                }
> +            }
> +        }
> +
> +        private void setMessageContent(SoapMessage message, SOAPMessage soapMessage) 
> +            throws MessagingException, SOAPException {
> +            
> +            if (soapMessage.getAttachments().hasNext()) {
> +                StringBuffer sb = new StringBuffer();
> +                for (String str : soapMessage.getMimeHeaders().getHeader("Content-Type")) {
> +                    sb.append(str);
> +                }
> +                String contentType = sb.toString();
> +                if (contentType != null && contentType.length() > 0) {
> +                    message.put(org.apache.cxf.message.Message.CONTENT_TYPE, contentType);
>                  }
> +                    
>              }
> +            
>          }
>  
>      }
> [...]

-- 
Peter Jones
IONA Technologies Inc.
E-Mail: mailto:peter.jones@iona.com
Tel: (w) 709-738-3725 x22 | Fax: 709-738-3745
84-86 Elizabeth Ave. St. John's, NL A1A 1W7 Canada