cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1063171 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/
Date Tue, 25 Jan 2011 08:35:47 GMT
Author: ffang
Date: Tue Jan 25 08:35:47 2011
New Revision: 1063171

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

........
  r1063157 | ffang | 2011-01-25 15:01:45 +0800 (二, 25  1 2011) | 1 line
  
  [CXF-3277]soap headers can't be carried back when exception happen
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
    cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/GreeterImpl.java
    cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/IntFaultClientServerTest.java

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java?rev=1063171&r1=1063170&r2=1063171&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/AbstractJAXWSMethodInvoker.java
Tue Jan 25 08:35:47 2011
@@ -168,4 +168,29 @@ public abstract class AbstractJAXWSMetho
         }
     }
 
+    protected void updateHeader(Exchange exchange, MessageContext ctx) {
+        if (ctx.containsKey(Header.HEADER_LIST) 
+                && ctx.get(Header.HEADER_LIST) instanceof List<?>) {
+            List list = (List) ctx.get(Header.HEADER_LIST);
+            if (list != null && !list.isEmpty()) {
+                SoapMessage sm = (SoapMessage) createResponseMessage(exchange);
+                if (sm != null) {
+                    Iterator iter = list.iterator();
+                    while (iter.hasNext()) {
+                        Header header = (Header) iter.next();
+                        if (!header.getName().getNamespaceURI().
+                            equals("http://docs.oasis-open.org/wss/2004/01/" 
+                                   + "oasis-200401-wss-wssecurity-secext-1.0.xsd")
+                                && !header.getName().getNamespaceURI().
+                                equals("http://docs.oasis-open.org/" 
+                                    + "wss/oasis-wss-wssecurity-secext-1.1.xsd")) {
+                            //don't copy over security header, out interceptor chain will
take care of it.
+                            sm.getHeaders().add(header);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
 }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java?rev=1063171&r1=1063170&r2=1063171&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
Tue Jan 25 08:35:47 2011
@@ -28,6 +28,7 @@ import javax.xml.ws.Provider;
 import javax.xml.ws.handler.MessageContext.Scope;
 
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.context.WebServiceContextImpl;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Exchange;
@@ -61,6 +62,10 @@ public class JAXWSMethodInvoker extends 
             addHandlerProperties(ctx, handlerScopedStuff);
             //update the webservice response context
             updateWebServiceContext(exchange, ctx);
+        } catch (Fault f) {
+            //get chance to copy over customer's header
+            updateHeader(exchange, ctx);
+            throw f;
         } finally {
             //clear the WebServiceContextImpl's ThreadLocal variable
             WebServiceContextImpl.clear();

Modified: cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.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/MAPCodec.java?rev=1063171&r1=1063170&r2=1063171&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
Tue Jan 25 08:35:47 2011
@@ -64,6 +64,7 @@ import org.apache.cxf.ws.addressing.MAPA
 import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.addressing.ReferenceParametersType;
 import org.apache.cxf.ws.addressing.RelatesToType;
+import org.apache.cxf.ws.addressing.VersionTransformer.Names200408;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
 
@@ -702,7 +703,8 @@ public class MAPCodec extends AbstractSo
         Iterator<Header> iter = header.iterator();
         while (iter.hasNext()) {
             Header hdr = iter.next();
-            if (Names.WSA_NAMESPACE_NAME.equals(hdr.getName().getNamespaceURI())) {
+            if (Names.WSA_NAMESPACE_NAME.equals(hdr.getName().getNamespaceURI())
+                || Names200408.WSA_NAMESPACE_NAME.equals(hdr.getName().getNamespaceURI()))
{
                 iter.remove();
             }
         }

Modified: cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/GreeterImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/GreeterImpl.java?rev=1063171&r1=1063170&r2=1063171&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/GreeterImpl.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/GreeterImpl.java
Tue Jan 25 08:35:47 2011
@@ -18,6 +18,16 @@
  */
 package org.apache.cxf.systest.fault;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.intfault.BadRecordLitFault;
 import org.apache.intfault.types.BareDocumentResponse;
 @javax.jws.WebService(portName = "SoapPort", serviceName = "SOAPService", 
@@ -25,8 +35,21 @@ import org.apache.intfault.types.BareDoc
                       endpointInterface = "org.apache.intfault.Greeter",
                       wsdlLocation = "testutils/hello_world_fault.wsdl")
 public class GreeterImpl {
+    @Resource
+    protected WebServiceContext context;
+    
     public BareDocumentResponse testDocLitFault(String in) throws BadRecordLitFault {
         System.out.println("Executing testDocLitFault sayHi\n");
+        List<Header> headers = new ArrayList<Header>();
+        Header header = null;
+        try {
+            header = new Header(new QName("http://test", "test"), 
+                                new String("test"), new JAXBDataBinding(String.class));
+        } catch (JAXBException e) {
+            e.printStackTrace();
+        }                        
+        headers.add(header);
+        context.getMessageContext().put(Header.HEADER_LIST, headers);
         throw new BadRecordLitFault("int fault", 5);
 
     }

Modified: cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/IntFaultClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/IntFaultClientServerTest.java?rev=1063171&r1=1063170&r2=1063171&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/IntFaultClientServerTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/fault/IntFaultClientServerTest.java
Tue Jan 25 08:35:47 2011
@@ -20,8 +20,18 @@
 package org.apache.cxf.systest.fault;
 
 import java.net.URL;
+import java.util.List;
+
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+
+import org.w3c.dom.Node;
 
+import org.apache.cxf.binding.soap.SoapHeader;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.intfault.BadRecordLitFault;
 import org.apache.intfault.Greeter;
@@ -46,14 +56,38 @@ public class IntFaultClientServerTest ex
 
         SOAPService service = new SOAPService(wsdl, serviceName);
         assertNotNull("Service is null", service);
-
+        
         Greeter greeter = service.getSoapPort();
+        ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
+        ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
         updateAddressPort(greeter, PORT);
         try {
             greeter.testDocLitFault("fault");
         } catch (BadRecordLitFault e) {
             assertEquals(5, e.getFaultInfo());
+            assertSoapHeader((BindingProvider)greeter);
         }
 
     }
+    
+    private void assertSoapHeader(BindingProvider serviceProxy) {
+        List<?> headers = (List<?>) serviceProxy.getResponseContext().get(Header.HEADER_LIST);
+        QName testQName = new QName("http://test", "test");
+        if (headers != null) {
+            for (Object o : headers) {
+                if (o instanceof SoapHeader) {
+                    SoapHeader soapHeader = (SoapHeader) o;
+                    QName qName = soapHeader.getName();
+                    if (testQName.getNamespaceURI().equals(qName.getNamespaceURI())
+                            && testQName.getLocalPart().equals(qName.getLocalPart()))
{
+                        Node returnedContent = (Node) soapHeader.getObject();
+                        assertEquals("test", returnedContent.getTextContent());
+                        return;
+                    }
+                }
+            }
+        }
+        fail("Header not found");
+    }
+
 }



Mime
View raw message