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/07/31 19:28:16 UTC

svn commit: r427178 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ addressing/test/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/engine/ core/src/org/apache/axis2/transport/ core/src/o...

Author: davidillsley
Date: Mon Jul 31 10:28:15 2006
New Revision: 427178

URL: http://svn.apache.org/viewvc?rev=427178&view=rev
Log:
Committing patch from Brian for AXIS2-855
Looks good and satisfies comments from Eran.

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingFinalInHandlerTest.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java Mon Jul 31 10:28:15 2006
@@ -9,6 +9,9 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 
@@ -34,6 +37,7 @@
 
 public class AddressingFinalInHandler extends AddressingInHandler {
 
+    private static final Log log = LogFactory.getLog(AddressingFinalInHandler.class);
     private static final long serialVersionUID = -4020680449342946484L;
 
     public AddressingFinalInHandler() {
@@ -95,5 +99,25 @@
             throwFault(messageContext, WSA_ACTION, Final.FAULT_ADDRESSING_HEADER_REQUIRED, null);
         } 
     }
-
+    
+    protected void setDefaults(ArrayList alreadyFoundAddrHeader, MessageContext messageContext) {
+        //According to the WS-Addressing spec, we should default the wsa:To header to the
+        //anonymous URL. Doing that, however, might prevent a different value from being
+        //used instead, such as the transport URL.
+        
+        if (!alreadyFoundAddrHeader.contains(WSA_REPLY_TO)) {
+            Options messageContextOptions = messageContext.getOptions();
+            EndpointReference epr = messageContextOptions.getReplyTo();
+            
+            if (epr == null) {
+                epr = new EndpointReference("");
+                messageContextOptions.setReplyTo(epr);
+            }
+            
+            if (log.isTraceEnabled())
+                log.trace("setDefaults: Setting WS-Addressing default value for the ReplyTo property.");
+            
+            epr.setAddress(Final.WSA_ANONYMOUS_URL);
+        }        
+    }
 }

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java Mon Jul 31 10:28:15 2006
@@ -159,11 +159,16 @@
         
         // check for the presence of madatory addressing headers
         checkForMandatoryHeaders(checkedHeaderNames, messageContext);
-
+         
+        // provide default values for headers that have not been found.
+        setDefaults(checkedHeaderNames, messageContext);
+         
         return messageContextOptions;
     }
     
     protected abstract void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext messageContext) throws AxisFault;
+
+    protected abstract void setDefaults(ArrayList alreadyFoundAddrHeader, MessageContext messageContext) throws AxisFault;
 
     private boolean checkDuplicateHeaders(String addressingHeaderName, ArrayList checkedHeaderNames, ArrayList duplicateHeaderNames) {//throws AxisFault {
     	// If the header name has been seen before then we should return true and add it to the list

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java Mon Jul 31 10:28:15 2006
@@ -7,7 +7,11 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 
@@ -33,6 +37,7 @@
 
 public class AddressingSubmissionInHandler extends AddressingInHandler {
 
+    private static final Log log = LogFactory.getLog(AddressingSubmissionInHandler.class);
     private static final long serialVersionUID = 365417374773955107L;
 
     public AddressingSubmissionInHandler() {
@@ -106,5 +111,25 @@
                 throwFault(messageContext, WSA_MESSAGE_ID, Final.FAULT_ADDRESSING_HEADER_REQUIRED, null);
             }
         }
+    }
+    
+    protected void setDefaults(ArrayList alreadyFoundAddrHeader, MessageContext messageContext) {
+        //The none URI is not defined in the 2004/08 spec, but it is used here anyway
+        //as a flag to indicate the correct semantics to apply, i.e. in the 2004/08 spec
+        //the absence of a ReplyTo header indicates that a response is NOT required.
+        if (!alreadyFoundAddrHeader.contains(WSA_REPLY_TO)) {
+            Options messageContextOptions = messageContext.getOptions();
+            EndpointReference epr = messageContextOptions.getReplyTo();
+            
+            if (epr == null) {
+                epr = new EndpointReference("");
+                messageContextOptions.setReplyTo(epr);
+            }
+            
+            if (log.isTraceEnabled())
+                log.trace("setDefaults: Setting WS-Addressing default value for the ReplyTo property.");
+            
+            epr.setAddress(Final.WSA_NONE_URI);
+        }        
     }
 }

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingFinalInHandlerTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingFinalInHandlerTest.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingFinalInHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingFinalInHandlerTest.java Mon Jul 31 10:28:15 2006
@@ -1,261 +1,277 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.handlers.addressing;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.MessageContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class AddressingFinalInHandlerTest extends AddressingInHandlerTestBase {
-
-    private Log log = LogFactory.getLog(getClass());
-   
-    /**
-     * @param testName
-     */
-    public AddressingFinalInHandlerTest(String testName) {
-        super(testName);
-    }
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        inHandler = new AddressingFinalInHandler();
-        addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
-        versionDirectory = "final";
-        fromAddress = "http://www.w3.org/2005/08/addressing/anonymous";
-        secondRelationshipType = "http://some.custom.relationship";
-    }
-
-    public void testExtractAddressingInformationFromHeaders() {
-        try {
-            Options options = extractAddressingInformationFromHeaders();
-            
-            assertNotNull(options);
-            assertNotNull(options.getTo());
-   
-            Map allReferenceParameters = options.getTo().getAllReferenceParameters();
-            assertNotNull(allReferenceParameters);
-            QName qName = new QName("http://ws.apache.org/namespaces/axis2", "ParamOne", "axis2");
-            assertNotNull(allReferenceParameters.get(qName));
-
-            assertEPRHasCorrectMetadata(options.getFrom());
-            assertEPRHasCorrectMetadata(options.getFaultTo());
-            assertEPRHasCorrectMetadata(options.getReplyTo());
-            
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());
-        }
-    }
-    
-    public void testMessageWithOmittedAction() {
-        try {
-            testMessageWithOmittedHeaders("noAction");
-            fail("An AxisFault should have been thrown due to a missing Action header.");
-        }
-        catch (AxisFault af) {
-            //test passed
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testMessageWithOmittedFaultTo() {
-        try {
-            testMessageWithOmittedHeaders("noFaultTo");
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown due to a missing FaultTo header.");
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testMessageWithOmittedFrom() {
-        try {
-            testMessageWithOmittedHeaders("noFrom");
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown due to a missing From header.");
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testMessageWithOmittedMessageID() {
-        try {
-            testMessageWithOmittedHeaders("noMessageID");
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown due to a missing MessageID header.");
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testMessageWithOmittedReplyTo() {
-        try {
-            testMessageWithOmittedHeaders("noReplyTo");
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown due to a missing ReplyTo header.");
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testMessageWithOmittedTo() {
-        try {
-            testMessageWithOmittedHeaders("noTo");
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown due to a missing To header.");
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());            
-        }
-    }
-    
-    public void testDifferentSoapActionProcessing() {
-        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
-        MessageContext mc = new MessageContext();
-        
-        try {
-            mc.setSoapAction("http://ws.apache.org/tests/differentAction");
-            basicExtractAddressingInformationFromHeaders(testfile, mc);
-            fail("An AxisFault should have been thrown due to the soapaction being different to the ws-a action.");            
-        }
-        catch (AxisFault af) {
-            //Test passed.
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());                        
-        }
-    }
-    
-    public void testSameSoapAction() {
-        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
-        MessageContext mc = new MessageContext();
-        
-        try {
-            mc.setSoapAction("http://ws.apache.org/tests/action");
-            basicExtractAddressingInformationFromHeaders(testfile, mc);
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown while testing with a soapaction and ws-a action that are the same.");            
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());                        
-        }        
-    }
-    
-    public void testEmptySoapAction() {
-        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
-        MessageContext mc = new MessageContext();
-        
-        try {
-            mc.setSoapAction("");
-            basicExtractAddressingInformationFromHeaders(testfile, mc);
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown while testing with an empty soapaction.");            
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());                        
-        }
-    }
-    
-    public void testNullSoapAction() {
-        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
-        MessageContext mc = new MessageContext();
-        
-        try {
-            mc.setSoapAction(null);
-            basicExtractAddressingInformationFromHeaders(testfile, mc);
-        }
-        catch (AxisFault af) {
-            af.printStackTrace();
-            log.error(af.getMessage());
-            fail("An unexpected AxisFault was thrown while testing with a null soapaction.");            
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-            fail(" An Exception has occured " + e.getMessage());                        
-        }
-    }
-    
-    private void assertEPRHasCorrectMetadata(EndpointReference epr){
-    	ArrayList metadata = epr.getMetaData();
-    	if(metadata != null){
-    		OMElement md = (OMElement)metadata.get(0);
-    		assertEquals(md.getQName(),new QName("http://ws.apache.org/namespaces/axis2","MetaExt"));
-    		assertEquals(md.getText(),"123456789");
-    		assertEquals(md.getAttributeValue(new QName("http://ws.apache.org/namespaces/axis2","AttrExt")),"123456789");
-    	}else{
-    		fail("No Metadata found in EPR");
-    	}
-    }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.handlers.addressing;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AddressingFinalInHandlerTest extends AddressingInHandlerTestBase {
+
+    private Log log = LogFactory.getLog(getClass());
+   
+    /**
+     * @param testName
+     */
+    public AddressingFinalInHandlerTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        inHandler = new AddressingFinalInHandler();
+        addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
+        versionDirectory = "final";
+        fromAddress = "http://www.w3.org/2005/08/addressing/anonymous";
+        secondRelationshipType = "http://some.custom.relationship";
+    }
+
+    public void testExtractAddressingInformationFromHeaders() {
+        try {
+            Options options = extractAddressingInformationFromHeaders();
+            
+            assertNotNull(options);
+            assertNotNull(options.getTo());
+   
+            Map allReferenceParameters = options.getTo().getAllReferenceParameters();
+            assertNotNull(allReferenceParameters);
+            QName qName = new QName("http://ws.apache.org/namespaces/axis2", "ParamOne", "axis2");
+            assertNotNull(allReferenceParameters.get(qName));
+
+            assertEPRHasCorrectMetadata(options.getFrom());
+            assertEPRHasCorrectMetadata(options.getFaultTo());
+            assertEPRHasCorrectMetadata(options.getReplyTo());
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());
+        }
+    }
+    
+    public void testMessageWithOmittedAction() {
+        try {
+            testMessageWithOmittedHeaders("noAction");
+            fail("An AxisFault should have been thrown due to a missing Action header.");
+        }
+        catch (AxisFault af) {
+            //test passed
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testMessageWithOmittedFaultTo() {
+        try {
+            Options options = testMessageWithOmittedHeaders("noFaultTo");
+            EndpointReference epr = options.getFaultTo();
+            
+            assertNull("The FaultTo endpoint reference is not null.", epr);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown due to a missing FaultTo header.");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testMessageWithOmittedFrom() {
+        try {
+            Options options = testMessageWithOmittedHeaders("noFrom");
+            EndpointReference epr = options.getFrom();
+            
+            assertNull("The From endpoint reference is not null.", epr);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown due to a missing From header.");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testMessageWithOmittedMessageID() {
+        try {
+            Options options = testMessageWithOmittedHeaders("noMessageID");
+            String messageID = options.getMessageId();
+            
+            assertNull("The message id is not null.", messageID);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown due to a missing MessageID header.");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testMessageWithOmittedReplyTo() {
+        try {
+            Options options = testMessageWithOmittedHeaders("noReplyTo");
+            EndpointReference epr = options.getReplyTo();
+            String address = epr.getAddress();
+            
+            assertEquals("The address of the ReplyTo endpoint reference is not the anonymous URI.", AddressingConstants.Final.WSA_ANONYMOUS_URL, address);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown due to a missing ReplyTo header.");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testMessageWithOmittedTo() {
+        try {
+            Options options = testMessageWithOmittedHeaders("noTo");
+            EndpointReference epr = options.getTo();
+            
+            assertNull("The To endpoint reference is not null.", epr);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown due to a missing To header.");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());            
+        }
+    }
+    
+    public void testDifferentSoapActionProcessing() {
+        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
+        MessageContext mc = new MessageContext();
+        
+        try {
+            mc.setSoapAction("http://ws.apache.org/tests/differentAction");
+            basicExtractAddressingInformationFromHeaders(testfile, mc);
+            fail("An AxisFault should have been thrown due to the soapaction being different to the ws-a action.");            
+        }
+        catch (AxisFault af) {
+            //Test passed.
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());                        
+        }
+    }
+    
+    public void testSameSoapAction() {
+        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
+        MessageContext mc = new MessageContext();
+        
+        try {
+            mc.setSoapAction("http://ws.apache.org/tests/action");
+            basicExtractAddressingInformationFromHeaders(testfile, mc);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown while testing with a soapaction and ws-a action that are the same.");            
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());                        
+        }        
+    }
+    
+    public void testEmptySoapAction() {
+        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
+        MessageContext mc = new MessageContext();
+        
+        try {
+            mc.setSoapAction("");
+            basicExtractAddressingInformationFromHeaders(testfile, mc);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown while testing with an empty soapaction.");            
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());                        
+        }
+    }
+    
+    public void testNullSoapAction() {
+        String testfile = "valid-messages/"+versionDirectory+"/soapmessage.xml";
+        MessageContext mc = new MessageContext();
+        
+        try {
+            mc.setSoapAction(null);
+            basicExtractAddressingInformationFromHeaders(testfile, mc);
+        }
+        catch (AxisFault af) {
+            af.printStackTrace();
+            log.error(af.getMessage());
+            fail("An unexpected AxisFault was thrown while testing with a null soapaction.");            
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+            fail(" An Exception has occured " + e.getMessage());                        
+        }
+    }
+    
+    private void assertEPRHasCorrectMetadata(EndpointReference epr){
+    	ArrayList metadata = epr.getMetaData();
+    	if(metadata != null){
+    		OMElement md = (OMElement)metadata.get(0);
+    		assertEquals(md.getQName(),new QName("http://ws.apache.org/namespaces/axis2","MetaExt"));
+    		assertEquals(md.getText(),"123456789");
+    		assertEquals(md.getAttributeValue(new QName("http://ws.apache.org/namespaces/axis2","AttrExt")),"123456789");
+    	}else{
+    		fail("No Metadata found in EPR");
+    	}
+    }
+}

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java Mon Jul 31 10:28:15 2006
@@ -158,11 +158,13 @@
         }
     }
     
-    protected void testMessageWithOmittedHeaders(String testName) throws Exception {
+    protected Options testMessageWithOmittedHeaders(String testName) throws Exception {
         String testfile = "omitted-header-messages/"+versionDirectory+"/"+testName+"Message.xml";
         
         MessageContext mc = new MessageContext();
         basicExtractAddressingInformationFromHeaders(testfile, mc);
+        
+        return mc.getOptions();
     }
     
     public void testExtractAddressingInformationFromHeadersInvalidCardinalityReplyTo() {

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java Mon Jul 31 10:28:15 2006
@@ -18,6 +18,7 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -70,7 +71,10 @@
     
     public void testMessageWithOmittedFaultTo() {
         try {
-            testMessageWithOmittedHeaders("noFaultTo");
+            Options options = testMessageWithOmittedHeaders("noFaultTo");
+            EndpointReference epr = options.getFaultTo();
+            
+            assertNull("The FaultTo endpoint reference is not null.", epr);
         }
         catch (AxisFault af) {
             af.printStackTrace();
@@ -86,7 +90,10 @@
     
     public void testMessageWithOmittedFrom() {
         try {
-            testMessageWithOmittedHeaders("noFrom");
+            Options options = testMessageWithOmittedHeaders("noFrom");
+            EndpointReference epr = options.getFrom();
+            
+            assertNull("The From endpoint reference is not null.", epr);
         }
         catch (AxisFault af) {
             af.printStackTrace();
@@ -117,7 +124,10 @@
     
     public void testMessageWithOmittedMessageIDReplyToAndFaultTo() {
         try {
-            testMessageWithOmittedHeaders("noMessageIDNoReplyToNoFaultTo");
+            Options options = testMessageWithOmittedHeaders("noMessageIDNoReplyToNoFaultTo");
+            String messageID = options.getMessageId();
+            
+            assertNull("The message id is not null.", messageID);
         }
         catch (AxisFault af) {
             af.printStackTrace();
@@ -133,7 +143,11 @@
     
     public void testMessageWithOmittedReplyTo() {
         try {
-            testMessageWithOmittedHeaders("noReplyTo");
+            Options options = testMessageWithOmittedHeaders("noReplyTo");
+            EndpointReference epr = options.getReplyTo();
+            String address = epr.getAddress();
+            
+            assertEquals("The address of the ReplyTo endpoint reference is not the none URI.", AddressingConstants.Final.WSA_NONE_URI, address);
         }
         catch (AxisFault af) {
             af.printStackTrace();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java Mon Jul 31 10:28:15 2006
@@ -52,6 +52,9 @@
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
+
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
@@ -235,15 +238,30 @@
             faultContext.setTo(processingContext.getReplyTo());
         }
 
-        if (faultTo == null || AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(faultTo.getAddress())
-                || AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(faultTo.getAddress())
-                || AddressingConstants.Final.WSA_NONE_URI.equals(faultTo.getAddress())) {
-            Object writer = processingContext.getProperty(MessageContext.TRANSPORT_OUT);
-            if (writer != null) {
-                faultContext.setProperty(MessageContext.TRANSPORT_OUT, writer);
-            } else {
-                throw new AxisFault(Messages.getMessage("nowhereToSendError"));
+        //Determine that we have the correct transport available.
+        TransportOutDescription transportOut = faultContext.getTransportOut();
+
+        try {
+            if (faultContext.isServerSide() && faultContext.getTo() != null) {
+                String replyToAddress = faultContext.getTo().getAddress();
+                if (!(AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyToAddress)
+                        || AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyToAddress)
+                        || AddressingConstants.Final.WSA_NONE_URI.equals(replyToAddress))) {
+                    URI uri = new URI(replyToAddress);
+                    String scheme = uri.getScheme();
+                    if (!transportOut.getName().getLocalPart().equals(scheme)) {
+                        ConfigurationContext configurationContext = faultContext.getConfigurationContext();
+                        transportOut = configurationContext.getAxisConfiguration()
+                                .getTransportOut(new QName(scheme));
+                        if (transportOut == null) {
+                            throw new AxisFault("Can not find the transport sender : " + scheme);
+                        }
+                        faultContext.setTransportOut(transportOut);
+                    }
+                }
             }
+        } catch (URISyntaxException urise) {
+            throw new AxisFault(urise);
         }
 
         faultContext.setOperationContext(processingContext.getOperationContext());
@@ -252,9 +270,6 @@
 
         SOAPEnvelope envelope;
 
-        faultContext.setProperty(Constants.OUT_TRANSPORT_INFO,
-                processingContext.getProperty(Constants.OUT_TRANSPORT_INFO));
-
         if (processingContext.isSOAP11()) {
             envelope = OMAbstractFactory.getSOAP11Factory().getDefaultFaultEnvelope();
         } else {
@@ -266,6 +281,8 @@
         extractFaultInformationFromMessageContext(processingContext, envelope.getBody().getFault(),
                 e);
         faultContext.setEnvelope(envelope);
+        faultContext.setProperty(MessageContext.TRANSPORT_OUT,
+                processingContext.getProperty(MessageContext.TRANSPORT_OUT));
         faultContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                 processingContext.getProperty(Constants.OUT_TRANSPORT_INFO));
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java Mon Jul 31 10:28:15 2006
@@ -88,16 +88,18 @@
         }
 
         if (epr != null) {
-            out = openTheConnection(epr, msgContext);
-
-            OutputStream newOut = startSendWithToAddress(msgContext, out);
-
-            if (newOut != null) {
-                out = newOut;
+            if (!epr.getAddress().equals(AddressingConstants.Final.WSA_NONE_URI)) {
+                out = openTheConnection(epr, msgContext);
+    
+                OutputStream newOut = startSendWithToAddress(msgContext, out);
+    
+                if (newOut != null) {
+                    out = newOut;
+                }
+    
+                writeMessage(msgContext, out);
+                finalizeSendWithToAddress(msgContext, out);
             }
-
-            writeMessage(msgContext, out);
-            finalizeSendWithToAddress(msgContext, out);
         } else {
             out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
 
@@ -107,7 +109,7 @@
                 finalizeSendWithOutputStreamFromIncomingConnection(msgContext, out);
             } else {
                 throw new AxisFault(
-                        "Both the TO and Property MessageContext.TRANSPORT_WRITER is Null, No where to send");
+                        "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
             }
         }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Mon Jul 31 10:28:15 2006
@@ -206,7 +206,12 @@
                     writeMessageWithCommons(msgContext, epr, dataOut, format);
                 }
             } else {
-                sendUsingOutputStream(msgContext, format, dataOut);
+                if (msgContext.getProperty(MessageContext.TRANSPORT_OUT) != null) {
+                    sendUsingOutputStream(msgContext, format, dataOut);
+                }
+                else {
+                    throw new AxisFault("Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+                }
             }
 
             if (msgContext.getOperationContext() != null) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=427178&r1=427177&r2=427178&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Mon Jul 31 10:28:15 2006
@@ -34,7 +34,6 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
-import org.apache.axis2.transport.TransportSender;
 import org.apache.axis2.wsdl.WSDLConstants;
 
 import javax.xml.namespace.QName;
@@ -109,7 +108,6 @@
 
         // write the Message to the Wire
         TransportOutDescription transportOut = newmsgCtx.getTransportOut();
-        TransportSender sender = transportOut.getSender();
 
         //there may be instance where you want to send the response to replyTo
         //and this default behaviour should happen if somebody (e.g. a module) has not already provided
@@ -118,7 +116,8 @@
             if (newmsgCtx.isServerSide() && newmsgCtx.getTo() != null) {
                 String replyToAddress = newmsgCtx.getTo().getAddress();
                 if (!(AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyToAddress)
-                        || AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyToAddress))) {
+                        || AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyToAddress)
+                        || AddressingConstants.Final.WSA_NONE_URI.equals(replyToAddress))) {
                     URI uri = new URI(replyToAddress);
                     String scheme = uri.getScheme();
                     if (!transportOut.getName().getLocalPart().equals(scheme)) {



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