You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ng...@apache.org on 2007/02/18 21:55:19 UTC

svn commit: r508994 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: client/ClientUtils.java core/controller/AxisInvocationController.java

Author: ngallardo
Date: Sun Feb 18 12:55:18 2007
New Revision: 508994

URL: http://svn.apache.org/viewvc?view=rev&rev=508994
Log:
Moved SOAPAction determination code to a util class.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/ClientUtils.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/ClientUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/ClientUtils.java?view=auto&rev=508994
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/ClientUtils.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/ClientUtils.java Sun Feb 18 12:55:18 2007
@@ -0,0 +1,59 @@
+package org.apache.axis2.jaxws.client;
+
+import org.apache.axis2.jaxws.BindingProvider;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ClientUtils {
+    
+    private static Log log = LogFactory.getLog(ClientUtils.class);    
+    
+    /**
+     * Determines what the SOAPAction value should be for a given MessageContext.  
+     * 
+     * @param ctx - The MessageContext for the request
+     * @return A string with the calculated SOAPAction
+     */
+    public static String findSOAPAction(MessageContext ctx) {
+        OperationDescription op = ctx.getOperationDescription();
+        Boolean useSoapAction = (Boolean) ctx.getProperties().get(BindingProvider.SOAPACTION_USE_PROPERTY);
+        if(useSoapAction != null && useSoapAction.booleanValue()) {
+            // If SOAPAction use hasn't been disabled by the client, then first
+            // look in the context properties.
+            String action = (String) ctx.getProperties().get(BindingProvider.SOAPACTION_URI_PROPERTY);
+            if (action != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Setting soap action from JAX-WS request context.  Action [" + action + "]");
+                }
+                return action;
+            }
+            
+            // If we didn't find anything in the context props, then we need to 
+            // check the OperationDescrition to see if one was configured in the WSDL.
+            if (op != null) {
+                action = op.getAction();
+                if (action != null) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Setting soap action from operation description.  Action [" + action + "]");
+                    }
+                    return action;
+                }                
+            }
+            else {
+                if (log.isDebugEnabled()) {
+                    log.debug("Cannot set the soap action.  No operation description was found.");
+                }
+            }
+        }
+        else {
+            if (log.isDebugEnabled()) {
+                log.debug("Soap action usage was disabled");
+            }
+        }
+        
+        return null;
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=508994&r1=508993&r2=508994
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Sun Feb 18 12:55:18 2007
@@ -22,7 +22,6 @@
 import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
 import javax.xml.namespace.QName;
@@ -30,7 +29,6 @@
 import javax.xml.ws.Response;
 import javax.xml.ws.WebServiceException;
 
-import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants.Configuration;
 import org.apache.axis2.addressing.EndpointReference;
@@ -44,6 +42,7 @@
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.ClientUtils;
 import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.client.async.CallbackFuture;
 import org.apache.axis2.jaxws.client.async.PollingFuture;
@@ -77,7 +76,6 @@
 public class AxisInvocationController extends InvocationController {
     
     private static Log log = LogFactory.getLog(AxisInvocationController.class);
-    private static boolean debug = log.isDebugEnabled();
     
     /*
      * (non-Javadoc)
@@ -380,7 +378,7 @@
             options.setTo(toEPR);
             
             // Get the SOAP Action (if needed)
-            String soapAction = configureSOAPAction(requestMsgCtx);
+            String soapAction = ClientUtils.findSOAPAction(requestMsgCtx);
             options.setAction(soapAction);
             
             // Use the OperationClient to send the request and put the contents
@@ -403,52 +401,6 @@
     }
     
     /**
-     * Returns the SOAP action that should be used for the invocation.  If the
-     * client has already set the property in the JAX-WS request context, then
-     * that value should be used.  Otherwise, we should grab it from the 
-     * operation description that was configured for the operation.
-     * 
-     * @param ctx
-     * @return
-     */
-    private String configureSOAPAction(MessageContext ctx) {
-        OperationDescription op = ctx.getOperationDescription();
-        
-        Boolean useSoapAction = (Boolean) ctx.getProperties().get(BindingProvider.SOAPACTION_USE_PROPERTY);
-        if(useSoapAction != null && useSoapAction.booleanValue()){
-            String action = (String) ctx.getProperties().get(BindingProvider.SOAPACTION_URI_PROPERTY);
-            if (action != null) {
-                if (debug) {
-                    log.debug("Setting soap action from JAX-WS request context.  Action [" + action + "]");
-                }
-                return action;
-            }
-            
-            if (op != null) {
-                action = op.getAction();
-                if (action != null) {
-                    if (debug) {
-                        log.debug("Setting soap action from operation description.  Action [" + action + "]");
-                    }
-                    return action;
-                }                
-            }
-            else {
-                if (debug) {
-                    log.debug("Cannot set the soap action.  No operation description was found.");
-                }
-            }
-        }
-        else {
-            if (debug) {
-                log.debug("Soap action usage was disabled");
-            }
-        }
-        
-        return null;
-    }
-    
-    /**
      * Use the provided ServiceClient instance to create an OperationClient identified 
      * by the operation QName provided.
      * 
@@ -566,7 +518,7 @@
         // AxisOperation the OperationClient should be based on.
         // Note that the OperationDesc is only set through use of the Proxy. Dispatch
         // clients do not use operations, so the operationDesc will be null.  In this
-        // case an anonymous AxisService with anoymouns AxisOperations for the supported
+        // case an anonymous AxisService with anonymous AxisOperations for the supported
         // MEPs will be created; and it is that anonymous operation name which needs to
         // be specified
         QName operationName = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org