cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1050281 - in /cxf/branches/2.3.x-fixes: ./ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java
Date Fri, 17 Dec 2010 06:09:23 GMT
Author: ema
Date: Fri Dec 17 06:09:23 2010
New Revision: 1050281

URL: http://svn.apache.org/viewvc?rev=1050281&view=rev
Log:
Merged revisions 1050280 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1050280 | ema | 2010-12-17 14:04:51 +0800 (Fri, 17 Dec 2010) | 1 line
  
  [CXF-3199]:Set the wsa action and remove the not understood soap headers in OneWayDecoupledFaultHandler
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 17 06:09:23 2010
@@ -1 +1 @@
-/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919,1048930,1049078,1049937,1050005,1050021,1050095,1050102,1050113,1050156,1050165
+/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821,1043225,1043229,1043902,1043907,1043954,1044085,1044238-1044305,1045024,1048915,1048919,1048930,1049078,1049937,1050005,1050021,1050095,1050102,1050113,1050156,1050165,1050280

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java?rev=1050281&r1=1050280&r2=1050281&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandler.java
Fri Dec 17 06:09:23 2010
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.ws.addressing.soap;
 
+import java.util.Iterator;
+
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.headers.Header;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
@@ -28,6 +31,7 @@ import org.apache.cxf.transport.Destinat
 import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
 import org.apache.cxf.ws.addressing.ContextUtils;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.Names;
 
 /**
  * Utility interceptor for dealing with faults occurred during processing 
@@ -38,6 +42,8 @@ import org.apache.cxf.ws.addressing.Endp
  * annotations or explicitly added to the list of interceptors. 
  */
 public class OneWayDecoupledFaultHandler extends AbstractSoapInterceptor {
+    
+    public static final String WSA_ACTION = "http://schemas.xmlsoap.org/wsdl/soap/envelope/fault";
 
     public OneWayDecoupledFaultHandler() {
         super(Phase.PRE_PROTOCOL);
@@ -61,9 +67,18 @@ public class OneWayDecoupledFaultHandler
                 ContextUtils.retrieveMAPs(inMessage, false, false, true);
             
             if (maps != null && !ContextUtils.isGenericAddress(maps.getFaultTo()))
{
+                //Just keep the wsa headers to remove the not understand headers
+                Iterator<Header> iterator = message.getHeaders().iterator();
+                while (iterator.hasNext()) {
+                    Header header = iterator.next();
+                    if (!isWSAHeader(header)) {
+                        iterator.remove();
+                    }
+                }
                 exchange.setOneWay(false);
                 exchange.setOutMessage(message);
-                
+                //manually set the action
+                message.put(ContextUtils.ACTION, WSA_ACTION);
                 Destination destination = createDecoupledDestination(
                                                exchange, maps.getFaultTo());
                 exchange.setDestination(destination);
@@ -75,4 +90,11 @@ public class OneWayDecoupledFaultHandler
     protected Destination createDecoupledDestination(Exchange exchange, EndpointReferenceType
epr) {
         return ContextUtils.createDecoupledDestination(exchange, epr);
     }
+    
+    private boolean isWSAHeader(Header header) {
+        if (header.getName().getNamespaceURI().startsWith(Names.WSA_NAMESPACE_NAME)) {
+            return true;
+        }
+        return false;
+    }
 }

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java?rev=1050281&r1=1050280&r2=1050281&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/OneWayDecoupledFaultHandlerTest.java
Fri Dec 17 06:09:23 2010
@@ -18,7 +18,10 @@
  */
 package org.apache.cxf.ws.addressing.soap;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.headers.Header;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.MessageImpl;
@@ -29,7 +32,6 @@ import org.apache.cxf.ws.addressing.Attr
 import org.apache.cxf.ws.addressing.ContextUtils;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.easymock.EasyMock;
-
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -45,7 +47,8 @@ public class OneWayDecoupledFaultHandler
         };
         
         SoapMessage message = new SoapMessage(new MessageImpl());
-        
+        QName qname = new QName("http://cxf.apache.org/mustunderstand", "TestMU");
+        message.getHeaders().add(new Header(qname, new Object()));
         AddressingProperties maps = new AddressingPropertiesImpl();
         
         EndpointReferenceType faultTo = new EndpointReferenceType();
@@ -61,7 +64,7 @@ public class OneWayDecoupledFaultHandler
         exchange.setOneWay(true);
         
         handler.handleFault(message);
-        
+        assertTrue(message.getHeaders().isEmpty());
         assertFalse(exchange.isOneWay());
         assertSame(message, exchange.getOutMessage());
         assertNotNull(exchange.getDestination());



Mime
View raw message