Author: thomas.diesler(a)jboss.com
Date: 2007-03-15 19:53:38 -0400 (Thu, 15 Mar 2007)
New Revision: 2626
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.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/MessageContextJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerJAXBTestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerSourceTestCase.java
Log:
[JBWS-1578] Redefine order of jaxws handlers
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-15
19:06:23 UTC (rev 2625)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -141,7 +141,7 @@
executorMap.put(type, executor);
MessageContext msgContext =
(MessageContext)MessageContextAssociation.peekMessageContext();
- return executor.handleRequest(msgContext);
+ return executor.handleMessage(msgContext);
}
@Override
@@ -149,7 +149,7 @@
{
MessageContext msgContext =
(MessageContext)MessageContextAssociation.peekMessageContext();
HandlerChainExecutor executor = executorMap.get(type);
- return (executor != null ? executor.handleResponse(msgContext) : true);
+ return (executor != null ? executor.handleMessage(msgContext) : true);
}
@Override
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -34,6 +34,7 @@
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.jboss.logging.Logger;
import org.jboss.ws.core.CommonMessageContext;
@@ -57,10 +58,12 @@
private EndpointMetaData epMetaData;
// The list of handlers
protected List<Handler> handlers = new ArrayList<Handler>();
- // The list of handlers tp close
- protected List<Handler> closeHandlers = new ArrayList<Handler>();
+ // The list of executed handlers
+ protected List<Handler> executedHandlers = new ArrayList<Handler>();
// The index of the first handler that returned false during processing
protected int falseIndex = -1;
+ // True if the current direction is outbound
+ protected Boolean isOutbound;
public HandlerChainExecutor(EndpointMetaData epMetaData, List<Handler>
unsortedChain)
{
@@ -92,47 +95,61 @@
public void close(MessageContext msgContext)
{
log.debug("close");
- int handlerIndex = closeHandlers.size() - 1;
- for (; handlerIndex >= 0; handlerIndex--)
+ CommonMessageContext context = (CommonMessageContext)msgContext;
+ for (int index = 1; index <= executedHandlers.size(); index++)
{
- Handler currHandler = closeHandlers.get(handlerIndex);
- currHandler.close(msgContext);
+ Handler currHandler = executedHandlers.get(executedHandlers.size() - index);
+ try
+ {
+ context.setCurrentScope(Scope.HANDLER);
+ currHandler.close(msgContext);
+ }
+ finally
+ {
+ context.setCurrentScope(Scope.APPLICATION);
+ }
}
}
- public boolean handleRequest(MessageContext msgContext)
+ public boolean handleMessage(MessageContext msgContext)
{
+ isOutbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (isOutbound == null)
+ throw new IllegalStateException("Cannot find property: " +
MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
boolean doNext = true;
if (handlers.size() > 0)
{
- log.debug("Enter: handleRequest");
+ log.debug("Enter: handle" + (isOutbound ? "Out" : "In
") + "BoundMessage");
- SOAPMessageContextJAXWS soapContext = (SOAPMessageContextJAXWS)msgContext;
- soapContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM,
Boolean.TRUE);
+ msgContext.put(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
- int handlerIndex = 0;
+ int index = getFirstHandler();
Handler currHandler = null;
try
{
String lastMessageTrace = null;
- for (; doNext && handlerIndex < handlers.size(); handlerIndex++)
+ while (doNext && index >= 0)
{
- currHandler = handlers.get(handlerIndex);
+ currHandler = handlers.get(index);
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled() && msgContext instanceof
SOAPMessageContext)
{
- SOAPPart soapPart = soapContext.getMessage().getSOAPPart();
+ SOAPPart soapPart =
((SOAPMessageContext)msgContext).getMessage().getSOAPPart();
lastMessageTrace = traceSOAPPart("BEFORE handleRequest - " +
currHandler, soapPart, lastMessageTrace);
}
- doNext = handleMessage(currHandler, soapContext);
+ doNext = handleMessage(currHandler, msgContext);
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled() && msgContext instanceof
SOAPMessageContext)
{
- SOAPPart soapPart = soapContext.getMessage().getSOAPPart();
+ SOAPPart soapPart =
((SOAPMessageContext)msgContext).getMessage().getSOAPPart();
lastMessageTrace = traceSOAPPart("AFTER handleRequest - " +
currHandler, soapPart, lastMessageTrace);
}
+
+ if (doNext)
+ index = getNextIndex(index);
}
}
catch (RuntimeException ex)
@@ -144,124 +161,96 @@
{
// we start at this index in the response chain
if (doNext == false)
- falseIndex = handlerIndex;
+ falseIndex = index;
- soapContext.removeProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
- log.debug("Exit: handleRequest with status: " + doNext);
+ msgContext.remove(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
+ log.debug("Exit: handle" + (isOutbound ? "Out" : "In
") + "BoundMessage with status: " + doNext);
}
}
return doNext;
}
- public boolean handleResponse(MessageContext msgContext)
+ private int getFirstHandler()
{
- boolean doNext = true;
-
- SOAPMessageContextJAXWS soapContext = (SOAPMessageContextJAXWS)msgContext;
- soapContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
-
- if (handlers.size() > 0)
+ int index;
+ if (falseIndex == -1)
{
- log.debug("Enter: handleResponse");
-
- int handlerIndex = handlers.size() - 1;
- if (falseIndex != -1)
- handlerIndex = falseIndex - 1;
-
- Handler currHandler = null;
- try
- {
- String lastMessageTrace = null;
- for (; doNext && handlerIndex >= 0; handlerIndex--)
- {
- currHandler = handlers.get(handlerIndex);
-
- if (log.isTraceEnabled())
- {
- SOAPPart soapPart = soapContext.getMessage().getSOAPPart();
- lastMessageTrace = traceSOAPPart("BEFORE handleResponse - " +
currHandler, soapPart, lastMessageTrace);
- }
-
- doNext = handleMessage(currHandler, soapContext);
-
- if (log.isTraceEnabled())
- {
- SOAPPart soapPart = soapContext.getMessage().getSOAPPart();
- lastMessageTrace = traceSOAPPart("AFTER handleResponse - " +
currHandler, soapPart, lastMessageTrace);
- }
- }
- }
- catch (RuntimeException ex)
- {
- doNext = false;
- processHandlerFailure(ex);
- }
- finally
- {
- // we start at this index in the fault chain
- if (doNext == false)
- falseIndex = handlerIndex;
-
- soapContext.removeProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
- log.debug("Exit: handleResponse with status: " + doNext);
- }
+ index = (isOutbound ? 0 : handlers.size() - 1);
}
+ else
+ {
+ index = (isOutbound ? falseIndex - 1 : falseIndex + 1);
+ }
+ return index;
+ }
- return doNext;
+ private int getNextIndex(int prevIndex)
+ {
+ int nextIndex = (isOutbound ? prevIndex + 1 : prevIndex - 1);
+ if (nextIndex >= handlers.size())
+ nextIndex = -1;
+ return nextIndex;
}
public boolean handleFault(MessageContext msgContext, Exception ex)
{
+ isOutbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (isOutbound == null)
+ throw new IllegalStateException("Cannot find property: " +
MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
boolean doNext = true;
if (handlers.size() > 0)
{
- log.debug("Enter: handleFault");
+ log.debug("Enter: handle" + (isOutbound ? "Out" : "In
") + "BoundFault");
- SOAPMessageContextJAXWS soapContext = (SOAPMessageContextJAXWS)msgContext;
- soapContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM,
Boolean.TRUE);
- SOAPMessage soapMessage = soapContext.getMessage();
-
- // If the message is not already a fault message then it is replaced with a
fault message
- try
+ if (msgContext instanceof SOAPMessageContext)
{
- if (soapMessage == null || soapMessage.getSOAPBody().getFault() == null)
+ SOAPMessageContext soapContext = (SOAPMessageContext)msgContext;
+ SOAPMessage soapMessage = soapContext.getMessage();
+
+ // If the message is not already a fault message then it is replaced with a
fault message
+ try
{
- soapMessage = SOAPFaultHelperJAXWS.exceptionToFaultMessage(ex);
- soapContext.setMessage(soapMessage);
+ if (soapMessage == null || soapMessage.getSOAPBody().getFault() == null)
+ {
+ soapMessage = SOAPFaultHelperJAXWS.exceptionToFaultMessage(ex);
+ soapContext.setMessage(soapMessage);
+ }
}
+ catch (SOAPException se)
+ {
+ throw new WebServiceException("Cannot convert exception to fault
message", ex);
+ }
}
- catch (SOAPException se)
- {
- throw new WebServiceException("Cannot convert exception to fault
message", ex);
- }
-
- int handlerIndex = handlers.size() - 1;
- if (falseIndex != -1)
- handlerIndex = falseIndex - 1;
-
+
+ msgContext.put(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
+
+ int index = getFirstHandler();
Handler currHandler = null;
try
{
String lastMessageTrace = null;
- for (; doNext && handlerIndex >= 0; handlerIndex--)
+ while (doNext && index >= 0)
{
- currHandler = handlers.get(handlerIndex);
+ currHandler = handlers.get(index);
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled() && msgContext instanceof
SOAPMessageContext)
{
- SOAPPart soapPart = soapMessage.getSOAPPart();
+ SOAPPart soapPart =
((SOAPMessageContext)msgContext).getMessage().getSOAPPart();
lastMessageTrace = traceSOAPPart("BEFORE handleFault - " +
currHandler, soapPart, lastMessageTrace);
}
- doNext = handleFault(currHandler, soapContext);
+ doNext = handleFault(currHandler, msgContext);
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled() && msgContext instanceof
SOAPMessageContext)
{
- SOAPPart soapPart = soapMessage.getSOAPPart();
+ SOAPPart soapPart =
((SOAPMessageContext)msgContext).getMessage().getSOAPPart();
lastMessageTrace = traceSOAPPart("AFTER handleFault - " +
currHandler, soapPart, lastMessageTrace);
}
+
+ index = getNextIndex(index);
}
}
catch (RuntimeException rte)
@@ -271,12 +260,8 @@
}
finally
{
- // we start at this index in the response chain
- if (doNext == false)
- falseIndex = handlerIndex;
-
- soapContext.removeProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
- log.debug("Exit: handleFault with status: " + doNext);
+ msgContext.remove(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
+ log.debug("Exit: handle" + (isOutbound ? "Out" : "In
") + "BoundFault with status: " + doNext);
}
}
@@ -297,61 +282,54 @@
throw new WebServiceException(ex);
}
- private boolean handleMessage(Handler currHandler, SOAPMessageContextJAXWS
msgContext)
+ private boolean handleMessage(Handler currHandler, MessageContext msgContext)
{
- MessageContext handlerContext = msgContext;
- if (currHandler instanceof LogicalHandler)
+ CommonMessageContext context = (CommonMessageContext)msgContext;
+ if (currHandler instanceof LogicalHandler && msgContext instanceof
SOAPMessageContextJAXWS)
{
if (epMetaData.getStyle() == Style.RPC)
throw new WebServiceException("Cannot use logical handler with
RPC");
- handlerContext = new LogicalMessageContextImpl(msgContext);
+ msgContext = new
LogicalMessageContextImpl((SOAPMessageContextJAXWS)msgContext);
}
- if (closeHandlers.contains(currHandler) == false)
- closeHandlers.add(currHandler);
-
-
- boolean doNext = false;
+ if (executedHandlers.contains(currHandler) == false)
+ executedHandlers.add(currHandler);
+
try
{
- msgContext.setCurrentScope(Scope.HANDLER);
- doNext = currHandler.handleMessage(handlerContext);
+ context.setCurrentScope(Scope.HANDLER);
+ return currHandler.handleMessage(msgContext);
}
finally
{
- msgContext.setCurrentScope(Scope.APPLICATION);
+ context.setCurrentScope(Scope.APPLICATION);
}
-
- return doNext;
}
- private boolean handleFault(Handler currHandler, SOAPMessageContextJAXWS msgContext)
+ private boolean handleFault(Handler currHandler, MessageContext msgContext)
{
- MessageContext handlerContext = msgContext;
- if (currHandler instanceof LogicalHandler)
+ CommonMessageContext context = (CommonMessageContext)msgContext;
+ if (currHandler instanceof LogicalHandler && msgContext instanceof
SOAPMessageContextJAXWS)
{
if (epMetaData.getStyle() == Style.RPC)
throw new WebServiceException("Cannot use logical handler with
RPC");
-
- handlerContext = new LogicalMessageContextImpl(msgContext);
+
+ msgContext = new
LogicalMessageContextImpl((SOAPMessageContextJAXWS)msgContext);
}
- if (closeHandlers.contains(currHandler) == false)
- closeHandlers.add(currHandler);
-
- boolean doNext = false;
+ if (executedHandlers.contains(currHandler) == false)
+ executedHandlers.add(currHandler);
+
try
{
- msgContext.setCurrentScope(Scope.HANDLER);
- doNext = currHandler.handleFault(handlerContext);
+ context.setCurrentScope(Scope.HANDLER);
+ return currHandler.handleFault(msgContext);
}
finally
{
- msgContext.setCurrentScope(Scope.APPLICATION);
+ context.setCurrentScope(Scope.APPLICATION);
}
-
- return doNext;
}
/**
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
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -76,7 +76,7 @@
HandlerChainExecutor executor = createExecutor(sepMetaData, type);
MessageContext msgContext =
(MessageContext)MessageContextAssociation.peekMessageContext();
- return executor.handleRequest(msgContext);
+ return executor.handleMessage(msgContext);
}
public boolean callResponseHandlerChain(ServerEndpointMetaData sepMetaData,
HandlerType type)
@@ -84,7 +84,7 @@
log.debug("callResponseHandlerChain: " + type);
HandlerChainExecutor executor = getExecutor(type);
MessageContext msgContext =
(MessageContext)MessageContextAssociation.peekMessageContext();
- return (executor != null ? executor.handleResponse(msgContext) : true);
+ return (executor != null ? executor.handleMessage(msgContext) : true);
}
public void closeHandlerChain(ServerEndpointMetaData sepMetaData, HandlerType type)
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -106,46 +106,13 @@
if (outbound == null)
throw new IllegalStateException("Cannot find property: " +
MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- // Preserve addressing properties
- SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)reqContext.getProperty(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
- // MTOM setting need to pass past pivot
- boolean mtomEnabled = XOPContext.isMTOMEnabled();
-
-
MessageContextAssociation.popMessageContext();
SOAPMessageContextJAXWS resContext = new SOAPMessageContextJAXWS(reqContext);
resContext.setSOAPMessage(null);
// Reverse the direction
- resContext.setProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY, !outbound);
+ resContext.setProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY, new
Boolean(!outbound));
- /*
- resContext.clear();
-
- resContext.setProperty(StubExt.PROPERTY_MTOM_ENABLED, mtomEnabled);
- resContext.setProperty(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND,
addrProps);
-
- // Copy the handler scoped properties
- try
- {
- reqContext.setCurrentScope(Scope.HANDLER);
- resContext.setCurrentScope(Scope.HANDLER);
- for(String key : reqContext.keySet())
- {
- if (((MessageContextJAXWS)reqContext).getScope(key) == Scope.HANDLER)
- {
- Object value = reqContext.get(key);
- resContext.put(key, value);
- }
- }
- }
- finally
- {
- reqContext.setCurrentScope(Scope.APPLICATION);
- resContext.setCurrentScope(Scope.APPLICATION);
- }
- */
-
MessageContextAssociation.pushMessageContext(resContext);
return resContext;
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-03-15
19:06:23 UTC (rev 2625)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -233,7 +233,7 @@
SOAPMessage soapMessage = msgContext.getSOAPMessage();
if (soapMessage != null && soapMessage.getSOAPPart().getEnvelope() !=
null)
{
- if (soapMessage.getSOAPPart().getEnvelope().getBody().getFault() != null)
+ if (soapMessage.getSOAPPart().getEnvelope().getBody().hasFault())
{
seMetrics.processFaultMessage(beginProcessing);
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -460,7 +460,7 @@
// Also, a one-way operation must show up as empty content, and can be detected
// by a null envelope.
SOAPEnvelope soapEnv = part.getEnvelope();
- boolean isFault = soapEnv != null && soapEnv.getBody().getFault() !=
null;
+ boolean isFault = soapEnv != null && soapEnv.getBody().hasFault();
if (isFault && httpResponse != null)
{
httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2007-03-15
19:06:23 UTC (rev 2625)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -79,6 +79,7 @@
private Source payload;
private boolean isDOMValid = true;
private boolean isModifiedFromSource;
+ private boolean hasFault;
public SOAPBodyImpl(String prefix, String namespace)
{
@@ -112,7 +113,7 @@
public SOAPElement addChildElement(SOAPElement child) throws SOAPException
{
log.trace("addChildElement: " + child.getElementName());
- expandToDOM();
+ expandToDOM(false);
if ((child instanceof SOAPBodyElement) == false)
child = convertToBodyElement(child);
@@ -123,7 +124,7 @@
public SOAPBodyElement addBodyElement(Name name) throws SOAPException
{
log.trace("addBodyElement: " + name);
- expandToDOM();
+ expandToDOM(false);
SOAPBodyElement child = new SOAPBodyElementDoc(name);
return (SOAPBodyElement)addChildElement(child);
}
@@ -131,7 +132,7 @@
public SOAPBodyElement addBodyElement(QName qname) throws SOAPException
{
log.trace("addBodyElement: " + qname);
- expandToDOM();
+ expandToDOM(false);
SOAPBodyElement child = new SOAPBodyElementDoc(qname);
return (SOAPBodyElement)addChildElement(child);
}
@@ -139,7 +140,7 @@
public SOAPBodyElement addDocument(Document doc) throws SOAPException
{
log.trace("addDocument");
- expandToDOM();
+ expandToDOM(false);
Element rootElement = doc.getDocumentElement();
SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
SOAPElement soapElement = soapFactory.createElement(rootElement);
@@ -149,20 +150,21 @@
public SOAPFault addFault() throws SOAPException
{
log.trace("addFault");
- expandToDOM();
+ expandToDOM(true);
if (hasFault())
throw new SOAPException("A SOAPBody may contain at most one SOAPFault child
element");
SOAPFaultImpl soapFault = new SOAPFaultImpl(getPrefix(), getNamespaceURI());
soapFault = (SOAPFaultImpl)addChildElement(soapFault);
soapFault.setFaultCode(soapFault.getDefaultFaultCode());
+ hasFault = true;
return soapFault;
}
public SOAPFault addFault(Name faultCode, String faultString) throws SOAPException
{
log.trace("addFault");
- expandToDOM();
+ expandToDOM(true);
if (hasFault())
throw new SOAPException("A SOAPBody may contain at most one SOAPFault child
element");
@@ -170,13 +172,14 @@
soapFault = (SOAPFaultImpl)addChildElement(soapFault);
soapFault.setFaultCode(faultCode);
soapFault.setFaultString(faultString);
+ hasFault = true;
return soapFault;
}
public SOAPFault addFault(QName faultCode, String faultString) throws SOAPException
{
log.trace("addFault");
- expandToDOM();
+ expandToDOM(true);
if (hasFault())
throw new SOAPException("A SOAPBody may contain at most one SOAPFault child
element");
@@ -184,13 +187,14 @@
soapFault = (SOAPFaultImpl)addChildElement(soapFault);
soapFault.setFaultCode(faultCode);
soapFault.setFaultString(faultString);
+ hasFault = true;
return soapFault;
}
public SOAPFault addFault(Name faultCode, String faultString, Locale locale) throws
SOAPException
{
log.trace("addFault");
- expandToDOM();
+ expandToDOM(true);
if (hasFault())
throw new SOAPException("A SOAPBody may contain at most one SOAPFault child
element");
@@ -198,13 +202,14 @@
soapFault.setFaultCode(faultCode);
soapFault.setFaultString(faultString, locale);
addChildElement(soapFault);
+ hasFault = true;
return soapFault;
}
public SOAPFault addFault(QName faultCode, String faultString, Locale locale) throws
SOAPException
{
log.trace("addFault");
- expandToDOM();
+ expandToDOM(true);
if (hasFault())
throw new SOAPException("A SOAPBody may contain at most one SOAPFault child
element");
@@ -212,22 +217,24 @@
soapFault.setFaultCode(faultCode);
soapFault.setFaultString(faultString, locale);
addChildElement(soapFault);
+ hasFault = true;
return soapFault;
}
public SOAPFault getFault()
{
log.trace("getFault");
- expandToDOM();
+ expandToDOM(true);
Iterator it = faultIterator();
- return it.hasNext() ? (SOAPFault)it.next() : null;
+ SOAPFault soapFault = it.hasNext() ? (SOAPFault)it.next() : null;
+ hasFault = (soapFault != null);
+ return soapFault;
}
public boolean hasFault()
{
log.trace("hasFault");
- expandToDOM();
- return faultIterator().hasNext();
+ return hasFault;
}
private Iterator faultIterator()
@@ -238,7 +245,7 @@
public Node appendChild(Node newChild) throws DOMException
{
log.trace("appendChild: " + newChild.getNodeName());
- expandToDOM();
+ expandToDOM(false);
if (needsConversionToBodyElement(newChild))
newChild = convertToBodyElement(newChild);
@@ -248,7 +255,7 @@
public Node insertBefore(Node newChild, Node refChild) throws DOMException
{
log.trace("insertBefore: " + newChild.getNodeName());
- expandToDOM();
+ expandToDOM(false);
if (needsConversionToBodyElement(newChild))
newChild = convertToBodyElement(newChild);
@@ -258,7 +265,7 @@
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
{
log.trace("replaceChild: " + newChild.getNodeName());
- expandToDOM();
+ expandToDOM(false);
if (needsConversionToBodyElement(newChild))
newChild = convertToBodyElement(newChild);
@@ -268,42 +275,42 @@
public Iterator getChildElements()
{
log.trace("getChildElements");
- expandToDOM();
+ expandToDOM(false);
return super.getChildElements();
}
public Iterator getChildElements(Name name)
{
log.trace("getChildElements: " + name);
- expandToDOM();
+ expandToDOM(false);
return super.getChildElements(name);
}
public NodeList getChildNodes()
{
log.trace("getChildNodes");
- expandToDOM();
+ expandToDOM(false);
return super.getChildNodes();
}
public Node getFirstChild()
{
log.trace("getFirstChild");
- expandToDOM();
+ expandToDOM(false);
return super.getFirstChild();
}
public Node getLastChild()
{
log.trace("getLastChild");
- expandToDOM();
+ expandToDOM(false);
return super.getLastChild();
}
public boolean hasChildNodes()
{
log.trace("hasChildNodes");
- expandToDOM();
+ expandToDOM(false);
return super.hasChildNodes();
}
@@ -325,7 +332,7 @@
return new SOAPBodyElementDoc(element);
}
- private void expandToDOM()
+ private void expandToDOM(boolean handleFault)
{
if (isDOMValid == false)
{
@@ -335,7 +342,7 @@
if (msgContext != null && UnifiedMetaData.isFinalRelease() == false)
{
Boolean allowExpand =
(Boolean)msgContext.getProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM);
- if (Boolean.TRUE.equals(allowExpand) == false)
+ if (handleFault == false && allowExpand == false)
throw new WSException("Expanding content element to DOM");
}
@@ -455,7 +462,7 @@
public Document extractContentAsDocument() throws SOAPException
{
log.trace("extractContentAsDocument");
- expandToDOM();
+ expandToDOM(false);
Iterator childElements = DOMUtils.getChildElements(this);
// zero child elements?
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -43,19 +43,19 @@
public void testHandlerChainOnWebServiceRef() throws Throwable
{
String resStr = invokeTestClient("testService1", "Kermit");
-
assertEquals("Kermit|LogOut|AuthOut|RoutOut|LogIn|AuthIn|RoutIn|endpoint|RoutOut|AuthOut|LogOut|RoutIn|AuthIn|LogIn",
resStr);
+
assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn",
resStr);
}
public void testHandlerChainNegative() throws Throwable
{
String resStr = invokeTestClient("testService2", "Kermit");
-
assertEquals("Kermit|LogIn|AuthIn|RoutIn|endpoint|RoutOut|AuthOut|LogOut",
resStr);
+
assertEquals("Kermit|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut",
resStr);
}
public void testHandlerChainOverride() throws Throwable
{
String resStr = invokeTestClient("testService3", "Kermit");
-
assertEquals("Kermit|LogOut|AuthOut|RoutOut|LogIn|AuthIn|RoutIn|endpoint|RoutOut|AuthOut|LogOut|RoutIn|AuthIn|LogIn",
resStr);
+
assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn",
resStr);
}
private String invokeTestClient(String testName, String reqStr) throws Throwable
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -66,7 +66,7 @@
bindingProvider.getBinding().setHandlerChain(handlerChain);
String resStr = port.echo("Kermit");
-
assertEquals("Kermit|LogOut|AuthOut|RoutOut|LogIn|AuthIn|RoutIn|endpoint|RoutOut|AuthOut|LogOut|RoutIn|AuthIn|LogIn",
resStr);
+
assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn",
resStr);
}
public void testHandlerChainOnServiceEndpointInterface() throws Exception
@@ -78,6 +78,6 @@
EndpointWithHandlerChain port =
(EndpointWithHandlerChain)service.getPort(EndpointWithHandlerChain.class);
String resStr = port.echo("Kermit");
-
assertEquals("Kermit|LogOut|AuthOut|RoutOut|LogIn|AuthIn|RoutIn|endpoint|RoutOut|AuthOut|LogOut|RoutIn|AuthIn|LogIn",
resStr);
+
assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn",
resStr);
}
}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerJAXBTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerJAXBTestCase.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerJAXBTestCase.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -63,13 +63,13 @@
expStr.append(":LogicalClientHandler");
expStr.append(":SOAP11ClientHandler");
expStr.append(":PortClientHandler");
+ expStr.append(":PortServerHandler");
+ expStr.append(":SOAP11ServerHandler");
expStr.append(":LogicalServerHandler");
+ expStr.append(":endpoint");
+ expStr.append(":LogicalServerHandler");
expStr.append(":SOAP11ServerHandler");
expStr.append(":PortServerHandler");
- expStr.append(":endpoint");
- expStr.append(":PortServerHandler");
- expStr.append(":SOAP11ServerHandler");
- expStr.append(":LogicalServerHandler");
expStr.append(":PortClientHandler");
expStr.append(":SOAP11ClientHandler");
expStr.append(":LogicalClientHandler");
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerSourceTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerSourceTestCase.java 2007-03-15
19:06:23 UTC (rev 2625)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/logicalhandler/LogicalHandlerSourceTestCase.java 2007-03-15
23:53:38 UTC (rev 2626)
@@ -63,13 +63,13 @@
expStr.append(":LogicalClientHandler");
expStr.append(":SOAP11ClientHandler");
expStr.append(":PortClientHandler");
+ expStr.append(":PortServerHandler");
+ expStr.append(":SOAP11ServerHandler");
expStr.append(":LogicalServerHandler");
+ expStr.append(":endpoint");
+ expStr.append(":LogicalServerHandler");
expStr.append(":SOAP11ServerHandler");
expStr.append(":PortServerHandler");
- expStr.append(":endpoint");
- expStr.append(":PortServerHandler");
- expStr.append(":SOAP11ServerHandler");
- expStr.append(":LogicalServerHandler");
expStr.append(":PortClientHandler");
expStr.append(":SOAP11ClientHandler");
expStr.append(":LogicalClientHandler");