Author: jason.greene(a)jboss.com
Date: 2007-03-15 06:13:42 -0400 (Thu, 15 Mar 2007)
New Revision: 2618
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP12Binding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerDelegateJAXRPC.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/ServerHandlerChain.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/HTTPBindingJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/MessageBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/PayloadBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/SOAP11BindingJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/HandlerDelegate.java
Log:
Fix mustUnderstand processing
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonBinding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonBinding.java 2007-03-15 00:28:50
UTC (rev 2617)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonBinding.java 2007-03-15 10:13:42
UTC (rev 2618)
@@ -28,6 +28,7 @@
import javax.xml.namespace.QName;
import org.jboss.ws.core.jaxrpc.binding.BindingException;
+import org.jboss.ws.core.server.HandlerDelegate;
import org.jboss.ws.core.soap.UnboundHeader;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -53,4 +54,6 @@
/** bind an exception to a fault message */
Object bindFaultMessage(Exception ex);
+
+ void setHandlerDelegate(HandlerDelegate delegate);
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java 2007-03-15
00:28:50 UTC (rev 2617)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,13 +23,21 @@
// $Id$
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import org.jboss.ws.Constants;
import org.jboss.ws.core.jaxrpc.Use;
+import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
/**
@@ -60,4 +68,25 @@
return soapMessage;
}
+
+ public abstract Set<String> getRoles();
+
+ @Override
+ protected void verifyUnderstoodHeader(SOAPHeaderElement element) throws Exception
+ {
+ QName name = new QName(element.getNamespaceURI(), element.getLocalName());
+ String actor = element.getActor();
+ Set<String> roles = getRoles();
+
+ boolean isActor = actor == null || actor.length() == 0 ||
Constants.URI_SOAP11_NEXT_ACTOR.equals(actor) || roles.contains(actor);
+ if (isActor && !handlerDelegate.getHeaders().contains(name))
+ {
+ QName faultCode = Constants.SOAP11_FAULT_CODE_MUST_UNDERSTAND;
+ String faultString = "Unprocessed 'mustUnderstand' header element:
" + element.getElementName();
+ SOAPFaultImpl fault = new SOAPFaultImpl();
+ fault.setFaultCode(faultCode);
+ fault.setFaultString(faultString);
+ throwFaultException(fault);
+ }
+ }
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP12Binding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP12Binding.java 2007-03-15
00:28:50 UTC (rev 2617)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP12Binding.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,11 +23,19 @@
// $Id$
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import org.jboss.ws.Constants;
import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
/**
@@ -50,4 +58,25 @@
factory.setEnvNamespace(Constants.NS_SOAP12_ENV);
return factory.createMessage();
}
+
+ protected abstract Set<String> getRoles();
+
+ @Override
+ protected void verifyUnderstoodHeader(SOAPHeaderElement element) throws Exception
+ {
+ QName name = new QName(element.getNamespaceURI(), element.getLocalName());
+ String actor = element.getActor();
+ Set<String> roles = getRoles();
+
+ boolean isActor = actor == null || actor.length() == 0 ||
Constants.URI_SOAP11_NEXT_ACTOR.equals(actor) || roles.contains(actor);
+ if (isActor && !handlerDelegate.getHeaders().contains(name))
+ {
+ // How do we pass NotUnderstood blocks? They are not in the fault element
+ QName faultCode = SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT;
+ SOAPFaultImpl fault = new SOAPFaultImpl();
+ fault.setFaultCode(faultCode);
+ fault.setFaultString("SOAP header blocks not understood");
+ throwFaultException(fault);
+ }
+ }
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-15
00:28:50 UTC (rev 2617)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,14 +23,18 @@
// $Id$
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
+import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
@@ -41,6 +45,7 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import org.apache.xerces.xs.XSElementDeclaration;
@@ -51,6 +56,7 @@
import org.jboss.ws.core.jaxrpc.ParameterWrapping;
import org.jboss.ws.core.jaxrpc.Style;
import org.jboss.ws.core.jaxrpc.binding.BindingException;
+import org.jboss.ws.core.server.HandlerDelegate;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.NameImpl;
@@ -69,6 +75,7 @@
import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.core.utils.MimeUtils;
import org.jboss.ws.extensions.xop.XOPContext;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ParameterMetaData;
import org.jboss.ws.metadata.umdm.TypesMetaData;
@@ -88,6 +95,8 @@
private boolean mtomEnabled;
+ protected HandlerDelegate handlerDelegate;
+
/** A constant representing the identity of the SOAP 1.1 over HTTP binding. */
public static final String SOAP11HTTP_BINDING =
"http://schemas.xmlsoap.org/wsdl/soap/http";
/** A constant representing the identity of the SOAP 1.2 over HTTP binding. */
@@ -800,6 +809,39 @@
abstract protected void throwFaultException(SOAPFaultImpl fault) throws Exception;
+ abstract protected void verifyUnderstoodHeader(SOAPHeaderElement element) throws
Exception;
+
+ public void checkMustUnderstand(OperationMetaData opMetaData) throws Exception
+ {
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ if (msgContext == null)
+ throw new WSException("MessageContext not available");
+
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl)msgContext.getSOAPMessage();
+ SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
+ if (soapEnvelope == null || soapEnvelope.getHeader() == null)
+ return;
+
+ Iterator it = soapEnvelope.getHeader().examineAllHeaderElements();
+ while (it.hasNext())
+ {
+ SOAPHeaderElement soapHeaderElement = (SOAPHeaderElement)it.next();
+ Name name = soapHeaderElement.getElementName();
+ QName xmlName = new QName(name.getURI(), name.getLocalName());
+
+ ParameterMetaData paramMetaData = (opMetaData != null ?
opMetaData.getParameter(xmlName) : null);
+ boolean isBoundHeader = (paramMetaData != null &&
paramMetaData.isInHeader());
+
+ if (!isBoundHeader && soapHeaderElement.getMustUnderstand())
+ verifyUnderstoodHeader(soapHeaderElement);
+ }
+ }
+
+ public void setHandlerDelegate(HandlerDelegate delegate)
+ {
+ handlerDelegate = delegate;
+ }
+
private void handleException(Exception ex) throws BindingException
{
if (ex instanceof RuntimeException)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP11BindingJAXRPC.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,9 +23,17 @@
//$Id:SOAP11BindingJAXRPC.java 1054 2006-09-26 10:33:43Z thomas.diesler(a)jboss.com $
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
+import org.jboss.ws.Constants;
import org.jboss.ws.core.CommonSOAP11Binding;
+import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -59,4 +67,13 @@
{
throw SOAPFaultHelperJAXRPC.getSOAPFaultException(fault);
}
-}
+
+ @Override
+ public Set<String> getRoles()
+ {
+ if (!(handlerDelegate instanceof HandlerDelegateJAXRPC))
+ throw new IllegalStateException("HandlerDelegateJAXRPC was not
available");
+
+ return ((HandlerDelegateJAXRPC)handlerDelegate).getRoles();
+ }
+}
\ No newline at end of file
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/SOAP12BindingJAXRPC.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,9 +23,12 @@
//$Id:SOAP12BindingJAXRPC.java 1054 2006-09-26 10:33:43Z thomas.diesler(a)jboss.com $
+import java.util.Set;
+
import javax.xml.soap.SOAPMessage;
import org.jboss.ws.core.CommonSOAP12Binding;
+import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -55,6 +58,15 @@
return SOAPFaultHelperJAXRPC.exceptionToFaultMessage(ex);
}
+ @Override
+ public Set<String> getRoles()
+ {
+ if (!(handlerDelegate instanceof HandlerDelegateJAXRPC))
+ throw new IllegalStateException("HandlerDelegateJAXRPC was not
available");
+
+ return ((HandlerDelegateJAXRPC)handlerDelegate).getRoles();
+ }
+
protected void throwFaultException(SOAPFaultImpl fault) throws Exception
{
throw SOAPFaultHelperJAXRPC.getSOAPFaultException(fault);
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -106,6 +107,16 @@
}
return list;
}
+
+ public void pullHeaders(Set<QName> headers)
+ {
+ for (HandlerEntry entry : handlers)
+ {
+ QName[] handlerHeaders = entry.handler.getHeaders();
+ if (handlerHeaders != null)
+ Collections.addAll(headers, handlerHeaders);
+ }
+ }
/**
* Initialize the a handler chain with the given handlers infos
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerDelegateJAXRPC.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerDelegateJAXRPC.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/HandlerDelegateJAXRPC.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -24,6 +24,7 @@
// $Id$
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -60,6 +61,10 @@
private ServerHandlerChain jaxrpcHandlerChain;
// This endpoints handler chain
private ServerHandlerChain postHandlerChain;
+ // Set of understood headers
+ Set<QName> headers = new HashSet<QName>();
+ // Set of roles
+ Set<String> roles = new HashSet<String>();
public HandlerDelegateJAXRPC(ServerEndpointMetaData sepMetaData)
{
@@ -81,7 +86,6 @@
}
boolean status = true;
- String[] roles = null;
HandlerChain handlerChain = null;
if (type == HandlerType.PRE)
@@ -92,15 +96,8 @@
handlerChain = postHandlerChain;
if (handlerChain != null)
- {
- roles = handlerChain.getRoles();
status = handlerChain.handleRequest(msgContext);
- }
- // BP-1.0 R1027
- if (type == HandlerType.POST)
- HandlerChainBaseImpl.checkMustUnderstand(msgContext, roles);
-
return status;
}
@@ -200,8 +197,20 @@
// what is the config for a handler chain?
handlerChain.init(null);
}
+ handlerChain.pullHeaders(headers);
+ Collections.addAll(roles, handlerChain.getRoles());
}
+ public Set<String> getRoles()
+ {
+ return roles;
+ }
+
+ public Set<QName> getHeaders()
+ {
+ return headers;
+ }
+
public void update(Observable observable, Object object)
{
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/ServerHandlerChain.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/ServerHandlerChain.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/handler/ServerHandlerChain.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Set;
+import javax.xml.namespace.QName;
import javax.xml.rpc.handler.MessageContext;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/HTTPBindingJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/HTTPBindingJAXWS.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/HTTPBindingJAXWS.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -34,6 +34,7 @@
import org.jboss.ws.core.CommonBinding;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.jaxrpc.binding.BindingException;
+import org.jboss.ws.core.server.HandlerDelegate;
import org.jboss.ws.core.soap.UnboundHeader;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
@@ -97,4 +98,9 @@
{
throw new NotImplementedException();
}
+
+ public void setHandlerDelegate(HandlerDelegate delegate)
+ {
+ // Not needed
+ }
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/MessageBinding.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/MessageBinding.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/MessageBinding.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -39,6 +39,7 @@
import org.jboss.ws.core.jaxrpc.binding.BindingException;
import org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.core.server.HandlerDelegate;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.UnboundHeader;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -172,4 +173,9 @@
{
throw new NotImplementedException();
}
+
+ public void setHandlerDelegate(HandlerDelegate delegate)
+ {
+ // Not needed
+ }
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/PayloadBinding.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/PayloadBinding.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/PayloadBinding.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -41,6 +41,7 @@
import org.jboss.ws.core.jaxrpc.binding.BindingException;
import org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.core.server.HandlerDelegate;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.SOAPBodyImpl;
@@ -187,4 +188,9 @@
{
throw new NotImplementedException();
}
+
+ public void setHandlerDelegate(HandlerDelegate delegate)
+ {
+ // Not neeeded
+ }
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/SOAP11BindingJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/SOAP11BindingJAXWS.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/binding/SOAP11BindingJAXWS.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -27,6 +27,10 @@
import java.util.List;
import java.util.Set;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
@@ -34,6 +38,7 @@
import org.jboss.util.NotImplementedException;
import org.jboss.ws.Constants;
import org.jboss.ws.core.CommonSOAP11Binding;
+import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS;
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Observable;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.ws.handler.Handler;
@@ -121,6 +122,11 @@
return info;
}
+ public Set<QName> getHeaders()
+ {
+ return resolver.getHeaders();
+ }
+
private HandlerChainExecutor createExecutor(ServerEndpointMetaData sepMetaData,
HandlerType type)
{
if (type == HandlerType.ALL)
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -24,11 +24,11 @@
// $Id$
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,6 +40,7 @@
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.SOAPBinding;
@@ -72,6 +73,9 @@
private Map<PortInfo, List<Handler>> preHandlers = new
HashMap<PortInfo, List<Handler>>();
private Map<PortInfo, List<Handler>> jaxwsHandlers = new
HashMap<PortInfo, List<Handler>>();
private Map<PortInfo, List<Handler>> postHandlers = new
HashMap<PortInfo, List<Handler>>();
+
+ // understood headers
+ Set<QName> headers = new HashSet<QName>();
public List<Handler> getHandlerChain(PortInfo info)
{
@@ -157,7 +161,7 @@
if (handler instanceof GenericSOAPHandler)
((GenericSOAPHandler)handler).setHeaders(soapHeaders);
-
+
// Inject resources
injectResources(handler);
@@ -320,6 +324,14 @@
handlerMap.put(info, handlerList = new ArrayList<Handler>());
}
handlerList.add(handler);
+
+ // Ask all initialized handlers for what headers they understand
+ if (handler instanceof SOAPHandler)
+ {
+ Set handlerHeaders = ((SOAPHandler)handler).getHeaders();
+ if (handlerHeaders != null)
+ headers.addAll(handlerHeaders);
+ }
return true;
}
@@ -338,4 +350,9 @@
return handlerMap;
}
+
+ public Set<QName> getHeaders()
+ {
+ return headers;
+ }
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2007-03-15
00:28:50 UTC (rev 2617)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/server/AbstractServiceEndpointInvoker.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -144,9 +144,10 @@
try
{
boolean oneway = false;
- CommonBinding binding = null;
EndpointInvocation epInv = null;
OperationMetaData opMetaData = null;
+ CommonBinding binding = bindingProvider.getCommonBinding();
+ binding.setHandlerDelegate(delegate);
// call the handler chain
boolean handlersPass = callRequestHandlerChain(sepMetaData, HandlerType.PRE);
@@ -154,14 +155,25 @@
// Unbind the request message
if (handlersPass)
{
- // Get the binding from the provideer
- binding = bindingProvider.getCommonBinding();
-
// Get the operation meta data from the SOAP message
opMetaData = getDispatchDestination(sepMetaData, reqMessage);
msgContext.setOperationMetaData(opMetaData);
oneway = opMetaData.isOneWay();
+ /*
+ * From JAX-WS 10.2.1 - "7. If the node does not understand how to
process
+ * the message, then neither handlers nor the endpoint
+ * are invoked and instead the binding generates a SOAP must
+ * understand exception"
+ *
+ * Therefore, this must precede the ENDPOINT chain; however, The PRE
+ * chain still must happen first since the message may be encrypted, in
which
+ * case the operation is still not known. Without knowing the operation, it
+ * is not possible to determine what headers are understood by the endpoint.
+ */
+ if (binding instanceof CommonSOAPBinding)
+ ((CommonSOAPBinding)binding).checkMustUnderstand(opMetaData);
+
// Unbind the request message
epInv = binding.unbindRequestMessage(opMetaData, reqMessage);
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/server/HandlerDelegate.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/server/HandlerDelegate.java 2007-03-15
00:28:50 UTC (rev 2617)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/server/HandlerDelegate.java 2007-03-15
10:13:42 UTC (rev 2618)
@@ -23,6 +23,10 @@
// $Id$
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
import org.jboss.ws.metadata.config.Configurable;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
@@ -57,4 +61,6 @@
{
sepMetaData.setHandlersInitialized(flag);
}
+
+ public abstract Set<QName> getHeaders();
}