ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r382449 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java core/src/org/apache/axis2/addressing/AddressingConstants.java
Date Thu, 02 Mar 2006 17:16:24 GMT
Author: chinthaka
Date: Thu Mar  2 09:16:23 2006
New Revision: 382449

URL: http://svn.apache.org/viewcvs?rev=382449&view=rev
Log:
Capturing MissingAddressingHeader fault

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=382449&r1=382448&r2=382449&view=diff
==============================================================================
--- 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
Thu Mar  2 09:16:23 2006
@@ -67,6 +67,8 @@
             logger.debug(addressingVersion + " Headers present in the SOAP message. Starting
to process ...");
             extractAddressingInformation(header, msgContext,
                     addressingHeaders, addressingNamespace);
+
+
         } else {
             logger.debug("No Headers present corresponding to " + addressingVersion);
         }
@@ -116,35 +118,54 @@
                 }
             }
         }
+
+        // check for the presense of madatory addressing headers
+        checkForMandatoryHeaders(alreadyFoundAddrHeader, messageContext);
+
         return messageContextOptions;
     }
 
+    private void checkForMandatoryHeaders(Map alreadyFoundAddrHeader, MessageContext messageContext)
throws AxisFault {
+        if (alreadyFoundAddrHeader.get(WSA_ACTION) == null) {
+            makeFault(messageContext, WSA_ACTION, Final.FAULT_ADDRESSING_HEADER_REQUIRED);
+        } else if (alreadyFoundAddrHeader.get(WSA_TO) == null) {
+            makeFault(messageContext, WSA_TO, Final.FAULT_ADDRESSING_HEADER_REQUIRED);
+        }
+    }
+
     private boolean hasDuplicateHeaders(String addressingHeaderName, MessageContext messageContext,
Map alreadyFoundAddressingHeaders) throws AxisFault {
         if (alreadyFoundAddressingHeaders.get(addressingHeaderName) != null) {
-            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(Final.FAULT_HEADER_PROB_HEADER_QNAME, "wsa:" + addressingHeaderName);
-            faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
-            if (!messageContext.isSOAP11()) {
-                SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
-                SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
-                SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
-                soapFaultValue.setText(messageContext.getEnvelope().getNamespace().getPrefix()
+ ":" + SOAP12Constants.FAULT_CODE_SENDER);
-                SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
-                SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
-                soapFaultSubcodeValue.setText(addressingNSObject.getPrefix() + ":" + Final.FAULT_INVALID_HEADER);
-                messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
-            }
-            throw new AxisFault("A header representing a Message Addressing Property is not
valid and the message cannot be processed", addressingNSObject.getPrefix() + ":" + Final.FAULT_INVALID_HEADER);
-
+            return makeFault(messageContext, addressingHeaderName, Final.FAULT_INVALID_HEADER);
         } else {
             alreadyFoundAddressingHeaders.put(addressingHeaderName, addressingHeaderName);
         }
         return false;
+    }
+
+    private boolean makeFault(MessageContext messageContext, String addressingHeaderName,
String faultCode) 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(Final.FAULT_HEADER_PROB_HEADER_QNAME, "wsa:" + addressingHeaderName);
+        faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
+        if (!messageContext.isSOAP11()) {
+            setFaultCode(messageContext, faultCode);
+        }
+        throw new AxisFault("A header representing a Message Addressing Property is not valid
and the message cannot be processed", addressingNSObject.getPrefix() + ":" + faultCode);
+    }
+
+    private void setFaultCode(MessageContext messageContext, String faultCode) {
+        SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
+        SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
+        SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
+        soapFaultValue.setText(messageContext.getEnvelope().getNamespace().getPrefix() +
":" + SOAP12Constants.FAULT_CODE_SENDER);
+        SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
+        SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
+        soapFaultSubcodeValue.setText(addressingNSObject.getPrefix() + ":" + faultCode);
+        messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
     }
 
     protected abstract void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader
header);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=382449&r1=382448&r2=382449&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
Thu Mar  2 09:16:23 2006
@@ -69,6 +69,7 @@
         public static final String FAULT_HEADER_PROB_HEADER = "ProblemHeader";
         public static final String FAULT_HEADER_DETAIL = "FaultDetail";
         public static final String FAULT_INVALID_HEADER = "InvalidAddressingHeader";
+        public static final String FAULT_ADDRESSING_HEADER_REQUIRED = "MessageAddressingHeaderRequired";
 
     }
 



Mime
View raw message