Author: heiko.braun(a)jboss.com
Date: 2007-09-07 08:54:25 -0400 (Fri, 07 Sep 2007)
New Revision: 4530
Modified:
legacy/tags/jbossws-1.2.1.GA_CP01/integration-jboss42/src/java/org/jboss/ws/integration/jboss42/ServiceEndpointInterceptor.java
legacy/tags/jbossws-1.2.1.GA_CP01/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
Log:
JBCTS-623: Handler message change failure
Modified:
legacy/tags/jbossws-1.2.1.GA_CP01/integration-jboss42/src/java/org/jboss/ws/integration/jboss42/ServiceEndpointInterceptor.java
===================================================================
---
legacy/tags/jbossws-1.2.1.GA_CP01/integration-jboss42/src/java/org/jboss/ws/integration/jboss42/ServiceEndpointInterceptor.java 2007-09-07
12:52:50 UTC (rev 4529)
+++
legacy/tags/jbossws-1.2.1.GA_CP01/integration-jboss42/src/java/org/jboss/ws/integration/jboss42/ServiceEndpointInterceptor.java 2007-09-07
12:54:25 UTC (rev 4530)
@@ -24,6 +24,7 @@
// $Id$
import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPEnvelope;
import org.jboss.ejb.plugins.AbstractInterceptor;
import org.jboss.invocation.Invocation;
@@ -34,10 +35,16 @@
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.MessageAbstraction;
+import org.jboss.ws.core.CommonSOAP11Binding;
+import org.jboss.ws.core.CommonSOAPBinding;
import org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC;
+import org.jboss.ws.core.jaxrpc.SOAP11BindingJAXRPC;
+import org.jboss.ws.core.jaxrpc.SOAP12BindingJAXRPC;
import org.jboss.ws.core.soap.SOAPMessageImpl;
+import org.jboss.ws.core.soap.SOAPEnvelopeImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
+import org.jboss.ws.Constants;
/**
* This Interceptor does the ws4ee handler processing.
@@ -86,6 +93,29 @@
// Call the next interceptor in the chain
if (handlersPass)
{
+
+ // [JBCTS-623] Check if handlers modified the payload
+
+ if (msgContext.isModified())
+ {
+ log.debug("Handler modified payload, unbind message again");
+ SOAPMessage reqMessage = msgContext.getSOAPMessage();
+ SOAPEnvelopeImpl env =
(SOAPEnvelopeImpl)reqMessage.getSOAPPart().getEnvelope();
+
+ CommonSOAPBinding soapBinding;
+ if(env.getNamespaceURI().equals(Constants.NS_SOAP11_ENV) )
+ {
+ soapBinding = new SOAP11BindingJAXRPC();
+ }
+ else
+ {
+ soapBinding = new SOAP12BindingJAXRPC();
+ }
+
+ epInv = soapBinding.unbindRequestMessage(opMetaData,
msgContext.getMessageAbstraction());
+ }
+
+
// The SOAPContentElements stored in the EndpointInvocation might have
changed after
// handler processing. Get the updated request payload. This should be a
noop if request
// handlers did not modify the incomming SOAP message.
Modified:
legacy/tags/jbossws-1.2.1.GA_CP01/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
---
legacy/tags/jbossws-1.2.1.GA_CP01/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-09-07
12:52:50 UTC (rev 4529)
+++
legacy/tags/jbossws-1.2.1.GA_CP01/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-09-07
12:54:25 UTC (rev 4530)
@@ -79,6 +79,8 @@
import org.jboss.ws.metadata.umdm.TypesMetaData;
import org.jboss.xb.binding.NamespaceRegistry;
import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
/**
* The SOAPBinding interface is an abstraction for the SOAP binding.
@@ -305,6 +307,29 @@
Name elName = soapBodyElement.getElementName();
+ //
+ NodeList childNodes = soapBodyElement.getChildNodes();
+ int childElementsLength = 0;
+ for ( int i=0; i<childNodes.getLength(); i++)
+ {
+ if(childNodes.item(i).getNodeType() == Node.ELEMENT_NODE)
+ {
+ childElementsLength++;
+ }
+ }
+
+ int expectedNumChildElements = 0;
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ if(!paramMetaData.isInHeader() && !paramMetaData.isSwA()
&& paramMetaData.getMode()!=ParameterMode.OUT )
+ {
+ expectedNumChildElements++;
+ }
+ }
+
+ if(childElementsLength!=expectedNumChildElements)
+ throw new BindingException("The number of child elements
doesn't match OperationMetaData: " + elName);
+
QName elQName = new QName(elName.getURI(), elName.getLocalName(),
elName.getPrefix());
elQName = namespaceRegistry.registerQName(elQName);
}
Show replies by date