summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2010-06-18 21:02:02 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2010-06-18 21:02:02 +0000
commitc8ac9d68bc34566fc6f03dcfe25da1b500e2ab54 (patch)
tree5204175f647a510431673ed0148d0ab4b2924e35
parent99f951468fdd48de1004614e15595d1a300c4c33 (diff)
Handle the receipt of messageID data from a wsa:MessageID header in an incoming Web service invocation of a bidirectional service, transmit this data to the callback invocation from the service and embed into a wsa:RelatesTo SOAP header in the callback Wen service message, as required by the OASIS Web Service Binding spec, described in TUSCANY-3592
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@956128 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java38
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java24
2 files changed, 49 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
index dd05e6ab32..e02547e727 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
@@ -26,6 +26,7 @@ import javax.wsdl.Operation;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
@@ -59,20 +60,17 @@ import org.oasisopen.sca.ServiceRuntimeException;
*/
public class Axis2ReferenceBindingInvoker implements Invoker {
public static final QName QNAME_WSA_FROM =
- new QName(AddressingConstants.Final.WSA_NAMESPACE,
- AddressingConstants.WSA_FROM,
- AddressingConstants.WSA_DEFAULT_PREFIX);
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM, AddressingConstants.WSA_DEFAULT_PREFIX);
public static final QName QNAME_WSA_TO =
- new QName(AddressingConstants.Final.WSA_NAMESPACE,
- AddressingConstants.WSA_TO,
- AddressingConstants.WSA_DEFAULT_PREFIX);
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
public static final QName QNAME_WSA_ACTION =
- new QName(AddressingConstants.Final.WSA_NAMESPACE,
- AddressingConstants.WSA_ACTION,
- AddressingConstants.WSA_DEFAULT_PREFIX);
-
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_ACTION, AddressingConstants.WSA_DEFAULT_PREFIX);
+
+ public static final QName QNAME_WSA_RELATESTO =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_RELATES_TO, AddressingConstants.WSA_DEFAULT_PREFIX);
+
private RuntimeEndpointReference endpointReference;
private ServiceClient serviceClient;
private QName wsdlOperationName;
@@ -160,6 +158,7 @@ public class Axis2ReferenceBindingInvoker implements Invoker {
if( isInvocationForCallback( msg ) ) {
addWSAToHeader( sh, toAddress );
addWSAActionHeader( sh );
+ addWSARelatesTo( sh, msg );
} // end if
// Allow privileged access to read properties. Requires PropertiesPermission read in
@@ -229,6 +228,25 @@ public class Axis2ReferenceBindingInvoker implements Invoker {
actionOM.setText(action == null ? "" : action);
sh.addChild(actionOM);
} // end method addWSAActionHeader
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ protected static String SCA_CALLBACK_REL = "http://docs.oasis-open.org/opencsa/sca-bindings/ws/callback";
+ /**
+ * Adds a wsa:RelatesTo SOAP header if the incoming invocation had a wsa:MessageID SOAP header present
+ * - note that OASIS SCA requires that the RelationshipType attribute is set to a particular SCA value
+ * @param sh - the SOAP headers
+ * @param msg - the message
+ */
+ private void addWSARelatesTo( SOAPHeader sh, Message msg ) {
+ String idValue = (String) msg.getHeaders().get(WS_MESSAGE_ID);
+ if( idValue != null ){
+ OMElement relatesToOM = sh.getOMFactory().createOMElement( QNAME_WSA_RELATESTO );
+ OMAttribute relType = sh.getOMFactory().createOMAttribute("RelationshipType", null, SCA_CALLBACK_REL);
+ relatesToOM.addAttribute( relType );
+ relatesToOM.setText( idValue );
+ sh.addChild( relatesToOM );
+ }
+ } // end method addWSARelatesTo
/**
* Indicates if the invocation is for the callback of a bidirectional service
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
index efc202b4d5..d73879463e 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
@@ -52,7 +52,8 @@ public class TuscanyServiceProvider {
new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
-
+ public static final QName QNAME_WSA_MESSAGEID =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_MESSAGE_ID);
private RuntimeEndpoint endpoint;
private WebServiceBinding wsBinding;
@@ -116,7 +117,8 @@ public class TuscanyServiceProvider {
}
} // end if
// Retrieve other callback-related headers
- }
+ handleMessageIDHeader( header, msg );
+ } // end if
// Create a from EPR to hold the details of the callback endpoint
EndpointReference from = null;
@@ -146,5 +148,21 @@ public class TuscanyServiceProvider {
throw new InvocationTargetException((Throwable) response.getBody());
}
return response.getBody();
- }
+ } // end method
+
+ private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
+ /**
+ * Handle a SOAP wsa:MessageID header - place the contents into the Tuscany message for use by any callback
+ * @param header - the SOAP Headers
+ * @param msg - the Tuscany Message
+ */
+ private void handleMessageIDHeader( SOAPHeader header, Message msg ) {
+ if( header == null ) return;
+ OMElement messageID = header.getFirstChildWithName(QNAME_WSA_MESSAGEID);
+ if (messageID != null) {
+ String idValue = messageID.getText();
+ // Store the value of the message ID element into the message under "WS_MESSAGE_ID"...
+ msg.getHeaders().put(WS_MESSAGE_ID, idValue);
+ } // end if
+ } // end method handleMessageID
}