Author: gdaniels
Date: Sat Jan 14 21:20:18 2006
New Revision: 369180

URL: http://svn.apache.org/viewcvs?rev=369180&view=rev
Log:
* Throw faults when duplicate headers detected

* Check for W3C namespace in appropriate places

* Send a default wsa:Action even if nothing specified (should this be ""?), 
since the header is (unnecessarily, IMO) mandatory

* Fix test and test message to accurately reflect a) soap namespaces on 
attributes, and b) targeting of headers

Modified:
    
webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java
    
webservices/addressing/trunk/src/org/apache/axis/message/addressing/EndpointReference.java
    
webservices/addressing/trunk/src/org/apache/axis/message/addressing/handler/AddressingHandler.java
    
webservices/addressing/trunk/src/org/apache/axis/message/addressing/util/AddressingUtils.java
    
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/AbstractAddressingHandlerTestCase.java
    
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/ServerSideAddressingHandlerTestCase.java
    
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/testRequest.xml

Modified: 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java
 (original)
+++ 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java
 Sat Jan 14 21:20:18 2006
@@ -17,6 +17,7 @@
 package org.apache.axis.message.addressing;
 
 import org.apache.axis.MessageContext;
+import org.apache.axis.AxisFault;
 import org.apache.axis.message.MessageElement;
 import org.apache.axis.message.addressing.util.AddressingUtils;
 import org.apache.axis.message.addressing.util.TextExtractor;
@@ -240,18 +241,52 @@
                 if (localName.equals(Constants.MESSAGE_ID)) {
                     messageID = new MessageID(headerElement);
                 } else if (localName.equals(Constants.TO)) {
+                    if (to != null) {
+                        throw new AxisFault("Client.duplicateToHeader",
+                                            "duplicate To header",
+                                            null, null);
+                    }
                     to = new To(headerElement);
-                    // set the WSA namespace URI in the MessageContext, so 
we'll know how to serialize types associated with this request
-                    MessageContext msgContext = 
MessageContext.getCurrentContext();
-                    if ( msgContext != null ) { msgContext.setProperty( 
Constants.ENV_ADDRESSING_NAMESPACE_URI, name.getURI() ); }
+                    // set the WSA namespace URI in the MessageContext,
+                    // so we'll know how to serialize types associated
+                    // with this request
+                    MessageContext msgContext =
+                            MessageContext.getCurrentContext();
+                    if ( msgContext != null ) {
+                        msgContext.setProperty(
+                                Constants.ENV_ADDRESSING_NAMESPACE_URI,
+                                name.getURI());
+                    }
                 } else if (localName.equals(Constants.ACTION)) {
-                   URI unspecified = new 
org.apache.axis.types.URI(TextExtractor.getText(headerElement), 
permitParseNonSpecificAction);
+                    if (action != null) {
+                        throw new AxisFault("Client.duplicateActionHeader",
+                                            "duplicate Action header",
+                                            null, null);
+                    }
+                   URI unspecified = new org.apache.axis.types.URI(
+                            TextExtractor.getText(headerElement),
+                            permitParseNonSpecificAction);
                    action = new Action(new URI(unspecified));
                 } else if (localName.equals(Constants.FROM)) {
+                    if (from != null) {
+                        throw new AxisFault("Client.duplicateFromHeader",
+                                            "duplicate From header",
+                                            null, null);
+                    }
                     from = new From(headerElement);
                 } else if (localName.equals(Constants.REPLY_TO)) {
+                    if (replyTo != null) {
+                        throw new AxisFault("Client.duplicateReplyToHeader",
+                                            "duplicate ReplyTo header",
+                                            null, null);
+                    }
                     replyTo = new ReplyTo(headerElement);
                 } else if (localName.equals(Constants.FAULT_TO)) {
+                    if (faultTo != null) {
+                        throw new AxisFault("Client.duplicateFaultToHeader",
+                                            "more than one FaultTo header",
+                                            null, null);
+                    }
                     faultTo = new FaultTo(headerElement);
                 } else if (localName.equals(Constants.RECIPIENT)) {
                     recipient = new Recipient(headerElement);

Modified: 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/EndpointReference.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/src/org/apache/axis/message/addressing/EndpointReference.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/EndpointReference.java
 (original)
+++ 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/EndpointReference.java
 Sat Jan 14 21:20:18 2006
@@ -156,9 +156,14 @@
         for (int i=0;i<children.getLength();i++) {
             Node child = children.item(i);
             if (child instanceof Element) {
-                if 
(!AddressingUtils.isAddressingNamespaceURI(child.getNamespaceURI())) {
-                    // skip for now - does not currently handle extensibility 
elements
-                    continue;
+                if (!AddressingUtils.isW3CAddressingNamespaceURI(
+                        child.getNamespaceURI())) {
+                    if (!AddressingUtils.isAddressingNamespaceURI(
+                            child.getNamespaceURI())) {
+                        // skip for now - does not currently handle
+                        // extensibility elements
+                        continue;
+                    }
                 }
                 String localName = child.getLocalName();
                 if (Constants.ADDRESS.equals(localName)) {

Modified: 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/handler/AddressingHandler.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/src/org/apache/axis/message/addressing/handler/AddressingHandler.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/handler/AddressingHandler.java
 (original)
+++ 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/handler/AddressingHandler.java
 Sat Jan 14 21:20:18 2006
@@ -164,7 +164,8 @@
                 resHeaders.setFrom(fromEPR);
             }
         }
-        URI actionURI = new 
org.apache.axis.types.URI(AddressingUtils.getFaultActionURI(), 
allowNonSpecificActions);
+        URI actionURI = new org.apache.axis.types.URI(
+                AddressingUtils.getFaultActionURI(), allowNonSpecificActions);
         resHeaders.setAction(new Action(new URI(actionURI)));
 
         // process RelatesTo
@@ -259,7 +260,13 @@
         if (action != null) {
             URI actionURI = new org.apache.axis.types.URI(action, 
allowNonSpecificActions);
             headers.setAction(new Action(new URI(actionURI)));
-        } else if(headers.getAction() != null) {
+        } else {
+            Action act = headers.getAction();
+            if (act == null) {
+                URI actionURI = new 
URI("http://apache.org/axis/defaultAction";);
+                headers.setAction(new Action(new URI(actionURI)));
+            }
+
             msgContext.setUseSOAPAction(true);
             // Make SOAP action match
             msgContext.setSOAPActionURI(headers.getAction().toString());
@@ -505,7 +512,7 @@
         if (replyTo != null) {
             resHeaders.setReferenceProperties(replyTo.getProperties());
             resHeaders.setReferenceParameters(replyTo.getParameters());
-            
+
             AttributedURI address = replyTo.getAddress();
             if (address != null) {
                 String uri = address.toString();

Modified: 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/util/AddressingUtils.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/src/org/apache/axis/message/addressing/util/AddressingUtils.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/util/AddressingUtils.java
 (original)
+++ 
webservices/addressing/trunk/src/org/apache/axis/message/addressing/util/AddressingUtils.java
 Sat Jan 14 21:20:18 2006
@@ -121,7 +121,8 @@
         while (headers.hasNext()) {
             SOAPHeaderElement hElement = (SOAPHeaderElement) headers.next();
             Name hName = hElement.getElementName();
-            if (isAddressingNamespaceURI( hName.getURI() )) {
+            if (isAddressingNamespaceURI(hName.getURI()) ||
+                    isW3CAddressingNamespaceURI(hName.getURI())) {
                 existingElements.add(hElement);
             }
         }

Modified: 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/AbstractAddressingHandlerTestCase.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/test/org/apache/ws/addressing/handler/AbstractAddressingHandlerTestCase.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/AbstractAddressingHandlerTestCase.java
 (original)
+++ 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/AbstractAddressingHandlerTestCase.java
 Sat Jan 14 21:20:18 2006
@@ -274,7 +274,7 @@
     protected void checkRelatesToHeader(AddressingHeaders addrHeaders, 
RelatesTo[] expectedRelatesTo) {
         List relatesToList = addrHeaders.getRelatesTo();
         assertNotNull(relatesToList);
-        assertEquals(new Integer(expectedRelatesTo.length), new 
Integer(relatesToList.size()));
+        assertEquals(expectedRelatesTo.length, relatesToList.size());
         for (int i = 0; i < relatesToList.size(); i++) {
             RelatesTo relatesTo = (RelatesTo) relatesToList.get(i);
             assertEquals(expectedRelatesTo[i].getType().toString(), 
relatesTo.getType().toString());

Modified: 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/ServerSideAddressingHandlerTestCase.java
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/test/org/apache/ws/addressing/handler/ServerSideAddressingHandlerTestCase.java?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/ServerSideAddressingHandlerTestCase.java
 (original)
+++ 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/ServerSideAddressingHandlerTestCase.java
 Sat Jan 14 21:20:18 2006
@@ -69,8 +69,9 @@
         AddressingHeaders addrHeaders = (AddressingHeaders) prop;
         assertFalse(addrHeaders.isSetMustUnderstand());
         checkMessageIdHeader(addrHeaders, 
"aaaabbbb-cccc-dddd-eeee-ffffffffffff");
-        checkRelatesToHeader(addrHeaders, new RelatesTo[]{new 
RelatesTo("uuid:11112222-3333-4444-5555-666666666666", "{urn:testNS}testPart"),
-                                                          new 
RelatesTo("uuid:11112222-3333-4444-5555-999999999999", 
AddressingUtils.getResponseRelationshipType().toString())});
+//        checkRelatesToHeader(addrHeaders, new RelatesTo[]{new 
RelatesTo("uuid:11112222-3333-4444-5555-666666666666", "{urn:testNS}testPart"),
+//                                                          new 
RelatesTo("uuid:11112222-3333-4444-5555-999999999999", 
AddressingUtils.getResponseRelationshipType().toString())});
+        checkRelatesToHeader(addrHeaders, new RelatesTo[]{new 
RelatesTo("uuid:11112222-3333-4444-5555-666666666666", 
"{urn:testNS}testPart")});
         ReplyTo expectedReplyTo = new ReplyTo(new 
Address(AddressingUtils.getAnonymousRoleURI()));
         expectedReplyTo.setPortType(new PortType("urn:Foo", "Test"));
         expectedReplyTo.setServiceName(new ServiceNameType("urn:Bar", 
"Test2"));

Modified: 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/testRequest.xml
URL: 
http://svn.apache.org/viewcvs/webservices/addressing/trunk/test/org/apache/ws/addressing/handler/testRequest.xml?rev=369180&r1=369179&r2=369180&view=diff
==============================================================================
--- 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/testRequest.xml
 (original)
+++ 
webservices/addressing/trunk/test/org/apache/ws/addressing/handler/testRequest.xml
 Sat Jan 14 21:20:18 2006
@@ -1,36 +1,37 @@
 <Envelope
     xmlns="http://schemas.xmlsoap.org/soap/envelope/";
+    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
     xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
 
     <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing";>
-        <wsa:MessageID actor="http://schemas.xmlsoap.org/soap/actor/next";>
+        <wsa:MessageID soap:actor="http://schemas.xmlsoap.org/soap/actor/next";>
         uuid:aaaabbbb-cccc-dddd-eeee-ffffffffffff
         </wsa:MessageID>
-        <wsa:RelatesTo actor="http://schemas.xmlsoap.org/soap/actor/next"; 
xmlns:ws="urn:testNS" RelationshipType="ws:testPart">
+        <wsa:RelatesTo soap:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
xmlns:ws="urn:testNS" RelationshipType="ws:testPart">
         uuid:11112222-3333-4444-5555-666666666666
         </wsa:RelatesTo>
-        <wsa:ReplyTo actor="http://schemas.xmlsoap.org/soap/actor/next";>
+        <wsa:ReplyTo soap:actor="http://schemas.xmlsoap.org/soap/actor/next";>
             
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
             <wsa:PortType xmlns:ns1="urn:Foo">ns1:Test</wsa:PortType>
             <wsa:ServiceName xmlns:ns1="urn:Bar">ns1:Test2</wsa:ServiceName>
         </wsa:ReplyTo>
-        <wsa:FaultTo actor="http://schemas.xmlsoap.org/soap/actor/next";>
+        <wsa:FaultTo soap:actor="http://schemas.xmlsoap.org/soap/actor/next";>
             <wsa:Address>http://business456.com/deadletters</wsa:Address>
         </wsa:FaultTo>
-        <wsa:To actor="urn:bob" mustUnderstand="1">mailto:[EMAIL 
PROTECTED]</wsa:To>
-        <wsa:Action 
actor="urn:bob">http://fabrikam123.com/mail#Delete</wsa:Action>
-        <wsa:RelatesTo 
actor="urn:bob">uuid:11112222-3333-4444-5555-999999999999</wsa:RelatesTo>
-        <wsa:To actor="http://schemas.xmlsoap.org/soap/actor/next"; 
mustUnderstand="1">mailto:[EMAIL PROTECTED]</wsa:To>
-        <wsa:From actor="http://schemas.xmlsoap.org/soap/actor/next"; 
mustUnderstand="1">
+        <wsa:To soap:actor="urn:bob" soap:mustUnderstand="1">mailto:[EMAIL 
PROTECTED]</wsa:To>
+        <wsa:Action 
soap:actor="urn:bob">http://fabrikam123.com/mail#Delete</wsa:Action>
+        <wsa:RelatesTo 
soap:actor="urn:bob">uuid:11112222-3333-4444-5555-999999999999</wsa:RelatesTo>
+        <wsa:To soap:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
soap:mustUnderstand="1">mailto:[EMAIL PROTECTED]</wsa:To>
+        <wsa:From soap:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
soap:mustUnderstand="1">
             <wsa:Address>http://business456.com/client1</wsa:Address>
         </wsa:From>
-        <wsa:Recipient actor="http://schemas.xmlsoap.org/soap/actor/next"; 
mustUnderstand="1">
+        <wsa:Recipient soap:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
soap:mustUnderstand="1">
             
<wsa:Address>http://blah.com:8080/axis/services/tester</wsa:Address>
         </wsa:Recipient>
-        <wsa:Action 
actor="http://schemas.xmlsoap.org/soap/actor/next";>http://foo.com/mail#Get</wsa:Action>
-        <hp:ResourceID xmlns:hp="http://www/hp/com/"; 
actor="http://schemas.xmlsoap.org/soap/actor/next"; 
mustUnderstand="0">1234</hp:ResourceID>
+        <wsa:Action 
soap:actor="http://schemas.xmlsoap.org/soap/actor/next";>http://foo.com/mail#Get</wsa:Action>
+        <hp:ResourceID xmlns:hp="http://www/hp/com/"; 
soap:actor="http://schemas.xmlsoap.org/soap/actor/next"; 
soap:mustUnderstand="0">1234</hp:ResourceID>
     </Header>
 
     <Body>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to