ws-addressing-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject svn commit: r368418 - in /webservices/addressing/trunk/src/org/apache/axis/message/addressing: AddressingHeaders.java Constants.java EndpointReference.java handler/AddressingHandler.java util/AddressingUtils.java
Date Thu, 12 Jan 2006 17:27:02 GMT
Author: gdaniels
Date: Thu Jan 12 09:26:52 2006
New Revision: 368418

URL: http://svn.apache.org/viewcvs?rev=368418&view=rev
Log:
More work for supporting W3C version, also actually echo reference parameters appropriately.

More to come...

Modified:
    webservices/addressing/trunk/src/org/apache/axis/message/addressing/AddressingHeaders.java
    webservices/addressing/trunk/src/org/apache/axis/message/addressing/Constants.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

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=368418&r1=368417&r2=368418&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
Thu Jan 12 09:26:52 2006
@@ -16,23 +16,20 @@
  */
 package org.apache.axis.message.addressing;
 
+import org.apache.axis.MessageContext;
+import org.apache.axis.message.MessageElement;
 import org.apache.axis.message.addressing.util.AddressingUtils;
 import org.apache.axis.message.addressing.util.TextExtractor;
-
-import org.apache.axis.message.MessageElement;
 import org.apache.axis.types.URI;
-import org.apache.axis.AxisEngine;
-import org.apache.axis.MessageContext;
-import org.apache.axis.utils.ArrayUtil;
+import org.apache.axis.utils.JavaUtils;
 import org.w3c.dom.Element;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.Name;
 import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPHeaderElement;
 import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.Name;
-
+import javax.xml.soap.SOAPHeaderElement;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -47,7 +44,7 @@
     /**
      * Are we using the W3C spec rules? (no ref props, etc...)
      */
-    boolean isW3CVersion = false;
+    public boolean isW3CVersion = false;
 
     /**
      * Field action
@@ -245,7 +242,7 @@
                 } else if (localName.equals(Constants.TO)) {
                     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 = AxisEngine.getCurrentMessageContext();
+                    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);
@@ -265,9 +262,10 @@
                                         localName);
                 }
             } else {
-                // its a reference property - check if it was added to refProps
-                if (!processReferenceProperty(headerElement,
-                                              refPropsQNames)) {
+                // it might be a reference property (wouldn't it be easier
+                // if they were all collected under, say wsa:To?)....
+                // check if it was added to refProps
+                if (!checkReferenceP(headerElement, refPropsQNames)) {
                     continue;
                 }
             }
@@ -363,6 +361,10 @@
         return referenceParameters;
     }
 
+    public void setReferenceParameters(List referenceParameters) {
+        this.referenceParameters = referenceParameters;
+    }
+
     public void addReferenceParameter(MessageElement refP) {
         if (referenceParameters == null) {
             referenceParameters = new ArrayList();
@@ -458,19 +460,17 @@
             }
         }
 
-        serializeReferenceProperties(env,
-                                     referenceProperties.get_any(),
-                                     actorURI,
-                                     false);
+        List refProps = (List)JavaUtils.convert(referenceProperties.get_any(),
+                                                ArrayList.class);
+        serializeReferencePs(env,
+                             refProps,
+                             actorURI,
+                             false);
         if (referenceParameters != null && !referenceParameters.isEmpty()) {
-            MessageElement [] refParams =
-                    (MessageElement []) ArrayUtil.convertObjectToArray(
-                            referenceParameters,
-                            MessageElement [].class);
-            serializeReferenceProperties(env,
-                                         refParams,
-                                         actorURI,
-                                         isW3CVersion);
+            serializeReferencePs(env,
+                                 referenceParameters,
+                                 actorURI,
+                                 isW3CVersion);
         }
     }
 
@@ -575,13 +575,15 @@
     }
 
     /**
-     * Add the reference property to the reference properties collection
+     * Take a SOAP header, check if it matches one of our reference
+     * properties/parameters, if so add it to the appropriate collection.
      * 
-     * @param headerElement
+     * @param headerElement the header to check
+     * @return true if it matched, false otherwise
      * @throws Exception
      */
-    private boolean processReferenceProperty(SOAPHeaderElement headerElement,
-                                             List refPropQNames)
+    private boolean checkReferenceP(SOAPHeaderElement headerElement,
+                                    List refPropQNames)
         throws Exception {
         Name name = headerElement.getElementName();
         QName elementName = new QName(name.getURI(), name.getLocalName());
@@ -598,15 +600,15 @@
     }
 
     /**
-     * Serialize the reference properties in the SOAP Header
+     * Serialize the reference properties/parameters in the SOAP Header
      * 
      * @param env
      * @param actorURI
      */
-    private void serializeReferenceProperties(SOAPEnvelope env,
-                                              MessageElement [] refPs,
-                                              String actorURI,
-                                              boolean addAttribute)
+    private void serializeReferencePs(SOAPEnvelope env,
+                                      List refPs,
+                                      String actorURI,
+                                      boolean addAttribute)
         throws Exception {
         // If no referenceProps are available, we are done
         if (refPs == null) { return; }
@@ -616,8 +618,8 @@
         if (header == null) { header = env.addHeader(); }
 
         // Add each ref property to SOAP Header
-        for (int i = 0; i < refPs.length; i++) {
-            MessageElement refProp = refPs[i];
+        for (int i = 0; i < refPs.size(); i++) {
+            MessageElement refProp = (MessageElement)refPs.get(i);
 
             element = makeSOAPHeader(refProp);
             element.setActor(actorURI);

Modified: webservices/addressing/trunk/src/org/apache/axis/message/addressing/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/addressing/trunk/src/org/apache/axis/message/addressing/Constants.java?rev=368418&r1=368417&r2=368418&view=diff
==============================================================================
--- webservices/addressing/trunk/src/org/apache/axis/message/addressing/Constants.java (original)
+++ webservices/addressing/trunk/src/org/apache/axis/message/addressing/Constants.java Thu
Jan 12 09:26:52 2006
@@ -217,10 +217,10 @@
      */
     public static final String WSDL_ATTRIB_ACTION = "Action";
 
-    public static final QName QN_ATTR_REFP =
-            new QName(NS_URI_ADDRESSING_2005_08, "IsReferenceParameter");
     /**
      * IsReferenceParameter attribute Name
      */
-    public static final Name ATTR_REFP = new PrefixedQName(QN_ATTR_REFP);
+    public static final Name ATTR_REFP = new PrefixedQName(NS_URI_ADDRESSING_2005_08,
+                                                           "IsReferenceParameter",
+                                                           "wsa");
 }

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=368418&r1=368417&r2=368418&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
Thu Jan 12 09:26:52 2006
@@ -201,7 +201,7 @@
      *
      * @param param XML rep of referenceParameter (MessageElement)
      */
-    private void addReferenceParameter(MessageElement param) {
+    public void addReferenceParameter(MessageElement param) {
         if (m_parameters == null) m_parameters = new ArrayList();
         m_parameters.add(param);
     }
@@ -286,14 +286,15 @@
         }
 
         // NOTE: ReferenceParameters were not part of the EPR type until WSA 2004/08.
-        if (AddressingUtils.getAddressingNamespaceURI().equals(
-                Constants.NS_URI_ADDRESSING_2004_08)) {
+        String namespaceURI = AddressingUtils.getAddressingNamespaceURI();
+        if (namespaceURI.equals(Constants.NS_URI_ADDRESSING_2004_08) ||
+                AddressingUtils.isW3CAddressingNamespaceURI(namespaceURI)) {
             List refParams = getParameters();
             if (refParams != null && !refParams.isEmpty()) {
                 Element refProp = doc.createElementNS(
                         AddressingUtils.getAddressingNamespaceURI(),
                         Constants.REFERENCE_PARAMETERS);
-                for (int i = 0; i < any.length; i++) {
+                for (int i = 0; i < refParams.size(); i++) {
                     MessageElement param = (MessageElement)refParams.get(i);
                     try {
                         refProp.appendChild(doc.importNode(param.getAsDOM(),

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=368418&r1=368417&r2=368418&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
Thu Jan 12 09:26:52 2006
@@ -179,15 +179,19 @@
         resHeaders.setMessageID(msgID);
 
         // now put all headers into soap env.
-        Message msg = msgContext.getCurrentMessage();
+        Message msg = msgContext.getResponseMessage();
         if (msg == null) {
             return;
         }
 
+        EndpointReferenceType faultTo = reqHeaders.getFaultTo();
+
+        resHeaders.setReferenceProperties(faultTo.getProperties());
+        resHeaders.setReferenceParameters(faultTo.getParameters());
+
         resHeaders.toEnvelope(msg.getSOAPEnvelope());
 
         // process FaultTo
-        EndpointReferenceType faultTo = reqHeaders.getFaultTo();
         if (faultTo != null) {
             AttributedURI address = faultTo.getAddress();
             if (address != null) {
@@ -526,6 +530,7 @@
         
         headers.setTo(address);
         headers.setReferenceProperties(epr.getProperties());
+        headers.setReferenceParameters(epr.getParameters());
 
         Service service = getService(msgContext);
 

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=368418&r1=368417&r2=368418&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
Thu Jan 12 09:26:52 2006
@@ -254,7 +254,11 @@
      */
     public static String getAnonymousRoleURI()
     {
-        return getAddressingNamespaceURI() + "/role/anonymous";
+        String namespaceURI = getAddressingNamespaceURI();
+        if (Constants.NS_URI_ADDRESSING_2005_08.equals(namespaceURI))
+            return Constants.URI_ANONYMOUS_W3C;
+
+        return namespaceURI + "/role/anonymous";
     }
 
     /**
@@ -278,6 +282,9 @@
 
         if (headers == null) {
             headers = new AddressingHeaders();
+            if (isW3CAddressingNamespaceURI(getAddressingNamespaceURI())) {
+                headers.isW3CVersion = true;
+            }
             // set property so other handlers might have a chance to use/modify
             msgContext.setProperty(type, headers);
         }



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


Mime
View raw message