cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1375033 - in /cxf/trunk: api/src/main/java/org/apache/cxf/ws/addressing/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/ rt/ws/addr/src/main/java/org/apache/cxf/ws/add...
Date Mon, 20 Aug 2012 14:19:29 GMT
Author: dkulp
Date: Mon Aug 20 14:19:29 2012
New Revision: 1375033

URL: http://svn.apache.org/viewvc?rev=1375033&view=rev
Log:
Change how adding the wsa ReplyTo is handled.
Make sure all the systests would pass if the optional ReplyTo wasn't specified.

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java Mon Aug 20
14:19:29 2012
@@ -314,6 +314,19 @@ public final class ContextUtils {
     }
     
     /**
+     * Helper method to determine if an EPR address is anon (either null,
+     * anonymous).
+     *
+     * @param ref the EPR under test
+     * @return true if the address is generic
+     */
+    public static boolean isAnonymousAddress(EndpointReferenceType ref) {
+        return ref == null 
+               || ref.getAddress() == null
+               || Names.WSA_ANONYMOUS_ADDRESS.equals(ref.getAddress().getValue());
+    }
+    
+    /**
      * Helper method to determine if an EPR address is none.
      *
      * @param ref the EPR under test

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Mon Aug 20
14:19:29 2012
@@ -32,7 +32,6 @@ import org.apache.cxf.phase.PhaseInterce
  */
 public class MAPAggregator extends AbstractPhaseInterceptor<Message> {
     public static final String USING_ADDRESSING = MAPAggregator.class.getName() + ".usingAddressing";
-    public static final String WRITE_ANONYMOUS_REPLY_TO = MAPAggregator.class.getName() +
".writeAnonymousReplyTo";
     public static final String ADDRESSING_DISABLED = MAPAggregator.class.getName() + ".addressingDisabled";
     public static final String DECOUPLED_DESTINATION = MAPAggregator.class.getName() 
         + ".decoupledDestination";

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Mon Aug 20 14:19:29 2012
@@ -494,8 +494,8 @@ public class SoapBindingFactory extends 
                 message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION,
Boolean.TRUE);
             }
         });
-        // don't send the ReplyTo headers if we don't need to either
-        ei.setProperty(MAPAggregator.WRITE_ANONYMOUS_REPLY_TO, Boolean.FALSE);
+        // don't send the optional ReplyTo headers if we don't need to either
+        ei.setProperty("ws-addressing.write.optional.replyto", Boolean.FALSE);
     }
     
     protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop,

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
(original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
Mon Aug 20 14:19:29 2012
@@ -844,12 +844,7 @@ public class MAPAggregatorImpl extends M
                         ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType();
                     replyTo.setAddress(address);
                 }
-                if (ContextUtils.isGenericAddress(replyTo)
-                    && !MessageUtils.getContextualBoolean(message, WRITE_ANONYMOUS_REPLY_TO,
true)) {
-                    maps.setReplyTo(null);
-                } else {
-                    maps.setReplyTo(replyTo);
-                }
+                maps.setReplyTo(replyTo);
             }
 
             // FaultTo

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Mon
Aug 20 14:19:29 2012
@@ -249,7 +249,7 @@ public class MAPCodec extends AbstractSo
                                     AttributedURIType.class,  
                                     jaxbContext);
                 }
-                if (needsReplyTo(maps)) {
+                if (needsReplyTo(maps, message)) {
                     encodeAsExposed(maps,
                             message,
                             maps.getReplyTo(), 
@@ -322,7 +322,18 @@ public class MAPCodec extends AbstractSo
         }
     }
 
-    private boolean needsReplyTo(AddressingProperties maps) {
+    private boolean needsReplyTo(AddressingProperties maps, SoapMessage m) {
+        if (!MessageUtils.getContextualBoolean(m, "ws-addressing.write.optional.replyto",
true)) {
+            if (ContextUtils.isNoneAddress(maps.getReplyTo())
+                && m.getExchange().isOneWay()) {
+                //one-way + none, not needed
+                return false;
+            }
+            if (ContextUtils.isAnonymousAddress(maps.getReplyTo())) {
+                //anonymous is the default if not specified, not needed
+                return false;
+            }
+        }
         return maps.getReplyTo() != null 
             && maps.getReplyTo().getAddress() != null
             && maps.getReplyTo().getAddress().getValue() != null
@@ -553,6 +564,17 @@ public class MAPCodec extends AbstractSo
                         }
                     }
                 }
+                
+                if (maps != null && !MessageUtils.isRequestor(message) &&
maps.getReplyTo() == null) {
+                    //per spec, if unspecified, replyTo is anon
+                    AttributedURIType address =
+                        ContextUtils.getAttributedURI(Names.WSA_ANONYMOUS_ADDRESS);
+                    EndpointReferenceType replyTo =
+                        ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType();
+                    replyTo.setAddress(address);
+                    maps.setReplyTo(replyTo);
+                }
+
                 if (null != referenceParameterHeaders && null != maps) {
                     decodeReferenceParameters(referenceParameterHeaders, maps, unmarshaller);
                 }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
Mon Aug 20 14:19:29 2012
@@ -85,7 +85,7 @@ public class WSAClientServerTest extends
         factory.setAddress("http://localhost:" + PORT + "/jaxws/add");
         factory.getFeatures().add(new WSAddressingFeature());
         AddNumbersPortType port = (AddNumbersPortType) factory.create();
-
+        ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto",
Boolean.TRUE);
         assertEquals(3, port.addNumbers(1, 2));
 
         String expectedOut = "<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>";
@@ -101,6 +101,7 @@ public class WSAClientServerTest extends
         ByteArrayOutputStream output = setupOutLogging();
 
         AddNumbersPortType port = getPort();
+        ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto",
Boolean.TRUE);
 
         assertEquals(3, port.addNumbers(1, 2));
 

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
Mon Aug 20 14:19:29 2012
@@ -40,6 +40,8 @@ import org.apache.cxf.binding.soap.SoapV
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AttributedURIType;
@@ -62,12 +64,25 @@ public class HeaderVerifier extends Abst
     public HeaderVerifier() {
         super(Phase.POST_PROTOCOL);
     }
+    public HeaderVerifier(String s) {
+        super(s);
+    }
     
     public Set<QName> getUnderstoodHeaders() {
         return Names.HEADERS;
     }
 
     public void handleMessage(SoapMessage message) {
+        if (!MessageUtils.isRequestor(message)
+            && !MessageUtils.isOutbound(message)
+            && getPhase().equals(Phase.POST_PROTOCOL)) {
+            message.getInterceptorChain().add(new AbstractSoapInterceptor(Phase.UNMARSHAL)
{
+                public void handleMessage(SoapMessage message) throws Fault {
+                    mediate(message);
+                }                
+            });
+            return;
+        }
         mediate(message);
     }
 
@@ -130,8 +145,7 @@ public class HeaderVerifier extends Abst
             verificationCache.put(MAPTest.verifyHeaders(wsaHeaders, 
                                                         partialResponse,
                                                         isRequestLeg(message),
-                                                        !VersionTransformer.Names200408.WSA_NAMESPACE_NAME
-                                                        .equals(currentNamespaceURI)));
+                                                        false));
         } catch (SOAPException se) {
             verificationCache.put("SOAP header verification failed: " + se);
         }

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java?rev=1375033&r1=1375032&r2=1375033&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
Mon Aug 20 14:19:29 2012
@@ -81,7 +81,7 @@ public class AddressingInlinePolicyTest 
 
     @BeforeClass
     public static void startServers() throws Exception {
-        assertTrue("server did not launch correctly", launchServer(Server.class, false));
+        assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
     
     @Test



Mime
View raw message