axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r382350 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/addressing/ core/src/org/apache/axis2/engine/
Date Thu, 02 Mar 2006 11:05:03 GMT
Author: chinthaka
Date: Thu Mar  2 03:04:59 2006
New Revision: 382350

URL: http://svn.apache.org/viewcvs?rev=382350&view=rev
Log:
Handling invalid addressing headers case

Modified:
    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/core/src/org/apache/axis2/addressing/AddressingConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.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=382350&r1=382349&r2=382350&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 03:04:59 2006
@@ -26,10 +26,15 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.ws.commons.om.OMAbstractFactory;
 import org.apache.ws.commons.om.OMAttribute;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMNamespace;
 import org.apache.ws.commons.soap.SOAP12Constants;
 import org.apache.ws.commons.soap.SOAPFactory;
+import org.apache.ws.commons.soap.SOAPFaultCode;
 import org.apache.ws.commons.soap.SOAPFaultReason;
+import org.apache.ws.commons.soap.SOAPFaultSubCode;
 import org.apache.ws.commons.soap.SOAPFaultText;
+import org.apache.ws.commons.soap.SOAPFaultValue;
 import org.apache.ws.commons.soap.SOAPHeader;
 import org.apache.ws.commons.soap.SOAPHeaderBlock;
 
@@ -42,6 +47,7 @@
 public abstract class AddressingInHandler extends AddressingHandler implements AddressingConstants
{
 
     private static final long serialVersionUID = 3907988439637261572L;
+    private OMNamespace addressingNSObject;
 
     public void invoke(MessageContext msgContext) throws AxisFault {
         SOAPHeader header = msgContext.getEnvelope().getHeader();
@@ -54,27 +60,22 @@
         logger.debug("Starting " + addressingVersion + " IN handler ...");
 
         ArrayList addressingHeaders;
-        try {
-            addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
-            if (addressingHeaders != null && addressingHeaders.size() > 0) {
-                msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace);
-                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);
-            }
-
-        } catch (AddressingException e) {
-            logger.info("Exception occurred in Addressing Module");
-            throw new AxisFault(e);
+        addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
+        if (addressingHeaders != null && addressingHeaders.size() > 0) {
+            msgContext.setProperty(WS_ADDRESSING_VERSION, addressingNamespace);
+            addressingNSObject = ((OMElement) addressingHeaders.get(0)).findNamespace(addressingNamespace,
"");
+            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);
         }
 
+
     }
 
     protected Options extractAddressingInformation(SOAPHeader header, MessageContext messageContext,
-                                                   ArrayList addressingHeaders, String addressingNamespace)
-            throws AddressingException {
+                                                   ArrayList addressingHeaders, String addressingNamespace)
throws AxisFault {
 
         Options messageContextOptions = messageContext.getOptions();
         Map alreadyFoundAddrHeader = new HashMap(7); // there are seven frequently used WS-A
headers
@@ -84,19 +85,19 @@
             SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
             EndpointReference epr;
             if (WSA_TO.equals(soapHeaderBlock.getLocalName())) {
-                if(!hasDuplicateHeaders(WSA_TO, messageContext, alreadyFoundAddrHeader)){
+                if (!hasDuplicateHeaders(WSA_TO, messageContext, alreadyFoundAddrHeader))
{
                     extractToEPRInformation(soapHeaderBlock, messageContextOptions, header);
                 }
             } else if (WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
-                if(!hasDuplicateHeaders(WSA_FROM, messageContext, alreadyFoundAddrHeader)){
+                if (!hasDuplicateHeaders(WSA_FROM, messageContext, alreadyFoundAddrHeader))
{
                     extractFromEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
                 }
             } else if (WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
-                if(!hasDuplicateHeaders(WSA_REPLY_TO, messageContext, alreadyFoundAddrHeader)){
+                if (!hasDuplicateHeaders(WSA_REPLY_TO, messageContext, alreadyFoundAddrHeader))
{
                     extractReplyToEPRInformation(messageContextOptions, soapHeaderBlock,
addressingNamespace);
                 }
             } else if (WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
-                if(!hasDuplicateHeaders(WSA_FAULT_TO, messageContext, alreadyFoundAddrHeader))
{
+                if (!hasDuplicateHeaders(WSA_FAULT_TO, messageContext, alreadyFoundAddrHeader))
{
                     extractFaultToEPRInformation(messageContextOptions, soapHeaderBlock,
addressingNamespace);
                 }
             } else if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
@@ -106,7 +107,7 @@
                 messageContextOptions.setAction(soapHeaderBlock.getText());
                 soapHeaderBlock.setProcessed();
             } else if (WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
-                if(!hasDuplicateHeaders(WSA_RELATES_TO, messageContext, alreadyFoundAddrHeader)){
+                if (!hasDuplicateHeaders(WSA_RELATES_TO, messageContext, alreadyFoundAddrHeader))
{
                     extractRelatesToInformation(soapHeaderBlock, addressingNamespace, messageContextOptions);
                 }
             }
@@ -114,16 +115,28 @@
         return messageContextOptions;
     }
 
-    private boolean hasDuplicateHeaders(String addressingHeaderName, MessageContext messageContext,
Map alreadyFoundAddressingHeaders) {
+    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.FAULT_HEADER_PROB_HEADER_QNAME, "wsa:" + addressingHeaderName);
             faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
-            return true;
+            if (messageContext.isSOAP11()) {
+                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);
+            } else {
+                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);
+            }
         } else {
             alreadyFoundAddressingHeaders.put(addressingHeaderName, addressingHeaderName);
         }

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=382350&r1=382349&r2=382350&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 Mar  2 03:04:59 2006
@@ -157,10 +157,6 @@
                 probHeaderQName.setText(faultyHeaderQName);
             }
 
-            String wsaFaultAction = (String) faultInfo.get(Final.WSA_FAULT_ACTION);
-            if (wsaFaultAction != null && !"".equals(wsaFaultAction)) {
-                processStringInfo(wsaFaultAction, WSA_ACTION, envelope);
-            }
         }
     }
 

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=382350&r1=382349&r2=382350&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 03:04:59 2006
@@ -67,6 +67,8 @@
         // fault information
         public static final String FAULT_HEADER_PROB_HEADER_QNAME = "ProblemHeaderQName";
         public static final String FAULT_HEADER_DETAIL = "FaultDetail";
+        public static final String FAULT_INVALID_HEADER = "InvalidAddressingHeader";
+
     }
 
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=382350&r1=382349&r2=382350&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 Mar  2 03:04:59 2006
@@ -281,13 +281,17 @@
         if (((exception = e) instanceof AxisFault || (exception = e.getCause()) instanceof
AxisFault))
         {
             QName faultCodeQName = ((AxisFault) exception).getFaultCode();
-            if (faultCodeQName != null && faultCodeQName.getLocalPart().indexOf(":")
== -1) {
-                String prefix = faultCodeQName.getPrefix();
-                String uri = faultCodeQName.getNamespaceURI();
-                prefix = prefix == null || "".equals(prefix) ? Constants.AXIS2_NAMESPACE_PREFIX
: prefix;
-                uri = uri == null || "".equals(uri) ? Constants.AXIS2_NAMESPACE_URI : uri;
-                soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
-                fault.declareNamespace(uri, prefix);
+            if (faultCodeQName != null) {
+                if (faultCodeQName.getLocalPart().indexOf(":") == -1) {
+                    String prefix = faultCodeQName.getPrefix();
+                    String uri = faultCodeQName.getNamespaceURI();
+                    prefix = prefix == null || "".equals(prefix) ? Constants.AXIS2_NAMESPACE_PREFIX
: prefix;
+                    uri = uri == null || "".equals(uri) ? Constants.AXIS2_NAMESPACE_URI :
uri;
+                    soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
+                    fault.declareNamespace(uri, prefix);
+                }else{
+                    soapFaultCode = faultCodeQName.getLocalPart();
+                }
             }
         }
 
@@ -305,8 +309,8 @@
             message = fault.getReason().getSOAPText().getText();
         } else if (soapException != null) {
             message = soapException.getMessage();
-        } else if (e instanceof AxisFault) {
-            message = ((AxisFault) e).getReason();
+        } else if (exception instanceof AxisFault) {
+            message = ((AxisFault) exception).getReason();
             message = message != null && "".equals(message) ? message : e.getMessage();
 
         }
@@ -315,6 +319,7 @@
         message = ("".equals(message) || (message == null))
                 ? "unknown"
                 : message;
+        fault.getReason().getSOAPText().setLang("en-US");
         fault.getReason().getSOAPText().setText(message);
 
         Object faultRole = context.getProperty(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME);



Mime
View raw message