cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r780800 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
Date Mon, 01 Jun 2009 19:45:26 GMT
Author: dkulp
Date: Mon Jun  1 19:45:26 2009
New Revision: 780800

URL: http://svn.apache.org/viewvc?rev=780800&view=rev
Log:
[CXF-2250] Fix issue of .INBOUND_MESSAGE_ATTACHMENTS not being mapped
correctly on the client side.

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java?rev=780800&r1=780799&r2=780800&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
Mon Jun  1 19:45:26 2009
@@ -204,13 +204,22 @@
                 }
             }
             if (MessageContext.INBOUND_MESSAGE_ATTACHMENTS.equals(key)) {
-                if (isOutbound()) {
-                    ret = reqMessage.get(key);
+                if (isRequestor() && isOutbound()) {
+                    ret = null;
+                } else if (isOutbound()) {
+                    ret = createAttachments(reqMessage, 
+                                            MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+                } else {
+                    ret = createAttachments(message, 
+                                            MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
                   
                 }
-                ret = createAttachments(getWrappedMessage(), MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
             } else if (MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS.equals(key)) {
-                ret = createAttachments(isRequestor() ? getWrappedMessage() : createResponseMessage(),
-                    MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
+                if (isRequestor() && !isOutbound()) {
+                    ret = createAttachments(reqMessage, MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
+                } else {
+                    ret = createAttachments(isRequestor() ? getWrappedMessage() : createResponseMessage(),
+                        MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
+                }
             } else if (MessageContext.MESSAGE_OUTBOUND_PROPERTY.equals(key)) {
                 ret = isOutbound();
             } else if (MessageContext.HTTP_REQUEST_HEADERS.equals(key)) {
@@ -283,11 +292,11 @@
         }
         return m;
     }
-    private Object createAttachments(Message mc, String propertyName) {
+    private Object createAttachments(Map<String, Object> mc, String propertyName) {
         if (mc == null) {
             return null;
         }
-        Collection<Attachment> attachments = mc.getAttachments();
+        Collection<Attachment> attachments = CastUtils.cast((Collection<?>)mc.get(Message.ATTACHMENTS));
         Map<String, DataHandler> dataHandlers = 
             AttachmentUtil.getDHMap(attachments);
         mc.put(propertyName, 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?rev=780800&r1=780799&r2=780800&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java Mon
Jun  1 19:45:26 2009
@@ -21,6 +21,7 @@
 import java.awt.Image;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.imageio.ImageIO;
@@ -32,10 +33,13 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Holder;
 import javax.xml.ws.Service;
+import javax.xml.ws.handler.MessageContext;
 
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.swa.SwAService;
 import org.apache.cxf.swa.SwAServiceInterface;
@@ -218,7 +222,12 @@
         VoidRequest request = new VoidRequest();
         OutputResponseAll response = port.echoAllAttachmentTypes(request, attach1, attach2,
attach3, attach4,
                                                                  attach5);
+        
         assertNotNull(response);
+        Map<?, ?> map = CastUtils.cast((Map<?, ?>)((BindingProvider)port).getResponseContext()
+                                           .get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
+        assertNotNull(map);
+        assertEquals(5, map.size()); 
     }
     
     @Test



Mime
View raw message