axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
Subject svn commit: r449748 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/addressing/ addressing/src/org/apache/axis2/handlers/addressing/ addressing/test/org/apache/axis2/addressing/ kernel/src/org/apache/axis2/addressing/ kernel...
Date Mon, 25 Sep 2006 17:23:23 GMT
Author: pradine
Date: Mon Sep 25 10:23:22 2006
New Revision: 449748

URL: http://svn.apache.org/viewvc?view=rev&rev=449748
Log:
Improve fault generation when WS-Addressing Submission spec is in effect.

Added:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
Removed:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java
Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java

Added: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java?view=auto&rev=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
(added)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
Mon Sep 25 10:23:22 2006
@@ -0,0 +1,170 @@
+/**
+ * 
+ */
+package org.apache.axis2.addressing;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.soap.SOAPFaultValue;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AddressingFaultsHelper{
+    
+    private static final Log log = LogFactory.getLog(AddressingFaultsHelper.class);
+    
+    //    wsa:InvalidAddressingHeader [Reason] the string: "A header representing a Message
Addressing Property is not valid and the message cannot be processed"
+    //      wsa:InvalidAddress
+    //      wsa:InvalidEPR
+    //      wsa:InvalidCardinality
+    public static void triggerInvalidCardinalityFault(MessageContext messageContext, String
incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerInvalidCardinalityFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
null, Submission.FAULT_INVALID_HEADER_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
"InvalidCardinality", Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:MissingAddressInEPR
+    public static void triggerMissingAddressInEPRFault(MessageContext messageContext, String
incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerMissingAddressInEPRFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
null, Submission.FAULT_INVALID_HEADER_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
"MissingAddressInEPR", Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:DuplicateMessageID
+    //      wsa:ActionMismatch
+    public static void triggerActionMismatchFault(MessageContext messageContext) throws AxisFault
{
+        if(log.isDebugEnabled()){
+            log.debug("triggerActionMismatchFault: messageContext: "+messageContext);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":Action", Submission.FAULT_INVALID_HEADER, null,
Submission.FAULT_INVALID_HEADER_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":Action", Final.FAULT_INVALID_HEADER, "ActionMismatch",
Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:OnlyAnonymousAddressSupported
+    public static void triggerOnlyAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerOnlyAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
null, Submission.FAULT_INVALID_HEADER_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:OnlyNonAnonymousAddressSupported
+    public static void triggerOnlyNonAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerOnlyNonAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
null, Submission.FAULT_INVALID_HEADER_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //    wsa:MessageAddressingHeaderRequired [Reason] the string: "A required header representing
a Message Addressing Property is not present"
+    public static void triggerMessageAddressingRequiredFault(MessageContext messageContext,
String missingHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerMessageAddressingRequiredFault: messageContext: "+messageContext+"
missingHeaderName: "+missingHeaderName);
+        }
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace))
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + missingHeaderName, Submission.FAULT_ADDRESSING_HEADER_REQUIRED,
null, Submission.FAULT_ADDRESSING_HEADER_REQUIRED_REASON);
+        else
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + missingHeaderName, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null, Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON);
+    }
+
+    //    wsa:ActionNotSupported [Reason] the string: "The [action] cannot be processed at
the receiver"
+    public static void triggerActionNotSupportedFault(MessageContext messageContext, String
problemAction) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerActionNotSupportedFault: messageContext: "+messageContext+"
problemAction: "+problemAction);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_PROBLEM_ACTION_NAME, problemAction,
AddressingConstants.FAULT_ACTION_NOT_SUPPORTED, null, AddressingConstants.FAULT_ACTION_NOT_SUPPORTED_REASON);
+    }
+
+    //    wsa:EndpointUnavailable [Reason] the string "The endpoint is unable to process
the message at this time"
+
+    private static void triggerAddressingFault(MessageContext messageContext, String faultInformationKey,
Object faultInformationValue, String faultcode, String faultSubcode, String faultReason) throws
AxisFault{
+        Map faultInformation = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+        if (faultInformation == null) {
+            faultInformation = new HashMap();
+            messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
+        }
+
+        faultInformation.put(faultInformationKey, faultInformationValue);
+
+        if (!messageContext.isSOAP11()) {
+            setFaultCode(messageContext, faultcode, faultSubcode);
+        }
+
+        messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
+        String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        AxisFault fault = new AxisFault(faultReason, new QName(namespace, faultcode, AddressingConstants.WSA_DEFAULT_PREFIX));
+        throw fault;
+    }
+
+    private static void setFaultCode(MessageContext messageContext, String faultCode, String
faultSubCode) {
+        SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
+        SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
+        SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
+        soapFaultValue.setText(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" + SOAP12Constants.FAULT_CODE_SENDER);
+        SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
+        SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
+        soapFaultSubcodeValue.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" + faultCode);
+        if (faultSubCode != null) {
+            SOAPFaultSubCode soapFaultSubCode2 = soapFac.createSOAPFaultSubCode(soapFaultSubCode);
+            SOAPFaultValue soapFaultSubcodeValue2 = soapFac.createSOAPFaultValue(soapFaultSubCode2);
+            soapFaultSubcodeValue2.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
faultSubCode);
+        }
+        messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
+    }
+    
+    public static OMElement getDetailElementForAddressingFault(MessageContext messageContext,
OMNamespace addressingNamespaceObject){
+        Map faultInfo = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+        OMElement problemDetail = null;
+        if (faultInfo != null) {
+            String faultyHeaderQName = (String) faultInfo.get(Final.FAULT_HEADER_PROB_HEADER_QNAME);
+            String faultyAction = (String) faultInfo.get(Final.FAULT_PROBLEM_ACTION_NAME);
+            if(faultyAction!=null && !"".equals(faultyAction)){
+                problemDetail = messageContext.getEnvelope().getOMFactory().createOMElement(Final.FAULT_PROBLEM_ACTION_NAME,
addressingNamespaceObject);
+                OMElement probH2 = messageContext.getEnvelope().getOMFactory().createOMElement(AddressingConstants.WSA_ACTION,
addressingNamespaceObject,problemDetail);
+                probH2.setText(faultyAction);
+            }
+            if (faultyHeaderQName != null && !"".equals(faultyHeaderQName)) {
+                problemDetail = messageContext.getEnvelope().getOMFactory().createOMElement(Final.FAULT_HEADER_PROB_HEADER_QNAME,
addressingNamespaceObject);
+                problemDetail.setText(faultyHeaderQName);
+            }
+        }
+        return problemDetail;
+    }
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
Mon Sep 25 10:23:22 2006
@@ -5,7 +5,7 @@
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.FinalFaultsHelper;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
@@ -57,7 +57,7 @@
 
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
+            AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
WSA_ACTION);
         } 
     }
     

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
Mon Sep 25 10:23:22 2006
@@ -24,7 +24,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.EndpointReferenceHelper;
-import org.apache.axis2.addressing.FinalFaultsHelper;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
@@ -165,7 +165,7 @@
         // This means that if for example there are multiple MessageIDs and a FaultTo, the
FaultTo will be respected.
         if(!duplicateHeaderNames.isEmpty()){
         	// Simply choose the first problem header we came across as we can only fault for
one of them.
-            FinalFaultsHelper.triggerInvalidCardinalityFault(messageContext, (String)duplicateHeaderNames.get(0));
+            AddressingFaultsHelper.triggerInvalidCardinalityFault(messageContext, (String)duplicateHeaderNames.get(0));
         }
         
         // check for the presence of madatory addressing headers
@@ -272,7 +272,7 @@
         
         if (soapAction != null && !"".equals(soapAction)) {
             if (!soapAction.equals(soapHeaderBlock.getText())) {
-                FinalFaultsHelper.triggerActionMismatchFault(messageContext);
+                AddressingFaultsHelper.triggerActionMismatchFault(messageContext);
             }
         }
         else {
@@ -294,7 +294,7 @@
             EndpointReferenceHelper.fromOM(epr, headerBlock, addressingNamespace);
         }
         catch (AxisFault af) {
-            FinalFaultsHelper.triggerMissingAddressInEPRFault(messageContext, headerBlock.getLocalName());
+            AddressingFaultsHelper.triggerMissingAddressInEPRFault(messageContext, headerBlock.getLocalName());
         }
     }
 }

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?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- 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
Mon Sep 25 10:23:22 2006
@@ -28,10 +28,11 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.EndpointReferenceHelper;
-import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
@@ -120,6 +121,11 @@
                 action = msgCtxt.getAxisOperation().getOutputAction();
             }
         }
+        if (Final.WSA_SOAP_FAULT_ACTION.equals(action) || Final.WSA_FAULT_ACTION.equals(action))
{
+            if (Submission.WSA_NAMESPACE.equals(addressingNamespaceObject.getNamespaceURI()))
{
+                action = Submission.WSA_FAULT_ACTION;
+            }
+        }
         if (action != null && !isAddressingHeaderAlreadyAvailable(WSA_ACTION, envelope,
                 addressingNamespaceObject, replaceHeaders)) {
             processStringInfo(action, WSA_ACTION, envelope, addressingNamespaceObject);
@@ -127,13 +133,14 @@
     }
 
     private void processFaultsInfoIfPresent(SOAPEnvelope envelope, MessageContext msgContext,
OMNamespace addressingNamespaceObject, boolean replaceHeaders) {
-        OMElement detailElement = FinalFaultsHelper.getDetailElementForAddressingFault(msgContext,
addressingNamespaceObject);
+        OMElement detailElement = AddressingFaultsHelper.getDetailElementForAddressingFault(msgContext,
addressingNamespaceObject);
         if(detailElement != null){
-            if(msgContext.isSOAP11()){ // This difference is explained in the WS-Addressing
SOAP Binding Spec.
+            if(msgContext.isSOAP11() && Final.WSA_NAMESPACE.equals(addressingNamespaceObject.getNamespaceURI())){
// This difference is explained in the WS-Addressing SOAP Binding Spec.
                 // Add detail as a wsa:FaultDetail header
                 SOAPHeaderBlock faultDetail = envelope.getHeader().addHeaderBlock(Final.FAULT_HEADER_DETAIL,
addressingNamespaceObject);
                 faultDetail.addChild(detailElement);
-            }else{
+            }
+            else if (!msgContext.isSOAP11()) {
                 // Add detail to the Fault in the SOAP Body
                 SOAPFault fault = envelope.getBody().getFault();
                 if (fault != null && fault.getDetail() != null) {

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
Mon Sep 25 10:23:22 2006
@@ -2,8 +2,8 @@
 
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
@@ -50,18 +50,18 @@
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_TO)) {
             // Should write a new SubmissionFaults class but for the moment use the FinalFaults
-            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_TO);
+            AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
WSA_TO);
         }
         
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
+            AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
WSA_ACTION);
         }
         
         if (alreadyFoundAddrHeader.contains(WSA_REPLY_TO) ||
             alreadyFoundAddrHeader.contains(WSA_FAULT_TO)) {
             
             if (!alreadyFoundAddrHeader.contains(WSA_MESSAGE_ID)) {
-                FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_MESSAGE_ID);
+                AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
WSA_MESSAGE_ID);
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
Mon Sep 25 10:23:22 2006
@@ -19,7 +19,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.AddressingHelper;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.FinalFaultsHelper;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.handlers.AbstractHandler;
 import org.apache.axis2.util.JavaUtils;
@@ -58,7 +58,7 @@
             if (log.isTraceEnabled())
                 log.trace("checkUsingAddressing: WS_ADDRESSING_VERSION=" + flag);
             if (JavaUtils.isFalseExplicitly(flag)) {
-                FinalFaultsHelper.triggerMessageAddressingRequiredFault(msgContext,AddressingConstants.WSA_ACTION);
+                AddressingFaultsHelper.triggerMessageAddressingRequiredFault(msgContext,AddressingConstants.WSA_ACTION);
             }
         }
     }
@@ -76,20 +76,20 @@
                 EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
                 msgContext.setReplyTo(anonEPR);
                 msgContext.setFaultTo(anonEPR);
-                FinalFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
+                AddressingFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_REPLY_TO);
             }
             if(AddressingHelper.isFaultRedirected(msgContext)){
                 EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
                 msgContext.setReplyTo(anonEPR);
                 msgContext.setFaultTo(anonEPR);
-                FinalFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
+                AddressingFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_FAULT_TO);
             }
         }else if("prohibited".equals(anonymous)){
             if(!AddressingHelper.isReplyRedirected(msgContext)){
-                FinalFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_REPLY_TO);
+                AddressingFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_REPLY_TO);
             }
             if(!AddressingHelper.isFaultRedirected(msgContext)){
-                FinalFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_FAULT_TO);
+                AddressingFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_FAULT_TO);
             }
         }
     }
@@ -102,7 +102,7 @@
     private void checkAction(MessageContext msgContext) throws AxisFault{
         if(msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION)!=null){
             if((msgContext.getAxisService() == null) || (msgContext.getAxisOperation() ==
null)){
-                FinalFaultsHelper.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
+                AddressingFaultsHelper.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
             }
         }
     }

Added: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java?view=auto&rev=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
(added)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
Mon Sep 25 10:23:22 2006
@@ -0,0 +1,139 @@
+/*
+* 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;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.context.MessageContext;
+
+import junit.framework.TestCase;
+
+public class AddressingFaultsTest extends TestCase {
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerInvalidCardinalityFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerInvalidCardinalityFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerInvalidCardinalityFault(messageContext, "Action");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_INVALID_HEADER), af.getFaultCode());
+            assertEquals("wsa:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerActionMismatchFault(org.apache.axis2.context.MessageContext)}.
+     */
+    public void testTriggerActionMismatchFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerActionMismatchFault(messageContext);
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_INVALID_HEADER), af.getFaultCode());
+            assertEquals("wsa:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerOnlyAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerOnlyAnonymousAddressSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(messageContext,
"ReplyTo");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_INVALID_HEADER), af.getFaultCode());
+            assertEquals("wsa:ReplyTo", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerOnlyNonAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerOnlyNonAnonymousAddressSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(messageContext,
"ReplyTo");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_INVALID_HEADER), af.getFaultCode());
+            assertEquals("wsa:ReplyTo", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerMessageAddressingRequiredFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerMessageAddressingRequiredFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
"Action");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_ADDRESSING_HEADER_REQUIRED),
af.getFaultCode());
+            assertEquals("wsa:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingFaultsHelper#triggerActionNotSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerActionNotSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Final.WSA_NAMESPACE);
+        try{
+            AddressingFaultsHelper.triggerActionNotSupportedFault(messageContext, "http://incorrect/action");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(AddressingConstants.FAULT_ACTION_NOT_SUPPORTED_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,AddressingConstants.FAULT_ACTION_NOT_SUPPORTED),
af.getFaultCode());
+            assertEquals("http://incorrect/action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
Mon Sep 25 10:23:22 2006
@@ -71,6 +71,10 @@
 
     public static final String WSAW_ANONYMOUS_PARAMETER_NAME = "wsawAnonymous";
     
+    // ======================== Common Faults ==============================
+    public static final String FAULT_ACTION_NOT_SUPPORTED = "ActionNotSupported";
+    public static final String FAULT_ACTION_NOT_SUPPORTED_REASON = "The [action] cannot be
processed at the receiver.";
+
     public interface Final {
 
         // ====================== Addressing 1.0 Final Version Constants ====================
@@ -85,7 +89,10 @@
                 "http://www.w3.org/2005/08/addressing/anonymous";
         public static final String WSA_NONE_URI =
                 "http://www.w3.org/2005/08/addressing/none";
-        public static final String WSA_FAULT_ACTION = "http://www.w3.org/2005/08/addressing/fault";
+        public static final String WSA_FAULT_ACTION =
+                "http://www.w3.org/2005/08/addressing/fault";
+        public static final String WSA_SOAP_FAULT_ACTION =
+                "http://www.w3.org/2005/08/addressing/soap/fault";
         public static final String WSA_TYPE_ATTRIBUTE_VALUE = "true";
         public static final String WSA_SERVICE_NAME_ENDPOINT_NAME = "EndpointName";
         public static final String WSA_POLICIES = "Policies";
@@ -106,8 +113,6 @@
         public static final String FAULT_INVALID_CARDINALITY = "InvalidCardinality";
         public static final String FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED = "OnlyAnonymousAddressSupported";
         public static final String FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED = "OnlyNonAnonymousAddressSupported";
-        public static final String FAULT_ACTION_NOT_SUPPORTED = "ActionNotSupported";
-        public static final String FAULT_ACTION_NOT_SUPPORTED_REASON = "The [action] cannot
be processed at the receiver.";
         public static final String FAULT_PROBLEM_ACTION_NAME = "ProblemAction";
 
         public static final QName WSAW_USING_ADDRESSING = new QName(WSAW_NAMESPACE,USING_ADDRESSING);
@@ -125,7 +130,15 @@
                 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
 
         public static final String EPR_REFERENCE_PROPERTIES = "ReferenceProperties";
+        public static final String WSA_FAULT_ACTION =
+                "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
         
+        // fault information
+        public static final String FAULT_INVALID_HEADER = "InvalidMessageInformationHeader";
+        public static final String FAULT_INVALID_HEADER_REASON = "A message information header
is not valid and the message cannot be processed. The validity failure can be either structural
or semantic, e.g. a [destination] that is not a URI or a [relationship] to a [message id]
that was never issued.";
+        public static final String FAULT_ADDRESSING_HEADER_REQUIRED = "MessageInformationHeaderRequired";
+        public static final String FAULT_ADDRESSING_HEADER_REQUIRED_REASON = "A required
message information header, To, MessageID, or Action, is not present.";
+
         public static final QName WSAW_USING_ADDRESSING = new QName(WSA_NAMESPACE,USING_ADDRESSING);
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?view=diff&rev=449748&r1=449747&r2=449748
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
Mon Sep 25 10:23:22 2006
@@ -166,13 +166,18 @@
             faultContext.setServiceContext(serviceContext);
         }
 
+        faultContext.setOperationContext(processingContext.getOperationContext());
         faultContext.setProcessingFault(true);
+        faultContext.setServerSide(true);
+        faultContext.setDoingREST(processingContext.isDoingREST());
+
         // 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);
+        }
+        else{ //If, for some reason there is no value set, should use a sensible action.
+            faultContext.setWSAAction(Final.WSA_SOAP_FAULT_ACTION);
         }
                 
         // there are some information  that the fault thrower wants to pass to the fault
path.
@@ -227,11 +232,6 @@
         } catch (URISyntaxException urise) {
             throw new AxisFault(urise);
         }
-
-        faultContext.setOperationContext(processingContext.getOperationContext());
-        faultContext.setProcessingFault(true);
-        faultContext.setServerSide(true);
-        faultContext.setDoingREST(processingContext.isDoingREST());
 
         SOAPEnvelope envelope;
 



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


Mime
View raw message