synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r521985 - in /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: core/axis2/ mediators/builtin/
Date Sat, 24 Mar 2007 06:33:36 GMT
Author: asankha
Date: Fri Mar 23 23:33:35 2007
New Revision: 521985

URL: http://svn.apache.org/viewvc?view=rev&rev=521985
Log:
Fix SYNAPSE-83 and replace deprecated UUIDGenerator and fix relationships/message ID's properly

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?view=diff&rev=521985&r1=521984&r2=521985
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
Fri Mar 23 23:33:35 2007
@@ -42,7 +42,7 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.neethi.Policy;
@@ -188,7 +188,7 @@
 
         // do not copy options from the original
         newMC.setConfigurationContext(ori.getConfigurationContext());
-        newMC.setMessageID("uuid:" + UUIDGenerator.getUUID());
+        newMC.setMessageID(UUIDGenerator.getUUID());
         newMC.setTo(ori.getTo());
         newMC.setSoapAction(ori.getSoapAction());
 
@@ -253,7 +253,7 @@
      * @param axisMsgCtx the Axis2 Message context
      * @return the resulting SOAPEnvelope
      */
-    private static SOAPEnvelope removeAddressingHeaders(MessageContext axisMsgCtx) {
+    public static SOAPEnvelope removeAddressingHeaders(MessageContext axisMsgCtx) {
 
         SOAPEnvelope env = axisMsgCtx.getEnvelope();
         SOAPHeader soapHeader = env.getHeader();
@@ -299,5 +299,5 @@
                }
            }
        }
-   } 
+   }
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java?view=diff&rev=521985&r1=521984&r2=521985
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
Fri Mar 23 23:33:35 2007
@@ -28,6 +28,7 @@
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.endpoints.utils.EndpointDefinition;
 import org.apache.synapse.statistics.StatisticsUtils;
+import org.apache.axiom.om.util.UUIDGenerator;
 
 /**
  * This class helps the Axis2SynapseEnvironment implement the send method
@@ -69,6 +70,8 @@
                 StatisticsUtils.processProxyServiceStatistics(smc);
                 StatisticsUtils.processAllSequenceStatistics(smc);
             }
+            Axis2FlexibleMEPClient.removeAddressingHeaders(messageContext);
+            messageContext.setMessageID(UUIDGenerator.getUUID());
             ae.send(messageContext);
 
         } catch (AxisFault e) {

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java?view=diff&rev=521985&r1=521984&r2=521985
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java
Fri Mar 23 23:33:35 2007
@@ -35,6 +35,7 @@
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.util.UUIDGenerator;
 
 import javax.xml.namespace.QName;
 
@@ -183,10 +184,9 @@
             // message, so that it could be tied back to the original request even if the
response
             // envelope does not contain addressing headers
             MessageContext responseMessageContext = new MessageContext();
+            responseMessageContext.setMessageID(msgctx.getMessageID());
             responseMessageContext.addRelatesTo(new RelatesTo(msgctx.getMessageID()));
-
             responseMessageContext.setOptions(options);
-			responseMessageContext.setMessageID(msgctx.getMessageID());
 			addMessageContext(responseMessageContext);
 
             AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java?view=diff&rev=521985&r1=521984&r2=521985
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
Fri Mar 23 23:33:35 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.client.async.Callback;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.RelatesTo;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.Constants;
@@ -52,6 +53,14 @@
             String messageID  = messageCtx.getOptions().getRelatesTo().getValue();
             Callback callback = (Callback) callbackStore.remove(messageID);
 
+            RelatesTo[] relates = messageCtx.getRelationships();
+            if (relates.length > 1) {
+                // we set a relates to to the response message so that if WSA is not used,
we
+                // could still link back to the original message. But if WSA was used, this
+                // gets duplicated, and we should remove it
+                removeDuplicateRelatesTo(messageCtx, relates);
+            }
+
             if (callback != null) {
                 handleMessage(messageCtx, ((AsyncCallback) callback).getSynapseOutMsgCtx());
             } else {
@@ -88,7 +97,7 @@
                 SOAPFault fault = response.getEnvelope().getBody().getFault();
                 Exception e = fault.getException();
                 if (e == null) {
-                    e = new Exception(fault.getReason().getFirstSOAPText().getText());  
 
+                    e = new Exception(fault.toString());    
                 }
 
                 ((FaultHandler) faultStack.pop()).handleFault(synapseOutMsgCtx,e);
@@ -130,6 +139,10 @@
 
             // If request is REST assume that the response is REST too
             response.setDoingREST(axisOutMsgCtx.isDoingREST());
+            if (axisOutMsgCtx.getMessageID() != null) {
+                response.setRelationships(
+                    new RelatesTo[] {new RelatesTo(axisOutMsgCtx.getMessageID())});
+            }
 
             // create the synapse message context for the response
             Axis2MessageContext synapseInMessageContext =
@@ -154,5 +167,32 @@
             synapseOutMsgCtx.getEnvironment().
                 injectMessage(synapseInMessageContext);
         }
+    }
+
+    private void removeDuplicateRelatesTo(MessageContext mc, RelatesTo[] relates) {
+
+        int insertPos = 0;
+        RelatesTo[] newRelates = new RelatesTo[relates.length];
+
+        for (int i=0; i<relates.length; i++) {
+            RelatesTo current = relates[i];
+            boolean found = false;
+
+            for (int j=0; j<newRelates.length && j<insertPos; j++) {
+                if (newRelates[j].equals(current) ||
+                    newRelates[j].getValue().equals(current.getValue())) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                newRelates[insertPos++] = current;
+            }
+        }
+
+        RelatesTo[] trimmedRelates = new RelatesTo[insertPos];
+        System.arraycopy(newRelates, 0, trimmedRelates, 0, insertPos);
+        mc.setRelationships(trimmedRelates);
     }
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java?view=diff&rev=521985&r1=521984&r2=521985
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
Fri Mar 23 23:33:35 2007
@@ -26,7 +26,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.Constants;



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


Mime
View raw message