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 da...@apache.org on 2006/06/29 13:59:17 UTC

svn commit: r418020 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/addressing/wsdl/ core/src/org/apache/axis2/description/ core/src/org/apache/axis2/engine/ core/src/org/apache...

Author: davidillsley
Date: Thu Jun 29 04:59:14 2006
New Revision: 418020

URL: http://svn.apache.org/viewvc?rev=418020&view=rev
Log:
First part of merged patch from AXIS2-750
Supports reading wsaw:Action from WSDL or DefaultActionPattern (WSDL1.1 only) if action
not specified in other way. Support for output/fault actions in services.xml to follow shortly.

Includes new unit tests for WSDL helpers. All unit tests pass locally

Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11ActionHelper.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11DefaultActionPatternHelper.java
    webservices/axis2/trunk/java/modules/core/test-resources/wsdl/actionTests.wsdl
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/wsdl/WSDL11ActionHelperTest.java
Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=418020&r1=418019&r2=418020&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Thu Jun 29 04:59:14 2006
@@ -147,9 +147,6 @@
 
     private void processWSAAction(Options messageContextOptions, SOAPEnvelope envelope,
                                   MessageContext msgCtxt, OMNamespace addressingNamespaceObject) {
-        if (msgCtxt.isProcessingFault()) {
-            processStringInfo(Final.WSA_FAULT_ACTION, WSA_ACTION, envelope, addressingNamespaceObject);
-        }
         String action = messageContextOptions.getAction();
         if (action != null && !isAddressingHeaderAlreadyAvailable(WSA_ACTION, envelope,
                 addressingNamespaceObject)) {

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11ActionHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11ActionHelper.java?rev=418020&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11ActionHelper.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11ActionHelper.java Thu Jun 29 04:59:14 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.addressing.wsdl;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.PortType;
+import javax.wsdl.extensions.AttributeExtensible;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The WSDL11ActionHelper provides 3 static methods to determine the correct wsa:Action value from
+ * a wsdl4j Input/Output/Fault object. It first attempts to access the wsaw:Action attribute and if
+ * that is not found uses the WSDL11DefaultActionPatternHelper to generate and Action based on the
+ * Default Action Pattern for WSDL1.1 at http://www.w3.org/TR/2006/WD-ws-addr-wsdl-20060216/#defactionwsdl11
+ */
+public class WSDL11ActionHelper {
+	
+	private static final Log log = LogFactory.getLog(WSDL11ActionHelper.class);
+	
+	/**
+	 * getActionFromInputElement
+	 * @param def the wsdl:defintion which contains the wsdl:portType
+	 * @param wsdl4jPortType the wsdl:portType which contains the wsdl:operation
+	 * @param op the wsdl:operation which contains the input element
+	 * @param input the input element to be examined to generate the wsa:Action
+	 * @return either the wsaw:Action from the input element or an action genernated using the DefaultActionPattern
+	 */
+    public static String getActionFromInputElement(Definition def, PortType wsdl4jPortType, Operation op, Input input){
+        String result = getWSAWActionExtensionAttribute(input);
+        if(result == null){
+            result = WSDL11DefaultActionPatternHelper.generateActionFromInputElement(def, wsdl4jPortType, op, input);
+        }
+        log.trace(result);
+    	return result;
+    }
+    
+    /**
+	 * getActionFromOutputElement
+	 * @param def the wsdl:defintion which contains the wsdl:portType
+	 * @param wsdl4jPortType the wsdl:portType which contains the wsdl:operation
+	 * @param op the wsdl:operation which contains the output element
+	 * @param output the input element to be examined to generate the wsa:Action
+	 * @return either the wsaw:Action from the output element or an action genernated using the DefaultActionPattern
+	 */
+    public static String getActionFromOutputElement(Definition def, PortType wsdl4jPortType, Operation op, Output output){
+    	String result = getWSAWActionExtensionAttribute(output);
+    	if(result == null){
+    		result = WSDL11DefaultActionPatternHelper.generateActionFromOutputElement(def, wsdl4jPortType, op, output);
+        }
+    	log.trace(result);
+    	return result;
+    }
+    
+    /**
+	 * getActionFromFaultElement
+	 * @param def the wsdl:defintion which contains the wsdl:portType
+	 * @param wsdl4jPortType the wsdl:portType which contains the wsdl:operation
+	 * @param op the wsdl:operation which contains the fault element
+	 * @param fault the fault element to be examined to generate the wsa:Action
+	 * @return either the wsaw:Action from the fault element or an action genernated using the DefaultActionPattern
+	 */
+    public static String getActionFromFaultElement(Definition def, PortType wsdl4jPortType, Operation op, Fault fault){
+    	String result = getWSAWActionExtensionAttribute(fault);
+    	if(result == null){
+    		result = WSDL11DefaultActionPatternHelper.generateActionFromFaultElement(def, wsdl4jPortType, op, fault);
+        }
+    	log.trace(result);
+    	return result;
+    }
+
+    private static String getWSAWActionExtensionAttribute(AttributeExtensible ae){
+    	// Search first for a wsaw:Action using the submission namespace
+    	Object attribute = ae.getExtensionAttribute(new QName(AddressingConstants.Submission.WSA_NAMESPACE, AddressingConstants.WSA_ACTION));
+    	// Then if that did no exist one using the w3c namespace
+    	if(attribute ==null){
+    		attribute = ae.getExtensionAttribute(new QName(AddressingConstants.Final.WSAW_NAMESPACE, AddressingConstants.WSA_ACTION));
+        }
+    	
+    	// wsdl4j may return a String, QName or a List of either
+    	// If it is a list, extract the first element
+    	if(attribute instanceof List){
+    		List l = (List)attribute;
+    		if(l.size()>0){
+    			attribute = l.get(0);
+    		}else{
+    			attribute = null;
+    		}
+    	}
+    	
+    	// attribute must now be a QName or String or null
+    	// If it is a QName, take the LocalPart as a String
+    	if(attribute instanceof QName){
+    		QName qn = (QName)attribute;
+    		attribute = qn.getLocalPart();
+    	}
+    	
+    	if(!(attribute instanceof String)){
+    		if(log.isTraceEnabled()){
+    			log.trace("No wsaw:Action attribute found");
+    		}
+    		return null;
+    	}else{
+    		String result = (String)attribute;
+    		log.trace(result);
+    		return result;
+    	}
+    }
+}

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11DefaultActionPatternHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11DefaultActionPatternHelper.java?rev=418020&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11DefaultActionPatternHelper.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/wsdl/WSDL11DefaultActionPatternHelper.java Thu Jun 29 04:59:14 2006
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.addressing.wsdl;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.OperationType;
+import javax.wsdl.Output;
+import javax.wsdl.PortType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Generates a wsa:Action value using the Default Action Pattern defined at
+ * http://www.w3.org/TR/2006/WD-ws-addr-wsdl-20060216/#defactionwsdl11
+ */
+public class WSDL11DefaultActionPatternHelper {
+	
+	private static final Log log = LogFactory.getLog(WSDL11DefaultActionPatternHelper.class);
+	
+	// String constants used extensively in this class
+	private static final String URN = "urn";
+	private static final String SLASH = "/";
+	private static final String COLON = ":";
+	private static final String REQUEST = "Request";
+	private static final String RESPONSE = "Response";
+	private static final String SOLICIT = "Solicit";
+	private static final String FAULT = "Fault";
+	
+	/**
+	 * Generate the Action for an Input using the Default Action Pattern
+	 * 
+	 * Pattern is defined as [target namespace][delimiter][port type name][delimiter][input name]
+	 * 
+	 * @param def is required to obtain the targetNamespace
+	 * @param wsdl4jPortType is required to obtain the portType name
+	 * @param op is required to generate the input name if not explicitly specifid
+	 * @param input is required for its name if specified
+	 * @return a wsa:Action value based on the Default Action Pattern and the provided objects
+	 */
+	public static String generateActionFromInputElement(Definition def, PortType wsdl4jPortType, Operation op, Input input){
+		// Get the targetNamespace of the wsdl:definition
+		String targetNamespace = def.getTargetNamespace();
+		
+		// Determine the delimiter. Per the spec: 'is ":" when the [target namespace] is a URN, otherwise "/". 
+		// Note that for IRI schemes other than URNs which aren't path-based (i.e. those that outlaw the "/" 
+		// character), the default action value may not conform to the rules of the IRI scheme. Authors
+		// are advised to specify explicit values in the WSDL in this case.'
+    	String delimiter = SLASH;
+    	if(targetNamespace.toLowerCase().startsWith(URN)){
+    		delimiter = COLON;
+    	}
+    	
+    	// Get the portType name (as a string to be included in the action)
+    	String portTypeName = wsdl4jPortType.getQName().getLocalPart();
+    	// Get the name of the input element (and generate one if none explicitly specified)
+    	String inputName = getNameFromInputElement(op, input);
+    	
+    	// Append the bits together
+    	StringBuffer sb = new StringBuffer();
+    	sb.append(targetNamespace);
+    	// Deal with the problem that the targetNamespace may or may not have a trailing delimiter
+    	if(!targetNamespace.endsWith(delimiter)){
+    		sb.append(delimiter);
+    	}
+    	sb.append(portTypeName);
+    	sb.append(delimiter);
+    	sb.append(inputName);
+    	
+    	// Resolve the action from the StringBuffer
+    	String result = sb.toString();
+    	
+    	if(log.isTraceEnabled()){
+    		log.trace("generateActionFromInputElement result: "+result);
+    	}
+    	
+    	return result;
+    }
+    
+	/**
+	 * Get the name of the specified Input element using the rules defined in WSDL 1.1
+	 * Section 2.4.5 http://www.w3.org/TR/wsdl#_names
+	 */
+    private static String getNameFromInputElement(Operation op, Input input) {
+    	// Get the name from the input element if specified.
+		String result = input.getName();
+		
+		// If not we'll have to generate it.
+		if (result == null) {
+			// If Request-Response or Solicit-Response do something special per
+			// WSDL 1.1 Section 2.4.5
+			OperationType operationType = op.getStyle();
+			if (null != operationType) {
+				if (operationType.equals(OperationType.REQUEST_RESPONSE)){
+					result = op.getName() + REQUEST;
+				}else if (operationType.equals(OperationType.SOLICIT_RESPONSE)){
+					result = op.getName() + RESPONSE;
+				}
+			}
+			// If the OperationType was not available for some reason, assume on-way or notification
+			if(result == null){
+				result = op.getName();
+			}
+		}
+		return result;
+	}
+    
+	/**
+	 * Generate the Action for an Output using the Default Action Pattern
+	 * 
+	 * Pattern is defined as [target namespace][delimiter][port type name][delimiter][output name]
+	 * 
+	 * @param def is required to obtain the targetNamespace
+	 * @param wsdl4jPortType is required to obtain the portType name
+	 * @param op is required to generate the output name if not explicitly specifid
+	 * @param output is required for its name if specified
+	 * @return a wsa:Action value based on the Default Action Pattern and the provided objects
+	 */
+    public static String generateActionFromOutputElement(Definition def, PortType wsdl4jPortType, Operation op, Output output){
+    	// Get the targetNamespace of the wsdl:definition
+		String targetNamespace = def.getTargetNamespace();
+		
+		// Determine the delimiter. Per the spec: 'is ":" when the [target namespace] is a URN, otherwise "/". 
+		// Note that for IRI schemes other than URNs which aren't path-based (i.e. those that outlaw the "/" 
+		// character), the default action value may not conform to the rules of the IRI scheme. Authors
+		// are advised to specify explicit values in the WSDL in this case.'
+    	String delimiter = SLASH;
+    	if(targetNamespace.toLowerCase().startsWith(URN)){
+    		delimiter = COLON;
+    	}
+    	
+    	// Get the portType name (as a string to be included in the action)
+    	String portTypeName = wsdl4jPortType.getQName().getLocalPart();
+    	// Get the name of the output element (and generate one if none explicitly specified)
+    	String outputName = getNameFromOutputElement(op, output);
+    	
+    	// Append the bits together
+    	StringBuffer sb = new StringBuffer();
+    	sb.append(targetNamespace);
+    	// Deal with the problem that the targetNamespace may or may not have a trailing delimiter
+    	if(!targetNamespace.endsWith(delimiter)){
+    		sb.append(delimiter);
+    	}
+    	sb.append(portTypeName);
+    	sb.append(delimiter);
+    	sb.append(outputName);
+    	
+    	// Resolve the action from the StringBuffer
+    	String result = sb.toString();
+    	
+    	if(log.isTraceEnabled()){
+    		log.trace("generateActionFromOutputElement result: "+result);
+    	}
+    	
+    	return result;
+    }
+    
+	/**
+	 * Get the name of the specified Output element using the rules defined in WSDL 1.1
+	 * Section 2.4.5 http://www.w3.org/TR/wsdl#_names
+	 */
+    private static String getNameFromOutputElement(Operation op, Output output) {
+    	// Get the name from the output element if specified.
+		String result = output.getName();
+		
+		// If not we'll have to generate it.
+		if (result == null) {
+			// If Request-Response or Solicit-Response do something special per
+			// WSDL 1.1 Section 2.4.5
+			OperationType operationType = op.getStyle();
+			if (null != operationType) {
+				if (operationType.equals(OperationType.REQUEST_RESPONSE)){
+					return op.getName() + RESPONSE;
+				}else if (operationType.equals(OperationType.SOLICIT_RESPONSE)){
+					return op.getName() + SOLICIT;
+				}
+			}
+			// If the OperationType was not available for some reason, assume on-way or notification
+			if(result == null){
+				result = op.getName();
+			}
+		}
+		return result;
+	}
+    
+    /**
+	 * Generate the Action for a Fault using the Default Action Pattern
+	 * 
+	 * Pattern is defined as [target namespace][delimiter][port type name][delimiter][operation name][delimiter]Fault[delimiter][fault name]
+	 * 
+	 * @param def is required to obtain the targetNamespace
+	 * @param wsdl4jPortType is required to obtain the portType name
+	 * @param op is required to obtain the operation name
+	 * @param fault is required to obtain the fault name
+	 * @return a wsa:Action value based on the Default Action Pattern and the provided objects
+	 */
+    public static String generateActionFromFaultElement(Definition def, PortType wsdl4jPortType, Operation op, Fault fault){
+        // Get the targetNamespace of the wsdl:definition
+        String targetNamespace = def.getTargetNamespace();
+
+        // Determine the delimiter. Per the spec: 'is ":" when the [target namespace] is a URN, otherwise "/". 
+        // Note that for IRI schemes other than URNs which aren't path-based (i.e. those that outlaw the "/" 
+        // character), the default action value may not conform to the rules of the IRI scheme. Authors
+        // are advised to specify explicit values in the WSDL in this case.'
+        String delimiter = SLASH;
+        if(targetNamespace.toLowerCase().startsWith(URN)){
+            delimiter = COLON;
+        }
+    	
+        // Get the portType name (as a string to be included in the action)
+        String portTypeName = wsdl4jPortType.getQName().getLocalPart();
+        // Get the operation name (as a string to be included in the action)
+        String operationName = op.getName();
+        
+        // Get the name of the fault element (name is mandatory on fault elements)
+        String faultName = fault.getName();
+    	
+        // Append the bits together
+        StringBuffer sb = new StringBuffer();
+        sb.append(targetNamespace);
+        // Deal with the problem that the targetNamespace may or may not have a trailing delimiter
+        if(!targetNamespace.endsWith(delimiter)){
+            sb.append(delimiter);
+        }
+        sb.append(portTypeName);
+        sb.append(delimiter);
+        sb.append(operationName);
+        sb.append(delimiter);
+        sb.append(FAULT);
+        sb.append(delimiter);
+        sb.append(faultName);
+    	
+        // Resolve the action from the StringBuffer
+        String result = sb.toString();
+    	
+        if(log.isTraceEnabled()){
+            log.trace("generateActionFromFaultElement result: "+result);
+        }
+    	
+        return result;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java?rev=418020&r1=418019&r2=418020&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java Thu Jun 29 04:59:14 2006
@@ -38,6 +38,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Set;
 
 public abstract class AxisOperation extends AxisDescription
         implements WSDLConstants {
@@ -70,6 +71,8 @@
     private QName name;
 
     private ArrayList wsamappingList;
+    private String outputAction;
+    private HashMap faultActions = new HashMap();
 
     private String soapAction;
 
@@ -266,6 +269,11 @@
         }
 
         operation.setWsamappingList(axisOperation.getWsamappingList());
+        operation.setOutputAction(axisOperation.getOutputAction());
+        String[] faultActionNames = axisOperation.getFaultActionNames();
+        for(int i=0;i<faultActionNames.length;i++){
+            operation.addFaultAction(faultActionNames[i],axisOperation.getFaultAction(faultActionNames[i]));
+        }
         operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
         operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
         operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
@@ -544,6 +552,42 @@
         this.soapAction = soapAction;
     }
 
+    public String getOutputAction() {
+        return outputAction;
+    }
+
+    public void setOutputAction(String act) {
+        outputAction = act;
+    }
+
+    public void addFaultAction(String faultName, String action) {
+        faultActions.put(faultName, action);
+    }
+
+    public void removeFaultAction(String faultName) {
+        faultActions.remove(faultName);
+    }
+
+    public String getFaultAction(String faultName) {
+        return (String) faultActions.get(faultName);
+    }
+
+    public String[] getFaultActionNames() {
+        Set keys = faultActions.keySet();
+        String[] faultActionNames = new String[keys.size()];
+        faultActionNames = (String[]) keys.toArray(faultActionNames);
+        return faultActionNames;
+    }
+
+    public String getFaultAction() {
+        String result = null;
+        Iterator iter = faultActions.values().iterator();
+        if (iter.hasNext()) {
+            result = (String) iter.next();
+        }
+        return result;
+    }
+    
     public boolean isEngaged(QName moduleName) {
         Iterator engagedModuleItr = engagedModules.iterator();
         while (engagedModuleItr.hasNext()) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=418020&r1=418019&r2=418020&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Thu Jun 29 04:59:14 2006
@@ -407,6 +407,12 @@
         operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
         operation.setPhasesOutFlow(axisOperation.getPhasesOutFlow());
 
+        operation.setOutputAction(axisOperation.getOutputAction());
+        String[] faultActionNames = axisOperation.getFaultActionNames();
+        for(int i=0;i<faultActionNames.length;i++){
+           operation.addFaultAction(faultActionNames[i],axisOperation.getFaultAction(faultActionNames[i]));
+        }
+        
         return operation;
     }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=418020&r1=418019&r2=418020&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java Thu Jun 29 04:59:14 2006
@@ -37,6 +37,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
@@ -199,11 +200,20 @@
         }
 
         faultContext.setProcessingFault(true);
-
+        // Add correct Action
+        AxisOperation op = processingContext.getAxisOperation();
+        if(op != null && op.getFaultAction()!=null){
+            faultContext.setWSAAction(processingContext.getAxisOperation().getFaultAction());
+        }else{ //If, for some reason there is no value set, should use a sensible action.
+            faultContext.setWSAAction(Final.WSA_FAULT_ACTION);
+        }
+                
         // there are some information  that the fault thrower wants to pass to the fault path.
+        // Means that the fault is a ws-addressing one hence use the ws-addressing fault action.
         Object faultInfoForHeaders = processingContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
         if (faultInfoForHeaders != null) {
             faultContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInfoForHeaders);
+            faultContext.setWSAAction(Final.WSA_FAULT_ACTION);
         }
 
         // if the exception is due to a problem in the faultTo header itself, we can not use those

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=418020&r1=418019&r2=418020&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Thu Jun 29 04:59:14 2006
@@ -85,7 +85,14 @@
                 new RelatesTo(
                         oldOptions.getMessageId(),
                         AddressingConstants.Final.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
-        newmsgCtx.setWSAAction(oldOptions.getAction());
+                
+        AxisOperation ao = inMessageContext.getAxisOperation();
+        if(ao!=null && ao.getOutputAction()!=null){
+           newmsgCtx.setWSAAction(ao.getOutputAction());
+        }else{
+           newmsgCtx.setWSAAction(oldOptions.getAction());
+        }
+        
         newmsgCtx.setOperationContext(inMessageContext.getOperationContext());
         newmsgCtx.setServiceContext(inMessageContext.getServiceContext());
         newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,

Added: webservices/axis2/trunk/java/modules/core/test-resources/wsdl/actionTests.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/test-resources/wsdl/actionTests.wsdl?rev=418020&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/wsdl/actionTests.wsdl (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/wsdl/actionTests.wsdl Thu Jun 29 04:59:14 2006
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:tns="http://ws.apache.org/axis2/actiontest/"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="actionTests"
+	xmlns:wsaw="http://www.w3.org/2005/08/addressing/wsdl"
+	targetNamespace="http://ws.apache.org/axis2/actiontest/">
+	<wsdl:types>
+	</wsdl:types>
+	<wsdl:message name="echoResponse">
+		<wsdl:part name="echoResponse" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoRequest">
+		<wsdl:part name="echoRequest" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoResponse1">
+		<wsdl:part name="echoResponse1" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoRequest1">
+		<wsdl:part name="echoRequest1" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoechoFault">
+		<wsdl:part name="echoechoFault" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoechoFault1">
+		<wsdl:part name="echoechoFault1" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoResponse2">
+		<wsdl:part name="echoResponse2" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoRequest2">
+		<wsdl:part name="echoRequest2" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoechoFault2">
+		<wsdl:part name="echoechoFault2" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoResponse3">
+		<wsdl:part name="echoResponse3" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoRequest3">
+		<wsdl:part name="echoRequest3" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:message name="echoechoFault3">
+		<wsdl:part name="echoechoFault3" type="xsd:string"></wsdl:part>
+	</wsdl:message>
+	<wsdl:portType name="withoutWSAWAction">
+		<wsdl:operation name="echo">
+			<wsdl:input message="tns:echoRequest" name="NamedInput"></wsdl:input>
+			<wsdl:output message="tns:echoResponse" name="NamedOutput"></wsdl:output>
+			<wsdl:fault name="echoFault" message="tns:echoechoFault"></wsdl:fault>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:portType name="withWSAWAction">
+		<wsdl:operation name="echo">
+			<wsdl:input message="tns:echoRequest1" wsaw:Action="http://example.org/action/echoIn"></wsdl:input>
+			<wsdl:output message="tns:echoResponse1" wsaw:Action="http://example.org/action/echoOut"></wsdl:output>
+			<wsdl:fault name="echoFault" message="tns:echoechoFault1" wsaw:Action="http://example.org/action/echoFault"></wsdl:fault>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:portType name="withoutWSAWActionNoName">
+		<wsdl:operation name="echo">
+			<wsdl:input message="tns:echoRequest2"></wsdl:input>
+			<wsdl:output message="tns:echoResponse2"></wsdl:output>
+			<wsdl:fault name="echoFault" message="tns:echoechoFault2"></wsdl:fault>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:portType name="withSOAPAction">
+		<wsdl:operation name="echo">
+			<wsdl:input message="tns:echoRequest3"></wsdl:input>
+			<wsdl:output message="tns:echoResponse3"></wsdl:output>
+			<wsdl:fault name="echoFault" message="tns:echoechoFault3"></wsdl:fault>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:binding name="withoutWSAWActionBinding"
+		type="tns:withoutWSAWAction">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="echo">
+			<soap:operation
+				soapAction="" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+			<wsdl:fault name="echoFault">
+				<soap:fault name="echoFault" use="literal" />
+			</wsdl:fault>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:binding name="withWSAWActionBinding"
+		type="tns:withWSAWAction">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="echo">
+			<soap:operation
+				soapAction="" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+			<wsdl:fault name="echoFault">
+				<soap:fault name="echoFault" use="literal" />
+			</wsdl:fault>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:binding name="withoutWSAWActionNoNameBinding"
+		type="tns:withoutWSAWActionNoName">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="echo">
+			<soap:operation
+				soapAction="" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+			<wsdl:fault name="echoFault">
+				<soap:fault name="echoFault" use="literal" />
+			</wsdl:fault>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:binding name="withSOAPActionBinding"
+		type="tns:withSOAPAction">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="echo">
+			<soap:operation
+				soapAction="http://ws.apache.org/axis2/actiontest/echo" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+			<wsdl:fault name="echoFault">
+				<soap:fault name="echoFault" use="literal" />
+			</wsdl:fault>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="actionTests">
+		<wsdl:port binding="tns:actionTestsWithWSAWActionSOAP"
+			name="actionTestsSOAP">
+			<soap:address location="http://tempuri.org" />
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>

Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/wsdl/WSDL11ActionHelperTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/wsdl/WSDL11ActionHelperTest.java?rev=418020&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/wsdl/WSDL11ActionHelperTest.java (added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/wsdl/WSDL11ActionHelperTest.java Thu Jun 29 04:59:14 2006
@@ -0,0 +1,120 @@
+package org.apache.axis2.addressing.wsdl;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+public class WSDL11ActionHelperTest extends TestCase {
+
+	String testWSDLFile = "wsdl/actionTests.wsdl";
+	
+	Definition definition;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+
+        reader.setFeature("javax.wsdl.importDocuments", false);
+        reader.setFeature("javax.wsdl.verbose", false);
+
+        URL wsdlFile = getClass().getClassLoader().getResource(testWSDLFile);
+        definition =  reader.readWSDL(wsdlFile.toString());
+	}
+
+
+	 // Test DefaultActionPattern (no names in WSDL)
+	 // Test not required for Fault as Fault elements MUST have naes per the WSDL 1.1 spec
+	 //	portType=withoutWSAWActionNoName
+	 // operation=echo
+	 public void testGenerateInputActionNoNames(){
+		 String expectedAction = "http://ws.apache.org/axis2/actiontest/withoutWSAWActionNoName/echoRequest";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withoutWSAWActionNoName"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Input in = op.getInput();
+		 String actualAction = WSDL11ActionHelper.getActionFromInputElement(definition,pt,op,in);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	 public void testGenerateOutputActionNoNames(){
+		 String expectedAction = "http://ws.apache.org/axis2/actiontest/withoutWSAWActionNoName/echoResponse";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withoutWSAWActionNoName"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Output out = op.getOutput();
+		 String actualAction = WSDL11ActionHelper.getActionFromOutputElement(definition,pt,op,out);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	
+	 // Test DefaultActionPattern (names explicitly set in WSDL)
+	 //	portType=withoutWSAWAction
+	 // operation=echo
+	 public void testGenerateInputAction(){
+		 String expectedAction = "http://ws.apache.org/axis2/actiontest/withoutWSAWAction/NamedInput";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withoutWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Input in = op.getInput();
+		 String actualAction = WSDL11ActionHelper.getActionFromInputElement(definition,pt,op,in);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	 public void testGenerateOutputAction(){
+		 String expectedAction = "http://ws.apache.org/axis2/actiontest/withoutWSAWAction/NamedOutput";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withoutWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Output out = op.getOutput();
+		 String actualAction = WSDL11ActionHelper.getActionFromOutputElement(definition,pt,op,out);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	 public void testGenerateFaultAction(){
+		 String expectedAction = "http://ws.apache.org/axis2/actiontest/withoutWSAWAction/echo/Fault/echoFault";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withoutWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Fault fault = op.getFault("echoFault");
+		 String actualAction = WSDL11ActionHelper.getActionFromFaultElement(definition,pt,op,fault);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	
+	 // Test reading wsaw:Action values
+	 // portType=withWSAWAction
+	 // operation=echo
+	 public void testGetWSAWInputAction(){
+		 String expectedAction = "http://example.org/action/echoIn";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Input in = op.getInput();
+		 String actualAction = WSDL11ActionHelper.getActionFromInputElement(definition,pt,op,in);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	 public void testGetWSAWOutputAction(){
+		 String expectedAction = "http://example.org/action/echoOut";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Output out = op.getOutput();
+		 String actualAction = WSDL11ActionHelper.getActionFromOutputElement(definition,pt,op,out);
+		 assertEquals(expectedAction, actualAction);
+	 }
+	 public void testGetWSAWFaultAction(){
+		 String expectedAction = "http://example.org/action/echoFault";
+		 PortType pt = definition.getPortType(new QName("http://ws.apache.org/axis2/actiontest/","withWSAWAction"));
+		 List operations = pt.getOperations();
+		 Operation op = (Operation)operations.get(0);
+		 Fault fault = op.getFault("echoFault");
+		 String actualAction = WSDL11ActionHelper.getActionFromFaultElement(definition,pt,op,fault);
+		 assertEquals(expectedAction, actualAction);
+	 }
+}



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