tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edward...@apache.org
Subject svn commit: r956193 - 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 Sat, 19 Jun 2010 06:41:05 GMT
Author: edwardsmj
Date: Sat Jun 19 06:41:04 2010
New Revision: 956193

URL: http://svn.apache.org/viewvc?rev=956193&view=rev
Log:
Handle the wsa:ReferenceParameters SOAP header if present on the invocation of a bidirectional
service offered as a Web service - pass the parameters back in the SOAP headers of any callback
operation invocation from the service to the client, as required by 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=956193&r1=956192&r2=956193&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
Sat Jun 19 06:41:04 2010
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.binding.w
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.Iterator;
 
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
@@ -28,6 +29,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
@@ -156,7 +158,7 @@ public class Axis2ReferenceBindingInvoke
         requestMC.setTo( new EndpointReference(toAddress) ); 
         
         if( isInvocationForCallback( msg ) ) {
-        	addWSAToHeader( sh, toAddress );
+        	addWSAToHeader( sh, toAddress, msg );
         	addWSAActionHeader( sh );
         	addWSARelatesTo( sh, msg );
         } // end if 
@@ -204,13 +206,23 @@ public class Axis2ReferenceBindingInvoke
 
     } // end method addWSAFromHeader
     
-    private void addWSAToHeader( SOAPHeader sh, String address ) {
+    private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+    private void addWSAToHeader( SOAPHeader sh, String address, Message msg ) {
         // Create wsa:To header which is required by ws-addressing spec
-
         OMElement wsaToOM = sh.getOMFactory().createOMElement(QNAME_WSA_TO);
         wsaToOM.setText( address );
         sh.addChild(wsaToOM);
         
+        // Deal with Reference Parameters, if present - copy to the header without the wsa:ReferenceParameters
wrapper
+        OMElement refParms = (OMElement) msg.getHeaders().get(WS_REF_PARMS);
+        if( refParms != null ) {
+        	Iterator<?> children = refParms.getChildren();
+        	while( children.hasNext() ) {
+        		OMNode node = (OMNode) children.next();
+        		sh.addChild(node);
+        	}
+        } // end if 
+        
     } // end method addWSAActionHeader
         
     

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=956193&r1=956192&r2=956193&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
Sat Jun 19 06:41:04 2010
@@ -50,6 +50,8 @@ public class TuscanyServiceProvider {
         new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
     public static final QName QNAME_WSA_FROM =
         new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
+    public static final QName QNAME_WSA_REPLYTO =
+        new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_REPLY_TO);
     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 =
@@ -107,15 +109,7 @@ public class TuscanyServiceProvider {
         //FIXME: can we use the Axis2 addressing support for this?
         SOAPHeader header = inMC.getEnvelope().getHeader();
         if (header != null) {
-            OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
-            if (from != null) {
-                OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
-                if (callbackAddrElement != null) {
-                    if (endpoint.getService().getInterfaceContract().getCallbackInterface()
!= null) {
-                        callbackAddress = callbackAddrElement.getText();
-                    }
-                }
-            } // end if
+            callbackAddress = handleCallbackAddress( header, msg );
             // Retrieve other callback-related headers
             handleMessageIDHeader( header, msg );
         } // end if
@@ -149,6 +143,27 @@ public class TuscanyServiceProvider {
         }
         return response.getBody();
     } // end method 
+
+    private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
+    private String handleCallbackAddress( SOAPHeader header, Message msg ) {
+    	String callbackAddress = null;
+        
+    	OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
+    	if( from == null ) from = header.getFirstChildWithName(QNAME_WSA_REPLYTO);
+    	
+        if (from != null) {
+            OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
+            if (callbackAddrElement != null) {
+                if (endpoint.getService().getInterfaceContract().getCallbackInterface() !=
null) {
+                    callbackAddress = callbackAddrElement.getText();
+                }
+                OMElement refParms = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+                if( refParms != null ) msg.getHeaders().put(WS_REF_PARMS, refParms);
+            }
+        } // end if
+    	
+    	return callbackAddress;
+    } // end method handleCallbackAddress
     
     private static String WS_MESSAGE_ID = "WS_MESSAGE_ID";
     /**



Mime
View raw message