axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
Subject svn commit: r451179 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/addressing/ addressing/src/org/apache/axis2/handlers/addressing/ addressing/test-resources/ addressing/test/org/apache/axis2/handlers/addressing/ kernel/src...
Date Fri, 29 Sep 2006 09:01:47 GMT
Author: pradine
Date: Fri Sep 29 02:01:46 2006
New Revision: 451179

URL: http://svn.apache.org/viewvc?view=rev&rev=451179
Log:
Add support for adding mustUnderstand attribute to ws-addressing headers.

Added:
    webservices/axis2/trunk/java/modules/addressing/test-resources/mustUnderstandTest.xml
Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    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/addressing/EndpointReferenceHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/EndpointReferenceHelper.java?view=diff&rev=451179&r1=451178&r2=451179
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
Fri Sep 29 02:01:46 2006
@@ -22,12 +22,12 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -151,33 +151,38 @@
      * namespace is in effect, however, then no metadata element will be included
      * in the output, even if a metadata property element has been defined.
      * 
+     * @param factory
      * @param epr
      * @param qname
      * @param addressingNamespace
      * @return
      * @throws AxisFault
      */
-    public static OMElement toOM(OMFactory fac, EndpointReference epr, QName qname, String
addressingNamespace) throws AxisFault {
+    public static OMElement toOM(OMFactory factory, EndpointReference epr, QName qname, String
addressingNamespace) throws AxisFault {
         OMElement eprElement = null;
         
         if (log.isDebugEnabled()) {
+            log.debug("toOM: Factory, " + factory);
             log.debug("toOM: Endpoint reference, " + epr);
             log.debug("toOM: Element qname, " + qname);
             log.debug("toOM: Addressing namespace, " + addressingNamespace);
         }
         
         if (qname.getPrefix() != null) {
-            OMNamespace wrapNs = fac.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
-            eprElement = fac.createOMElement(qname.getLocalPart(), wrapNs);
+            OMNamespace wrapNs = factory.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
+            if (factory instanceof SOAPFactory)
+                eprElement = ((SOAPFactory) factory).createSOAPHeaderBlock(qname.getLocalPart(),
wrapNs);
+            else
+                eprElement = factory.createOMElement(qname.getLocalPart(), wrapNs);
             
-            OMNamespace wsaNS = fac.createOMNamespace(addressingNamespace, AddressingConstants.WSA_DEFAULT_PREFIX);
-            OMElement addressE = fac.createOMElement(AddressingConstants.EPR_ADDRESS, wsaNS,
eprElement);
+            OMNamespace wsaNS = factory.createOMNamespace(addressingNamespace, AddressingConstants.WSA_DEFAULT_PREFIX);
+            OMElement addressE = factory.createOMElement(AddressingConstants.EPR_ADDRESS,
wsaNS, eprElement);
             String address = epr.getAddress();
             addressE.setText(address);
             
             List metaData = epr.getMetaData();
             if (metaData != null && AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNamespace))
{
-                OMElement metadataE = fac.createOMElement(AddressingConstants.Final.WSA_METADATA,
wsaNS, eprElement);
+                OMElement metadataE = factory.createOMElement(AddressingConstants.Final.WSA_METADATA,
wsaNS, eprElement);
                 for (int i = 0, size = metaData.size(); i < size; i++) {
                     OMNode omNode = (OMNode) metaData.get(i);
                     metadataE.addChild(omNode);
@@ -186,7 +191,7 @@
 
             Map referenceParameters = epr.getAllReferenceParameters();
             if (referenceParameters != null) {
-                OMElement refParameterElement = fac.createOMElement(AddressingConstants.EPR_REFERENCE_PARAMETERS,
wsaNS, eprElement);
+                OMElement refParameterElement = factory.createOMElement(AddressingConstants.EPR_REFERENCE_PARAMETERS,
wsaNS, eprElement);
                 Iterator iterator = referenceParameters.values().iterator();
                 while (iterator.hasNext()) {
                     OMNode omNode = (OMNode) iterator.next();

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=451179&r1=451178&r2=451179
==============================================================================
--- 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
Fri Sep 29 02:01:46 2006
@@ -36,6 +36,7 @@
 
 import javax.xml.namespace.QName;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 public class AddressingOutHandler extends AddressingHandler {
@@ -106,6 +107,9 @@
 
         // process fault headers, if present
         processFaultsInfoIfPresent(envelope, msgContext, addressingNamespaceObject, replaceHeaders);
+        
+        // process mustUnderstand attribute, if required.
+        processMustUnderstandProperty(envelope, msgContext, addressingNamespaceObject);
     }
 
     private void processWSAAction(Options messageContextOptions, SOAPEnvelope envelope,
@@ -312,6 +316,26 @@
         }
 
         return addressingHeader != null;
+    }
+    
+    /**
+     * Sets a mustUnderstand="1" attribute on all headers that are found with the appropriate
+     * addressing namespace.
+     * 
+     * @param envelope
+     * @param msgContext
+     * @param addressingNamespaceObject
+     */
+    private void processMustUnderstandProperty(SOAPEnvelope envelope, MessageContext msgContext,
OMNamespace addressingNamespaceObject) {
+        Object flag = msgContext.getProperty(AddressingConstants.ADD_MUST_UNDERSTAND_TO_ADDRESSING_HEADERS);
+        if (JavaUtils.isTrueExplicitly(flag)) {
+            List headers = envelope.getHeader().getHeaderBlocksWithNSURI(addressingNamespaceObject.getNamespaceURI());
+            Iterator iterator = headers.iterator();
+            while (iterator.hasNext()) {
+                SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) iterator.next();
+                soapHeaderBlock.setMustUnderstand(true);
+            }
+        }
     }
 }
 

Added: webservices/axis2/trunk/java/modules/addressing/test-resources/mustUnderstandTest.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test-resources/mustUnderstandTest.xml?view=auto&rev=451179
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/mustUnderstandTest.xml
(added)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/mustUnderstandTest.xml
Fri Sep 29 02:01:46 2006
@@ -0,0 +1,20 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+    <soapenv:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:myRef="http://reference.org">
+        <wsa:From soapenv:mustUnderstand="1">
+            <wsa:Address>http://www.from.org/service/</wsa:Address>
+            <wsa:ReferenceParameters>
+                <Reference2>Value 200</Reference2>
+            </wsa:ReferenceParameters>
+        </wsa:From>
+        <wsa:To soapenv:mustUnderstand="1">http://www.to.org/service/</wsa:To>
+        <wsa:MessageID soapenv:mustUnderstand="1">123456-7890</wsa:MessageID>
+        <myRef:Reference4>Value 400</myRef:Reference4>
+        <myRef:Reference3>Value 300</myRef:Reference3>
+        <wsa:Action soapenv:mustUnderstand="1">http://www.actions.org/action</wsa:Action>
+        <wsa:ReplyTo soapenv:mustUnderstand="1">
+            <wsa:Address>http://www.replyTo.org/service/</wsa:Address>
+        </wsa:ReplyTo>
+        <wsa:RelatesTo soapenv:mustUnderstand="1" wsa:RelationshipType="TestRelation">http://www.relatesTo.org/service/</wsa:RelatesTo>
+    </soapenv:Header>
+    <soapenv:Body></soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

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=451179&r1=451178&r2=451179
==============================================================================
--- 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
Fri Sep 29 02:01:46 2006
@@ -120,6 +120,49 @@
                 .getDocumentElement()));
     }
 
+    public void testMustUnderstandSupport() throws Exception {
+        msgCtxt = new MessageContext();
+
+        msgCtxt.setProperty(AddressingConstants.ADD_MUST_UNDERSTAND_TO_ADDRESSING_HEADERS,
Boolean.TRUE);
+        
+        EndpointReference epr = new EndpointReference("http://www.from.org/service/");
+        epr.addReferenceParameter(new QName("Reference2"),
+                "Value 200");
+        msgCtxt.setFrom(epr);
+
+        epr = new EndpointReference("http://www.to.org/service/");
+        epr.addReferenceParameter(
+                new QName("http://reference.org", "Reference4", "myRef"),
+                "Value 400");
+        epr.addReferenceParameter(
+                new QName("http://reference.org", "Reference3", "myRef"),
+                "Value 300");
+
+        msgCtxt.setTo(epr);
+        msgCtxt.setProperty(WS_ADDRESSING_VERSION, Submission.WSA_NAMESPACE);
+
+        epr =
+                new EndpointReference("http://www.replyTo.org/service/");
+        msgCtxt.setReplyTo(epr);
+
+        msgCtxt.setMessageID("123456-7890");
+        msgCtxt.setWSAAction("http://www.actions.org/action");
+
+        org.apache.axis2.addressing.RelatesTo relatesTo = new org.apache.axis2.addressing.RelatesTo(
+                "http://www.relatesTo.org/service/", "TestRelation");
+        msgCtxt.addRelatesTo(relatesTo);
+
+        msgCtxt.setEnvelope(
+                OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
+        outHandler.invoke(msgCtxt);
+
+        XMLComparator xmlComparator = new XMLComparator();
+        assertTrue(
+                xmlComparator.compare(msgCtxt.getEnvelope(),
+                        testUtil.getOMBuilder("mustUnderstandTest.xml")
+                .getDocumentElement()));
+    }
+
     public void testDuplicateHeaders() throws AxisFault {
 
         // this will check whether we can add to epr, if there is one already.

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=451179&r1=451178&r2=451179
==============================================================================
--- 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
Fri Sep 29 02:01:46 2006
@@ -68,6 +68,8 @@
     // this property once set to Boolean.TRUE will make the messages to skip Addressing Handler.
     // So you will not see Addressing Headers in the OUT path.
     public static final String DISABLE_ADDRESSING_FOR_OUT_MESSAGES = "disableAddressingForOutMessages";
+    
+    public static final String ADD_MUST_UNDERSTAND_TO_ADDRESSING_HEADERS = "addMustUnderstandToAddressingHeaders";
 
     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


Mime
View raw message