You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2006/10/19 10:38:50 UTC

svn commit: r465527 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ addressing/test-resources/ addressing/test/org/apache/axis2/handlers/addressing/ kernel/src/org/apache/axis2/addressing/

Author: davidillsley
Date: Thu Oct 19 01:38:48 2006
New Revision: 465527

URL: http://svn.apache.org/viewvc?view=rev&rev=465527
Log:
Fix for AXIS2-1282 - wsa:Action setting in client side
Added client-side outbound addressing validation and property to turn it off.

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?view=diff&rev=465527&r1=465526&r2=465527
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Thu Oct 19 01:38:48 2006
@@ -33,6 +33,7 @@
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.Utils;
 
 import javax.xml.namespace.QName;
 
@@ -119,7 +120,7 @@
     }
 
     private void processWSAAction(Options messageContextOptions, SOAPEnvelope envelope,
-                                  MessageContext msgCtxt, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) {
+                                  MessageContext msgCtxt, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) throws AxisFault {
         String action = messageContextOptions.getAction();
         
         if(log.isTraceEnabled()){
@@ -134,16 +135,36 @@
             }
         }
         
+        // Use the correct fault action for the selected namespace
         if (Final.WSA_FAULT_ACTION.equals(action) || Submission.WSA_FAULT_ACTION.equals(action)) {
             action = isFinalAddressingNamespace ? Final.WSA_FAULT_ACTION : Submission.WSA_FAULT_ACTION;
         }
         else if (!isFinalAddressingNamespace && Final.WSA_SOAP_FAULT_ACTION.equals(action)) {
             action = Submission.WSA_FAULT_ACTION;
         }
-        
-        if (action != null && !isAddressingHeaderAlreadyAvailable(WSA_ACTION, envelope,
-                addressingNamespaceObject, replaceHeaders)) {
-            processStringInfo(action, WSA_ACTION, envelope, addressingNamespaceObject);
+
+        // If we need to add a wsa:Action header
+        if(!isAddressingHeaderAlreadyAvailable(WSA_ACTION, envelope,
+                addressingNamespaceObject, replaceHeaders)){
+            if(log.isTraceEnabled()){
+                log.trace("processWSAAction: No existing wsa:Action header found");
+            }
+            // If we don't have an action to add,
+            if(action == null || "".equals(action)){
+                if(log.isTraceEnabled()){
+                    log.trace("processWSAAction: No action to add to header");
+                }
+                // Fault unless validation has been explictily turned off
+                if(!Utils.isExplicitlyTrue(msgCtxt, AddressingConstants.DISABLE_OUTBOUND_ADDRESSING_VALIDATION)){
+                    throw new AxisFault("Unable to determine wsa:Action for outbound message");
+                }
+            }else{
+                if(log.isTraceEnabled()){
+                    log.trace("processWSAAction: Adding action to header: "+action);
+                }
+                // Otherwise just add the header
+                processStringInfo(action, WSA_ACTION, envelope, addressingNamespaceObject);
+            }
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml?view=diff&rev=465527&r1=465526&r2=465527
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/eprTest.xml Thu Oct 19 01:38:48 2006
@@ -1,15 +1,17 @@
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
-    <soapenv:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
-        <wsa:Reference4>Value 400</wsa:Reference4>
-        <wsa:Reference1>Value 100</wsa:Reference1>
-        <wsa:Reference0>Value 0</wsa:Reference0>
-        <wsa:Reference2>Value 200</wsa:Reference2>
-        <wsa:Reference3>Value 300</wsa:Reference3>
-        <wsa:To>http://www.to.org/service/</wsa:To>
-        <wsa:ReplyTo>
-            <wsa:Address>
-                http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
-        </wsa:ReplyTo>
-    </soapenv:Header>
-    <soapenv:Body></soapenv:Body>
+	<soapenv:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
+		<wsa:Reference4>Value 400</wsa:Reference4>
+		<wsa:Reference1>Value 100</wsa:Reference1>
+		<wsa:Reference0>Value 0</wsa:Reference0>
+		<wsa:Reference2>Value 200</wsa:Reference2>
+		<wsa:Reference3>Value 300</wsa:Reference3>
+		<wsa:To>http://www.to.org/service/</wsa:To>
+		<wsa:ReplyTo>
+			<wsa:Address>
+				http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+			</wsa:Address>
+		</wsa:ReplyTo>
+		<wsa:Action>http://www.actions.org/action</wsa:Action>
+	</soapenv:Header>
+	<soapenv:Body />
 </soapenv:Envelope>

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java?view=diff&rev=465527&r1=465526&r2=465527
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingOutHandlerTest.java Thu Oct 19 01:38:48 2006
@@ -67,6 +67,7 @@
         msgCtxt.setTo(epr);
         msgCtxt.setReplyTo(replyTo);
         msgCtxt.setEnvelope(defaultEnvelope);
+        msgCtxt.setWSAAction("http://www.actions.org/action");
         outHandler.invoke(msgCtxt);
 
         StAXSOAPModelBuilder omBuilder = testUtil.getOMBuilder("eprTest.xml");
@@ -172,6 +173,7 @@
         msgCtxt.setEnvelope(defaultEnvelope);
 
         msgCtxt.setTo(eprOne);
+        msgCtxt.setWSAAction("http://www.actions.org/action");
         outHandler.invoke(msgCtxt);
 
         // now the soap message within the msgCtxt must have a to header.
@@ -199,6 +201,7 @@
 
         msgCtxt.setProperty(REPLACE_ADDRESSING_HEADERS, Boolean.TRUE);
         msgCtxt.setTo(eprOne);
+        msgCtxt.setWSAAction("http://www.actions.org/action");
         outHandler.invoke(msgCtxt);
 
         assertTrue("http://whatever.org".equals(defaultEnvelope.getHeader().getFirstChildWithName(new QName(WSA_TO)).getText()));
@@ -221,6 +224,7 @@
 
         msgCtxt.setProperty(REPLACE_ADDRESSING_HEADERS, Boolean.FALSE);
         msgCtxt.setTo(eprOne);
+        msgCtxt.setWSAAction("http://www.actions.org/action");
         outHandler.invoke(msgCtxt);
 
         assertTrue("http://oldEPR.org".equals(defaultEnvelope.getHeader().getFirstChildWithName(new QName(WSA_TO)).getText()));

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java?view=diff&rev=465527&r1=465526&r2=465527
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java Thu Oct 19 01:38:48 2006
@@ -70,6 +70,15 @@
     public static final String DISABLE_ADDRESSING_FOR_OUT_MESSAGES = "disableAddressingForOutMessages";
     
     public static final String ADD_MUST_UNDERSTAND_TO_ADDRESSING_HEADERS = "addMustUnderstandToAddressingHeaders";
+    
+    /**
+     * This property, if set to Boolean.TRUE, will mean that the addressing handler allows partially
+     * ws-addressed messages to be sent even if they are then invalid rather than throwing a fault.
+     * 
+     * It is not clear how necessary this property is and it may be removed before the next release if
+     * it is not seen to be necessary - davidillsley@apache.org
+     */
+    public static final String DISABLE_OUTBOUND_ADDRESSING_VALIDATION = "disableAddressingOutboundValidation";
 
     public static final String WSAW_ANONYMOUS_PARAMETER_NAME = "wsawAnonymous";
     



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org