You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/05/09 06:42:13 UTC
svn commit: r536414 - in /webservices/synapse/trunk/java/modules:
core/src/main/java/org/apache/synapse/
core/src/main/java/org/apache/synapse/core/axis2/
nhttp/src/org/apache/axis2/transport/nhttp/
Author: asankha
Date: Tue May 8 21:42:12 2007
New Revision: 536414
URL: http://svn.apache.org/viewvc?view=rev&rev=536414
Log:
Fix WS-RM for endpoints for RM version 1.0
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.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/nhttp/src/org/apache/axis2/transport/nhttp/ClientHandler.java
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java?view=diff&rev=536414&r1=536413&r2=536414
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java Tue May 8 21:42:12 2007
@@ -48,6 +48,9 @@
/** The system property used to specify/override the synapse configuration XML location */
String SYNAPSE_XML = "synapse.xml";
+ /** a message context property set to hold the relates to for POX responses */
+ String RELATES_TO_FOR_POX = "RelatesToForPox";
+
/** If the message context contains a Boolean.TRUE with this key, WS-A would be turned on send */
String OUTFLOW_ADDRESSING_ON = "OUTFLOW_ADDRESSING_ON";
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=536414&r1=536413&r2=536414
==============================================================================
--- 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 Tue May 8 21:42:12 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.synapse.Constants;
import javax.xml.namespace.QName;
@@ -184,7 +185,7 @@
// envelope does not contain addressing headers
MessageContext responseMessageContext = new MessageContext();
responseMessageContext.setMessageID(msgctx.getMessageID());
- responseMessageContext.addRelatesTo(new RelatesTo(msgctx.getMessageID()));
+ responseMessageContext.setProperty(Constants.RELATES_TO_FOR_POX, msgctx.getMessageID());
responseMessageContext.setOptions(options);
addMessageContext(responseMessageContext);
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=536414&r1=536413&r2=536414
==============================================================================
--- 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 Tue May 8 21:42:12 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.util.Utils;
import org.apache.axis2.transport.nhttp.NhttpConstants;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.commons.logging.Log;
@@ -32,6 +33,7 @@
import org.apache.synapse.SynapseException;
import org.apache.synapse.endpoints.Endpoint;
import org.apache.axiom.soap.SOAPFault;
+import org.apache.sandesha2.client.SandeshaClientConstants;
import java.util.*;
@@ -61,18 +63,25 @@
public void receive(MessageContext messageCtx) throws AxisFault {
+ String messageID = null;
+
if (messageCtx.getOptions() != null && messageCtx.getOptions().getRelatesTo() != null) {
- String messageID = messageCtx.getOptions().getRelatesTo().getValue();
+ messageID = messageCtx.getOptions().getRelatesTo().getValue();
+ } else if (messageCtx.getProperty(SandeshaClientConstants.SEQUENCE_KEY) == null) {
+ messageID = (String) messageCtx.getProperty(Constants.RELATES_TO_FOR_POX);
+ }
+
+ if (messageID != null) {
Callback callback = (Callback) callbackStore.remove(messageID);
RelatesTo[] relates = messageCtx.getRelationships();
- if (relates.length > 1) {
+ if (relates != null && 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 {
@@ -81,7 +90,7 @@
messageID + " But a callback has not been registered to process this response");
}
- } else {
+ } else if (!Utils.isExplicitlyTrue(messageCtx, NhttpConstants.SC_ACCEPTED)){
// TODO invoke a generic synapse error handler for this message
log.warn("Synapse received a response message without a message Id");
}
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientHandler.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientHandler.java?view=diff&rev=536414&r1=536413&r2=536414
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientHandler.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientHandler.java Tue May 8 21:42:12 2007
@@ -290,6 +290,11 @@
try {
MessageContext responseMsgCtx = outMsgCtx.getOperationContext().
getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
+ if (responseMsgCtx == null) {
+ // to support Sandesha.. however, this means that we received a 202 accepted
+ // for an out-only , for which we do not need a dummy message anyway
+ return;
+ }
responseMsgCtx.setServerSide(true);
responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
responseMsgCtx.setProperty(MessageContext.TRANSPORT_IN,
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java?view=diff&rev=536414&r1=536413&r2=536414
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java Tue May 8 21:42:12 2007
@@ -82,9 +82,21 @@
return;
}
- if (responseMsgCtx == null) {
- log.error("Error getting IN message context from the operation context");
+ // this conditional block is to support Sandesha, as it uses an out-in mep, but without
+ // creating the message context to write the response and adding it into the operation
+ // context, as it may get a 202 accepted or 200. So if the operation is complete ignore
+ // this message, else, create a new message context and handle this
+ if (responseMsgCtx == null && outMsgCtx.getOperationContext().isComplete()) {
+ log.debug("Error getting IN message context from the operation context. " +
+ "Possibly an RM terminate sequence message");
+ return;
+
} else {
+ if (responseMsgCtx == null) {
+ responseMsgCtx = new MessageContext();
+ responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
+ }
+
responseMsgCtx.setServerSide(true);
responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
responseMsgCtx.setProperty(MessageContext.TRANSPORT_IN, outMsgCtx
@@ -107,8 +119,6 @@
getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
responseMsgCtx.setConfigurationContext(outMsgCtx.getConfigurationContext());
- //responseMsgCtx.getOptions().setRelationships(
- // new RelatesTo[] { new RelatesTo(outMsgCtx.getMessageID()) });
responseMsgCtx.setTo(null);
}
}
@@ -117,6 +127,12 @@
* Process the received response through Axis2
*/
public void run() {
+ // to support Sandesha.. if there isn't a response message context, we cannot read any
+ // response and populate it with the soap envelope
+ if (responseMsgCtx == null) {
+ return;
+ }
+
SOAPEnvelope envelope = null;
try {
String contentType = response.getFirstHeader(HTTP.CONTENT_TYPE).getValue();
Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java?view=diff&rev=536414&r1=536413&r2=536414
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java Tue May 8 21:42:12 2007
@@ -65,6 +65,7 @@
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
+import org.apache.sandesha2.Sandesha2Constants;
/**
* NIO transport sender for Axis2 based on HttpCore and NIO extensions
@@ -312,7 +313,9 @@
// if this is a dummy message to handle http 202 case with non-blocking IO
// set the status code to 202 and the message body to an empty byte array (see below)
- if (Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED)) {
+ if (Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED) &&
+ msgContext.getProperty(
+ Sandesha2Constants.MessageContextProperties.SEQUENCE_ID) == null) {
response.setStatusCode(HttpStatus.SC_ACCEPTED);
}
@@ -332,11 +335,13 @@
OutputStream out = worker.getOutputStream();
try {
- if (!Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED)) {
- messageFormatter.writeTo(msgContext, format, out, true);
- } else {
+ if (Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED) &&
+ msgContext.getProperty(
+ Sandesha2Constants.MessageContextProperties.SEQUENCE_ID) == null) {
// see comment above on the reasoning
out.write(new byte[0]);
+ } else {
+ messageFormatter.writeTo(msgContext, format, out, true);
}
out.close();
} catch (IOException e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org