tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edward...@apache.org
Subject svn commit: r956128 - in /tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider: Axis2ReferenceBindingInvoker.java TuscanyServiceProvider.java
Date Fri, 18 Jun 2010 21:02:03 GMT
Author: edwardsmj
Date: Fri Jun 18 21:02:02 2010
New Revision: 956128

URL: http://svn.apache.org/viewvc?rev=956128&view=rev
Log:
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

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
    tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java?rev=956128&r1=956127&r2=956128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
Fri Jun 18 21:02:02 2010
@@ -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.ServiceRuntimeE
  */
 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 Axis2ReferenceBindingInvoke
         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 Axis2ReferenceBindingInvoke
         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

Modified: tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java?rev=956128&r1=956127&r2=956128&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
Fri Jun 18 21:02:02 2010
@@ -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
 }



Mime
View raw message