Author: chamikara
Date: Sun Apr 22 09:50:18 2007
New Revision: 531227

URL: http://svn.apache.org/viewvc?view=rev&rev=531227
Log:
Corrected the SandeshaClient.terminateSequence method.
        - This was not sending an ampty LastMessage in the WSRM 1.0 case, but 
this is wrong according to the protocol.
Several other bug fixes.

Modified:
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/client/SandeshaClient.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/StorageManager.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InvokerWorker.java
    
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java 
(original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java 
Sun Apr 22 09:50:18 2007
@@ -221,7 +221,7 @@
                        Iterator ops = service.getOperations();
                        while(ops.hasNext()) {
                                AxisOperation op = (AxisOperation) ops.next();
-                               log.debug("Examining operation " + op.getName() 
+ ", mep " + op.getAxisSpecifMEPConstant());
+                               log.debug("Examining operation " + op.getName() 
+ ", mep " + op.getMessageExchangePattern());
 
                                String name = null;
                                QName qName = op.getName();

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/client/SandeshaClient.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/client/SandeshaClient.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/client/SandeshaClient.java
 (original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/client/SandeshaClient.java
 Sun Apr 22 09:50:18 2007
@@ -31,6 +31,7 @@
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
@@ -472,17 +473,30 @@
 
                String oldAction = options.getAction();
 
-               SOAPEnvelope terminateEnvelope = 
configureTerminateSequence(options, serviceContext.getConfigurationContext());
-               OMElement terminateBody = 
terminateEnvelope.getBody().getFirstChildWithName(
-                               new QName(rmNamespaceValue, 
Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));
-
+               //in WSRM 1.0 we are adding another application msg with the 
LastMessage tag, instead of sending a terminate here.
+               //Actual terminate will be sent once all the messages upto this 
get acked
+               
                try {
-                       //to inform the Sandesha2 out handler.
-                       serviceClient.fireAndForget (terminateBody);            
                
+                       if 
(Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(rmSpecVersion)) {
+                               SOAPEnvelope terminateEnvelope = 
configureTerminateSequence(options, serviceContext
+                                               .getConfigurationContext());
+                               OMElement terminateBody = 
terminateEnvelope.getBody().getFirstChildWithName(
+                                               new QName(rmNamespaceValue,
+                                                               
Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));
+
+                               // to inform the Sandesha2 out handler.
+                               serviceClient.fireAndForget(terminateBody);
+
+                       } else {
+                               
options.setAction(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_LAST_MESSAGE);
+                               
options.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
+                               serviceClient.fireAndForget(null);
+
+                       }
+                       
                } catch (AxisFault e) {
                        String message = SandeshaMessageHelper.getMessage(
-                                       
SandeshaMessageKeys.couldNotSendTerminate,
-                                       e.toString());
+                                       
SandeshaMessageKeys.couldNotSendTerminate, e.toString());
                        throw new SandeshaException(message, e);
                } finally {
                        options.setAction(oldAction);

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
 (original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
 Sun Apr 22 09:50:18 2007
@@ -138,11 +138,11 @@
                                }
                        }
                                
-                       // Server-side, when we are suspend the outbound flow 
we may still be connected to an
-                       // inbound transport. If we are then they don't see the 
InvocationResponse that we
-                       // return, so we need to set a flag on the operation 
context too.
+                       //we need the incoming thread to wait when suspending.
+                       //Hence adding the boolean property.
+                       //Should be done only to the server side
                        OperationContext opCtx = msgCtx.getOperationContext();
-                       if(opCtx != null && returnValue == 
InvocationResponse.SUSPEND) {
+                       if(msgCtx.isServerSide() && opCtx != null && 
returnValue == InvocationResponse.SUSPEND) {
                                if(log.isDebugEnabled()) log.debug("Setting 
HOLD_RESPONSE property");
                                
opCtx.setProperty(RequestResponseTransport.HOLD_RESPONSE, Boolean.TRUE);
                        }

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/StorageManager.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/StorageManager.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/StorageManager.java
 (original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/StorageManager.java
 Sun Apr 22 09:50:18 2007
@@ -58,6 +58,9 @@
                
                thread = getPollingManager();
                if(thread != null) thread.stopRunning();
+               
+               //removing the reference to the configuration context
+               context=null;
        }
        
        public abstract void initStorage (AxisModule moduleDesc) throws 
SandeshaStorageException;

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java 
(original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java 
Sun Apr 22 09:50:18 2007
@@ -282,6 +282,8 @@
                // no need for an incoming transport for a terminate
                // message. If this is put, sender will look for an response.
                terminateMessage.setProperty(MessageContext.TRANSPORT_IN, 
null); 
+
+               terminateMessage.setTo(new EndpointReference 
(rmsBean.getToEPR()));
                
                // Ensure the correct token is used to secure the terminate 
sequence
                secureOutboundMessage(rmsBean, terminateMessage);

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InvokerWorker.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InvokerWorker.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InvokerWorker.java
 (original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InvokerWorker.java
 Sun Apr 22 09:50:18 2007
@@ -3,9 +3,11 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.RequestResponseTransport;
 import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -109,7 +111,7 @@
                                        transaction.rollback();
                                        transaction = 
storageManager.getTransaction();
                                }
-                               handleFault(msgToInvoke, e);
+                               handleFault(rmMsg, e);
                        }
 
                        if (rmMsg.getMessageType() == 
Sandesha2Constants.MessageTypes.APPLICATION) {
@@ -180,7 +182,8 @@
                
messageContext.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, 
Sandesha2Constants.VALUE_TRUE);
        }
 
-       private void handleFault(MessageContext inMsgContext, Exception e) {
+       private void handleFault(RMMsgContext inRMMsgContext, Exception e) {
+               MessageContext inMsgContext = 
inRMMsgContext.getMessageContext();
                AxisEngine engine = new 
AxisEngine(inMsgContext.getConfigurationContext());
                try {                                   
                        MessageContext faultContext = 
MessageContextBuilder.createFaultMessageContext(inMsgContext, e);
@@ -188,7 +191,21 @@
                        
faultContext.setProperty(Constants.Configuration.CONTENT_TYPE, inMsgContext
                                        
.getProperty(Constants.Configuration.CONTENT_TYPE));
 
-                       engine.sendFault(faultContext);
+                       EndpointReference faultEPR = 
inRMMsgContext.getFaultTo();
+                       if (faultEPR==null)
+                               faultEPR = inRMMsgContext.getReplyTo();
+                       
+                       //we handler the WSRM Anon InOut scenario differently 
here
+                       if 
(Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(inRMMsgContext.getRMSpecVersion())
+                                       && (faultEPR==null || 
faultEPR.hasAnonymousAddress())) {
+                               RequestResponseTransport 
requestResponseTransport = (RequestResponseTransport) 
inRMMsgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+                               
+                               //this will cause the fault to be thrown out of 
thread waiting on this transport object.
+                               AxisFault fault = new AxisFault ("Sandesha2 got 
a fault when doing the invocation", faultContext);
+                               
requestResponseTransport.signalFaultReady(fault);
+                       } else  
+                               engine.sendFault(faultContext);
+                       
                } catch (AxisFault e1) {
                        if (log.isErrorEnabled())
                                log.error("Unable to send fault message ", e1);

Modified: 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java?view=diff&rev=531227&r1=531226&r2=531227
==============================================================================
--- 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java
 (original)
+++ 
webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java
 Sun Apr 22 09:50:18 2007
@@ -1,6 +1,7 @@
 package org.apache.sandesha2.workers;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -201,6 +202,8 @@
                                transaction = null;
                        }
 
+                       msgCtx.getOptions().setTimeOutInMilliSeconds(1000000);
+                       
                        try {
                                AxisEngine engine = new AxisEngine 
(msgCtx.getConfigurationContext());
                                InvocationResponse response = 
InvocationResponse.CONTINUE;
@@ -465,10 +468,35 @@
                        // create the responseMessageContext
 
                        MessageContext responseMessageContext = new 
MessageContext();
+
+                       OperationContext requestMsgOpCtx = 
msgCtx.getOperationContext();
+                       
responseMessageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
 requestMsgOpCtx
+                                                       
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
+                       
responseMessageContext.setProperty(Constants.Configuration.CONTENT_TYPE, 
requestMsgOpCtx
+                                                       
.getProperty(Constants.Configuration.CONTENT_TYPE));
+                       
responseMessageContext.setProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE, 
requestMsgOpCtx
+                                       
.getProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE));
+
+            //If the response MsgCtx was not available Axis2 would hv put the 
transport info into a 
+            //HashMap, getting the data from it.
+                       HashMap transportInfoMap = (HashMap) 
msgCtx.getProperty(Constants.Configuration.TRANSPORT_INFO_MAP);
+                       if (transportInfoMap != null) {
+                               
responseMessageContext.setProperty(Constants.Configuration.CONTENT_TYPE, 
+                                                               
transportInfoMap.get(Constants.Configuration.CONTENT_TYPE));
+                               
responseMessageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
+                                               
transportInfoMap.get(Constants.Configuration.CHARACTER_SET_ENCODING));
+                       }
                        
                        //setting the message as serverSide will let it go 
through the MessageReceiver (may be callback MR).
                        responseMessageContext.setServerSide(true);
                        
+                       if (responseMessageContext.getSoapAction()==null) {
+                               //if there is no SOAP action in the response 
message, Axis2 will wrongly identify it as a REST message
+                               //This happens because we set serverSide to 
True in a previous step.
+                               //So we have to add a empty SOAPAction here.
+                               responseMessageContext.setSoapAction("");
+                       }
+                       
                        
responseMessageContext.setConfigurationContext(msgCtx.getConfigurationContext());
                        
responseMessageContext.setTransportIn(msgCtx.getTransportIn());
                        
responseMessageContext.setTransportOut(msgCtx.getTransportOut());
@@ -480,20 +508,6 @@
 
                        
responseMessageContext.setProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY,
                                        
msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY));
-
-                       // copying required properties from op. context to the 
response msg
-                       // ctx.
-                       
-                       // copying required properties from request op. context 
to the response msg
-                       // ctx.
-                       
-                       OperationContext requestMsgOpCtx = 
msgCtx.getOperationContext();
-                       
responseMessageContext.setProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE, 
requestMsgOpCtx
-                                                       
.getProperty(HTTPConstants.MTOM_RECEIVED_CONTENT_TYPE));
-                       
responseMessageContext.setProperty(HTTPConstants.CHAR_SET_ENCODING, 
requestMsgOpCtx
-                                                       
.getProperty(HTTPConstants.CHAR_SET_ENCODING));
-                       
responseMessageContext.setProperty(Constants.Configuration.CONTENT_TYPE, 
requestMsgOpCtx
-                                                       
.getProperty(Constants.Configuration.CONTENT_TYPE));
 
                        // If request is REST we assume the 
responseMessageContext is REST,
                        // so set the variable



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

Reply via email to