You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2018/07/20 18:08:02 UTC

[cxf] branch 3.2.x-fixes updated: If addressingRequired is set on the ws-addressing feature for the client, set MustUnderstand=1 to make sure the server will understand and process it.

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
     new f0ec215  If addressingRequired is set on the ws-addressing feature for the client, set MustUnderstand=1 to make sure the server will understand and process it.
f0ec215 is described below

commit f0ec2159f2a278a39973151a33cda4edb7b19212
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Fri Jul 20 14:05:20 2018 -0400

    If addressingRequired is set on the ws-addressing feature for the client, set MustUnderstand=1 to make sure the server will understand and process it.
    
    (cherry picked from commit a63a36bc4e151ab9c555304fab383a4624191f51)
---
 .../java/org/apache/cxf/ws/addressing/AddressingProperties.java    | 7 +++++++
 .../java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java  | 5 ++++-
 .../src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java  | 2 +-
 .../test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java   | 3 ++-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/AddressingProperties.java b/core/src/main/java/org/apache/cxf/ws/addressing/AddressingProperties.java
index 5b86702..dab7e64 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/AddressingProperties.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/AddressingProperties.java
@@ -39,6 +39,7 @@ public class AddressingProperties  {
     private String namespaceURI;
     private QName duplicate;
     private List<QName> mustUnderstand;
+    private boolean isRequired;
 
     /**
      * Constructor, defaults to 2005/08 namespace.
@@ -213,6 +214,12 @@ public class AddressingProperties  {
         }
         return mustUnderstand;
     }
+    public boolean isRequired() {
+        return isRequired;
+    }
+    public void setRequired(boolean b) {
+        isRequired = b;
+    }
 
     public String toString() {
         StringBuilder buf = new StringBuilder();
diff --git a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
index e9d32e1..e2bc912 100644
--- a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
+++ b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
@@ -434,6 +434,10 @@ public class MAPAggregatorImpl extends MAPAggregator {
             }
             AddressingProperties theMaps =
                 ContextUtils.retrieveMAPs(message, false, ContextUtils.isOutbound(message));
+            
+            if (isAddressingRequired() && ContextUtils.isRequestor(message)) {
+                theMaps.setRequired(true);
+            }
             if (null != theMaps) {
                 if (ContextUtils.isRequestor(message)) {
                     assertAddressing(message,
@@ -632,7 +636,6 @@ public class MAPAggregatorImpl extends MAPAggregator {
                 maps.setAction(ContextUtils.getAttributedURI(getActionUri(message, true)));
             }
         }
-
         return maps;
     }
 
diff --git a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
index e4995af..69f4587 100644
--- a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
+++ b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
@@ -466,7 +466,7 @@ public class MAPCodec extends AbstractSoapInterceptor {
                     "{0} : {1}",
                     new Object[] {name.getLocalPart(), getLogText(value)});
 
-            boolean mu = maps.getMustUnderstand().contains(name);
+            boolean mu = maps.isRequired() || maps.getMustUnderstand().contains(name);
 
             transformer.encodeAsExposed(message,
                                         maps.getNamespaceURI(),
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
index 2c9c0a7..76f9397 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
@@ -976,7 +976,8 @@ public class ClientServerTest extends AbstractBusClientServerTestBase {
                         "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider");
         Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName,
                                                                    StreamSource.class,
-                                                                   Service.Mode.PAYLOAD);
+                                                                   Service.Mode.PAYLOAD, 
+                                                                   new LoggingFeature());
 
         Client client = ((DispatchImpl<StreamSource>)dispatcher).getClient();
         WSAddressingFeature wsAddressingFeature = new WSAddressingFeature();