You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jl...@apache.org on 2007/05/13 22:12:19 UTC
svn commit: r537652 - in /incubator/cxf/trunk:
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/
rt/frontend/jaxws/s...
Author: jliu
Date: Sun May 13 13:12:18 2007
New Revision: 537652
URL: http://svn.apache.org/viewvc?view=rev&rev=537652
Log:
* Support JAX-WS handlers throw ProtocolException/RuntimeException on server side inbound per spec.
* Mapping remote exception to SOAPFaultException on client side properly.
Added:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java (with props)
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java (with props)
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Sun May 13 13:12:18 2007
@@ -28,6 +28,8 @@
import java.util.concurrent.FutureTask;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFault;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
@@ -38,7 +40,12 @@
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.http.HTTPException;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.endpoint.Client;
@@ -126,8 +133,6 @@
} catch (WebServiceException wex) {
throw wex.fillInStackTrace();
} catch (Exception ex) {
- //TODO - map to SoapFaultException and HTTPException
-
for (Class<?> excls : method.getExceptionTypes()) {
if (excls.isInstance(ex)) {
throw ex.fillInStackTrace();
@@ -138,6 +143,25 @@
HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
exception.initCause(ex);
throw exception;
+ } else if (getBinding() instanceof SOAPBinding) {
+ SOAPFault soapFault = ((SOAPBinding)getBinding()).getSOAPFactory().createFault();
+
+ if (ex instanceof SoapFault) {
+ soapFault.setFaultString(((SoapFault)ex).getReason());
+ soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
+
+ Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getOrCreateDetail(),
+ true);
+ soapFault.addDetail().appendChild(nd);
+
+ } else {
+ soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
+ soapFault.setFaultString(ex.getMessage());
+ }
+
+ SOAPFaultException exception = new SOAPFaultException(soapFault);
+ exception.initCause(ex);
+ throw exception;
} else {
throw new WebServiceException(ex);
}
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java Sun May 13 13:12:18 2007
@@ -53,6 +53,7 @@
} else {
invoker.setInbound();
}
+ invoker.setRequestor(isRequestor(message));
if (message.getExchange().isOneWay()
|| ((isRequestor(message) && !isOutbound(message))
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java Sun May 13 13:12:18 2007
@@ -69,6 +69,7 @@
private final List<Handler> closeHandlers = new ArrayList<Handler>();
private boolean outbound;
+ private boolean isRequestor;
private boolean responseExpected = true;
private boolean faultExpected;
private boolean handlerProcessingAborted;
@@ -124,9 +125,14 @@
// objectCtx.setRequestorRole(requestor);
context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, isOutbound());
return invokeHandlerChain(logicalHandlers, context);
-
}
-
+
+ public boolean invokeLogicalHandlersHandleFault(boolean requestor, LogicalMessageContext context) {
+ // objectCtx.setRequestorRole(requestor);
+ context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, isOutbound());
+ return invokeHandlerChainHandleFault(logicalHandlers, context);
+ }
+
public boolean invokeProtocolHandlers(boolean requestor, MessageContext context) {
// WrappedMessageContext context = new WrappedMessageContext(message);
// bindingContext.put(ObjectMessageContext.REQUESTOR_ROLE_PROPERTY, requestor);
@@ -134,7 +140,14 @@
return invokeHandlerChain(protocolHandlers, context);
}
+ public boolean invokeProtocolHandlersHandleFault(boolean requestor, MessageContext context) {
+ // WrappedMessageContext context = new WrappedMessageContext(message);
+ // bindingContext.put(ObjectMessageContext.REQUESTOR_ROLE_PROPERTY, requestor);
+ context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, isOutbound());
+ return invokeHandlerChainHandleFault(protocolHandlers, context);
+ }
+
public void setResponseExpected(boolean expected) {
responseExpected = expected;
}
@@ -150,7 +163,18 @@
public boolean isInbound() {
return !outbound;
}
-
+
+ //We need HandlerChainInvoker behaves differently on client and server side. For
+ //client side, as we do not have a faultChain, we need to call handleFault and close
+ //on handlers directly.
+ protected boolean isRequestor() {
+ return isRequestor;
+ }
+
+ protected void setRequestor(boolean requestor) {
+ isRequestor = requestor;
+ }
+
public void setInbound() {
outbound = false;
}
@@ -218,11 +242,46 @@
handlers = reverseHandlerChain(handlers);
for (Handler h : handlers) {
if (closeHandlers.contains(h)) {
+ //System.out.println("===========invokeClose " + h.toString());
h.close(context);
}
}
}
+
+ private boolean invokeHandlerChainHandleFault(List<? extends Handler> handlerChain,
+ MessageContext ctx) {
+ if (handlerChain.isEmpty()) {
+ LOG.log(Level.FINEST, "no handlers registered");
+ return true;
+ }
+
+ if (isClosed()) {
+ return false;
+ }
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.log(Level.FINE, "invoking handlers, direction: " + (outbound ? "outbound" : "inbound"));
+ }
+ setMessageOutboundProperty(ctx);
+
+ if (!outbound) {
+ handlerChain = reverseHandlerChain(handlerChain);
+ }
+
+ boolean continueProcessing = true;
+
+ WebServiceContextImpl.setMessageContext(ctx);
+
+
+ continueProcessing = invokeHandleFault(handlerChain, ctx);
+
+ if (!continueProcessing) {
+ handlerProcessingAborted = true;
+ }
+ return continueProcessing;
+ }
+
private boolean invokeHandlerChain(List<? extends Handler> handlerChain,
MessageContext ctx) {
if (handlerChain.isEmpty()) {
@@ -269,6 +328,7 @@
if (invokeThisHandler(h)) {
closeHandlers.add(h);
markHandlerInvoked(h);
+ //System.out.println("===========handleFault " + h.toString());
continueProcessing = h.handleFault(ctx);
}
if (!continueProcessing) {
@@ -294,6 +354,7 @@
if (invokeThisHandler(h)) {
closeHandlers.add(h);
markHandlerInvoked(h);
+ //System.out.println("===========handlerMessage " + h.toString());
continueProcessing = h.handleMessage(ctx);
}
if (!continueProcessing) {
@@ -307,12 +368,16 @@
}
} catch (ProtocolException e) {
LOG.log(Level.FINE, "handleMessage raised exception", e);
- changeMessageDirection(ctx);
- if (responseExpected) {
- setFaultMessage(ctx, e);
- invokeReversedHandleFault(ctx);
- } else {
- invokeReversedClose();
+
+ //this is the client outbound
+ if (isRequestor()) {
+ changeMessageDirection(ctx);
+ if (responseExpected) {
+ setFaultMessage(ctx, e);
+ invokeReversedHandleFault(ctx);
+ } else {
+ invokeReversedClose();
+ }
}
continueProcessing = false;
@@ -320,15 +385,19 @@
throw e;
} catch (RuntimeException e) {
LOG.log(Level.WARNING, "HANDLER_RAISED_RUNTIME_EXCEPTION", e);
- changeMessageDirection(ctx);
+
+ if (isRequestor()) {
+ changeMessageDirection(ctx);
+ invokeReversedClose();
+ }
+
continueProcessing = false;
- invokeReversedClose();
-
+ setFault(e);
throw e;
}
return continueProcessing;
}
-
+
//When the message direction is reversed, if the message is not already a fault message then it is
//replaced with a fault message
private void setFaultMessage(MessageContext mc, Exception exception) {
@@ -387,6 +456,7 @@
int index = invokedHandlers.size() - 2;
while (index >= 0 && continueProcessing) {
Handler h = invokedHandlers.get(index);
+ //System.out.println("===========invokeReversedHandleFault " + h.toString());
if (h instanceof LogicalHandler) {
continueProcessing = h.handleFault(logicalMessageContext);
} else {
@@ -451,7 +521,7 @@
// when handler processing has been aborted, only invoked on
// previously invoked handlers
//
- if (handlerProcessingAborted) {
+ if (handlerProcessingAborted || faultRaised()) {
ret = invokedHandlers.contains(h);
}
if (ret && LOG.isLoggable(Level.FINE)) {
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java?view=auto&rev=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java Sun May 13 13:12:18 2007
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxws.handler.logical;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Binding;
+import javax.xml.ws.ProtocolException;
+
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.handler.AbstractJAXWSHandlerInterceptor;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+
+
+public class LogicalHandlerFaultOutInterceptor<T extends Message>
+ extends AbstractJAXWSHandlerInterceptor<T> {
+
+ public LogicalHandlerFaultOutInterceptor(Binding binding) {
+ super(binding);
+ setPhase(Phase.PRE_MARSHAL);
+ }
+
+ public void handleMessage(T message) throws Fault {
+ HandlerChainInvoker invoker = getInvoker(message);
+ if (invoker.getLogicalHandlers().isEmpty()) {
+ return;
+ }
+
+ try {
+
+ XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter(XMLUtils.newDocument());
+
+ // Replace stax writer with DomStreamWriter
+ message.setContent(XMLStreamWriter.class, writer);
+
+
+ message.getInterceptorChain().add(new LogicalHandlerFaultOutEndingInterceptor<T>(
+ getBinding(),
+ origWriter,
+ writer));
+ } catch (ParserConfigurationException e) {
+ throw new Fault(e);
+ }
+ }
+
+
+ private class LogicalHandlerFaultOutEndingInterceptor<X extends Message>
+ extends AbstractJAXWSHandlerInterceptor<X> {
+
+ XMLStreamWriter origWriter;
+ W3CDOMStreamWriter domWriter;
+
+ public LogicalHandlerFaultOutEndingInterceptor(Binding binding,
+ XMLStreamWriter o,
+ W3CDOMStreamWriter n) {
+ super(binding);
+ origWriter = o;
+ domWriter = n;
+
+ setPhase(Phase.POST_MARSHAL);
+ }
+
+ public void handleMessage(X message) throws Fault {
+ HandlerChainInvoker invoker = getInvoker(message);
+ LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
+ invoker.setLogicalMessageContext(lctx);
+ boolean requestor = isRequestor(message);
+
+ XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
+ SOAPMessage origMessage = null;
+ if (reader != null) {
+ origMessage = message.getContent(SOAPMessage.class);
+ message.setContent(XMLStreamReader.class, reader);
+ message.removeContent(SOAPMessage.class);
+ } else if (domWriter.getDocument().getDocumentElement() != null) {
+ Source source = new DOMSource(domWriter.getDocument());
+ XMLUtils.writeTo(domWriter.getDocument(), System.out);
+ message.setContent(Source.class, source);
+ message.setContent(XMLStreamReader.class,
+ StaxUtils.createXMLStreamReader(domWriter.getDocument()));
+ }
+
+ Fault f = (Fault)message.getContent(Exception.class);
+
+ Throwable cause = f.getCause();
+ if (cause instanceof ProtocolException) {
+
+ if (!invoker.invokeLogicalHandlersHandleFault(requestor, lctx)) {
+ //do nothing
+ }
+ } else {
+ // do nothing
+ }
+
+
+ if (origMessage != null) {
+ message.setContent(SOAPMessage.class, origMessage);
+ }
+
+ try {
+ reader = message.getContent(XMLStreamReader.class);
+ message.removeContent(XMLStreamReader.class);
+ if (reader != null) {
+ StaxUtils.copy(reader, origWriter);
+ } else if (domWriter.getDocument().getDocumentElement() != null) {
+ StaxUtils.copy(domWriter.getDocument(), origWriter);
+ }
+ message.setContent(XMLStreamWriter.class, origWriter);
+ } catch (XMLStreamException e) {
+ throw new Fault(e);
+ }
+ }
+
+ }
+
+
+}
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java?view=auto&rev=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java Sun May 13 13:12:18 2007
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxws.handler.soap;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptor;
+import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+
+
+public class SOAPHandlerFaultOutInterceptor extends
+ AbstractProtocolHandlerInterceptor<SoapMessage> implements
+ SoapInterceptor {
+ private static final SAAJOutInterceptor SAAJ_OUT = new SAAJOutInterceptor();
+
+ public SOAPHandlerFaultOutInterceptor(Binding binding) {
+ super(binding);
+ setPhase(Phase.PRE_PROTOCOL);
+ addAfter(MustUnderstandInterceptor.class.getName());
+ addAfter(StaxOutInterceptor.class.getName());
+ addAfter(SAAJOutInterceptor.class.getName());
+ }
+
+ public Set<URI> getRoles() {
+ Set<URI> roles = new HashSet<URI>();
+ // TODO
+ return roles;
+ }
+
+ public Set<QName> getUnderstoodHeaders() {
+ Set<QName> understood = new HashSet<QName>();
+ for (Handler h : getBinding().getHandlerChain()) {
+ if (h instanceof SOAPHandler) {
+ Set<QName> headers = CastUtils.cast(((SOAPHandler) h).getHeaders());
+ if (headers != null) {
+ understood.addAll(headers);
+ }
+ }
+ }
+ return understood;
+ }
+
+ public void handleMessage(SoapMessage message) {
+ if (getInvoker(message).getProtocolHandlers().isEmpty()) {
+ return;
+ }
+
+ if (getInvoker(message).isOutbound()) {
+
+ SAAJ_OUT.handleMessage(message);
+
+ message.getInterceptorChain().add(new AbstractSoapInterceptor() {
+ @Override
+ public String getPhase() {
+ return Phase.USER_PROTOCOL;
+ }
+ @Override
+ public String getId() {
+ return SOAPHandlerFaultOutInterceptor.class.getName() + ".ENDING";
+ }
+
+ public void handleMessage(SoapMessage message) throws Fault {
+ handleMessageInternal(message);
+ }
+ });
+ }
+ }
+
+ private void handleMessageInternal(SoapMessage message) {
+ MessageContext context = createProtocolMessageContext(message);
+ HandlerChainInvoker invoker = getInvoker(message);
+ invoker.setProtocolMessageContext(context);
+
+ Fault f = (Fault)message.getContent(Exception.class);
+
+ Throwable cause = f.getCause();
+ if (cause instanceof ProtocolException) {
+
+ if (!invoker.invokeProtocolHandlersHandleFault(isRequestor(message), context)) {
+ // handleAbort(message, context);
+ }
+ } else {
+ // do nothing
+ }
+
+ onCompletion(message);
+ }
+
+ @Override
+ protected MessageContext createProtocolMessageContext(Message message) {
+ return new SOAPMessageContextImpl(message);
+ }
+
+ public void handleFault(SoapMessage message) {
+ }
+}
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java Sun May 13 13:12:18 2007
@@ -157,18 +157,17 @@
}
} else {
// client side inbound - Normal handler message processing
- // stops,, but still continue the outbound interceptor chain, dispatch the message
+ // stops,, but the inbound interceptor chain still continues, dispatch the message
System.out.println("SOAP Handler handleMessage returns false on client inbound, aborting");
}
} else {
if (!getInvoker(message).isOutbound()) {
- // server side outbound
+ // server side inbound
message.getInterceptorChain().abort();
Endpoint e = message.getExchange().get(Endpoint.class);
Message responseMsg = e.getBinding().createMessage();
if (!message.getExchange().isOneWay()) {
- // server side inbound
message.getExchange().setOutMessage(responseMsg);
SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();
@@ -186,9 +185,9 @@
}
} else {
- // server side inbound - Normal handler message processing
- // stops, but still continue the inbound interceptor chain, dispatch the message
- System.out.println("SOAP Handler handleMessage returns false on server inbound, aborting");
+ // server side outbound - Normal handler message processing
+ // stops, but still continue the outbound interceptor chain, dispatch the message
+ System.out.println("SOAP Handler handleMessage returns false on server outbound, aborting");
}
}
}
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java Sun May 13 13:12:18 2007
@@ -34,8 +34,10 @@
import org.apache.cxf.jaxws.binding.http.HTTPBindingImpl;
import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
//import org.apache.cxf.jaxws.handler.StreamHandlerInterceptor;
+import org.apache.cxf.jaxws.handler.logical.LogicalHandlerFaultOutInterceptor;
import org.apache.cxf.jaxws.handler.logical.LogicalHandlerInInterceptor;
import org.apache.cxf.jaxws.handler.logical.LogicalHandlerOutInterceptor;
+import org.apache.cxf.jaxws.handler.soap.SOAPHandlerFaultOutInterceptor;
import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
@@ -67,11 +69,16 @@
} else {
// TODO: what for non soap bindings?
}
-
- List<Interceptor> fault = super.getOutFaultInterceptors();
- fault.add(new LogicalHandlerOutInterceptor(binding));
- if (soap != null) {
- fault.add(soap);
+
+ List<Interceptor> fault = super.getOutFaultInterceptors();
+
+ LogicalHandlerFaultOutInterceptor lh = new LogicalHandlerFaultOutInterceptor(binding);
+ fault.add(lh);
+ //fault.add(new LogicalHandlerOutInterceptor(binding));
+ if (getBinding() instanceof SoapBinding) {
+ //fault.add(soap);
+ SOAPHandlerFaultOutInterceptor sh = new SOAPHandlerFaultOutInterceptor(binding);
+ fault.add(sh);
}
List<Interceptor> in = super.getInInterceptors();
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java Sun May 13 13:12:18 2007
@@ -236,6 +236,7 @@
ProtocolException pe = new ProtocolException("banzai");
protocolHandlers[2].setException(pe);
+ invoker.setRequestor(true);
assertTrue(invoker.isOutbound());
boolean continueProcessing = true;
@@ -321,6 +322,7 @@
protocolHandlers[2].setException(pe);
protocolHandlers[0].setHandleFaultRet(false);
+ invoker.setRequestor(true);
assertTrue(invoker.isOutbound());
boolean continueProcessing = true;
@@ -521,6 +523,8 @@
ProtocolException pe = new ProtocolException("banzai");
logicalHandlers[2].setException(pe);
+
+ invoker.setRequestor(true);
//boolean continueProcessing = true;
try {
@@ -583,6 +587,7 @@
ProtocolException pe = new ProtocolException("banzai");
logicalHandlers[2].setException(pe);
invoker.setResponseExpected(false);
+ invoker.setRequestor(true);
//boolean continueProcessing = true;
try {
@@ -626,6 +631,7 @@
RuntimeException re = new RuntimeException("banzai");
logicalHandlers[1].setException(re);
+ invoker.setRequestor(true);
//boolean continueProcessing = true;
try {
@@ -690,7 +696,8 @@
// throw exception during handleFault processing
logicalHandlers[2].setException(pe);
logicalHandlers[1].setFaultException(pe2);
-
+ invoker.setRequestor(true);
+
boolean continueProcessing = false;
try {
continueProcessing = invoker.invokeLogicalHandlers(false, lmc);
@@ -734,6 +741,7 @@
// throw exception during handleFault processing
logicalHandlers[2].setException(pe);
logicalHandlers[1].setFaultException(re);
+ invoker.setRequestor(true);
boolean continueProcessing = false;
@@ -773,7 +781,8 @@
public void testHandleFaultReturnsTrue() {
ProtocolException pe = new ProtocolException("banzai");
logicalHandlers[2].setException(pe);
-
+ invoker.setRequestor(true);
+
logicalHandlers[0].setHandleFaultRet(true);
logicalHandlers[1].setHandleFaultRet(true);
logicalHandlers[2].setHandleFaultRet(true);
@@ -815,7 +824,8 @@
public void testHandleFaultReturnsFalse() {
ProtocolException pe = new ProtocolException("banzai");
logicalHandlers[3].setException(pe);
-
+ invoker.setRequestor(true);
+
logicalHandlers[0].setHandleFaultRet(true);
logicalHandlers[1].setHandleFaultRet(true);
logicalHandlers[2].setHandleFaultRet(false);
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java Sun May 13 13:12:18 2007
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.systest.handlers;
+
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -33,6 +34,7 @@
import javax.xml.ws.LogicalMessage;
import javax.xml.ws.ProtocolException;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.LogicalMessageContext;
@@ -127,7 +129,7 @@
}
@Test
- public void testSOAPHandlerHandleMessageReturnTrueClientSide() throws Exception {
+ public void testSOAPHandlerHandleMessageReturnTrueClient() throws Exception {
TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false);
TestSOAPHandler soapHandler1 = new TestSOAPHandler(false);
@@ -163,7 +165,7 @@
}
@Test
- public void testLogicalHandlerHandleMessageReturnFalseClientSide() throws Exception {
+ public void testLogicalHandlerHandleMessageReturnFalseClientOutBound() throws Exception {
final String clientHandlerMessage = "handler2 client side";
TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
@@ -203,10 +205,55 @@
//assertTrue("close must be called", handler1.isCloseInvoked());
//assertTrue("close must be called", handler2.isCloseInvoked());
}
+
+ @Test
+ public void testSOAPHandlerHandleMessageReturnFalseClientOutbound() throws Exception {
+ final String clientHandlerMessage = "client side";
+ TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
+ TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) {
+ public boolean handleMessage(LogicalMessageContext ctx) {
+ super.handleMessage(ctx);
+ try {
+ Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound) {
+ LogicalMessage msg = ctx.getMessage();
+ assertNotNull("logical message is null", msg);
+ JAXBContext jaxbCtx = JAXBContext.newInstance(PackageUtils
+ .getPackageName(PingOneWay.class));
+ PingResponse resp = new PingResponse();
+ resp.getHandlersInfo().add(clientHandlerMessage);
+
+ msg.setPayload(resp, jaxbCtx);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ return true;
+ }
+ };
+ TestSOAPHandler soapHandler1 = new TestSOAPHandler(false);
+ TestSOAPHandler soapHandler2 = new TestSOAPHandler<SOAPMessageContext>(false) {
+ public boolean handleMessage(SOAPMessageContext ctx) {
+ super.handleMessage(ctx);
+
+ return false;
+ }
+ };
+ addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2);
+ List<String> resp = handlerTest.ping();
+ assertEquals(clientHandlerMessage, resp.get(0));
+
+ assertEquals(2, handler1.getHandleMessageInvoked());
+ assertEquals(2, handler2.getHandleMessageInvoked());
+ assertEquals(1, soapHandler1.getHandleMessageInvoked());
+ assertEquals(1, soapHandler2.getHandleMessageInvoked());
+ }
@Test
- public void testLogicalHandlerHandleMessageReturnsFalseInboundServerSide() throws PingException {
+ public void testLogicalHandlerHandleMessageReturnsFalseServerInbound() throws PingException {
String[] expectedHandlers = {"soapHandler4", "soapHandler3", "handler2",
"handler2", "soapHandler3", "soapHandler4"};
@@ -221,7 +268,7 @@
}
@Test
- public void testSOAPHandlerHandleMessageReturnsFalseInboundServerSide() throws PingException {
+ public void testSOAPHandlerHandleMessageReturnsFalseServerInbound() throws PingException {
String[] expectedHandlers = {"soapHandler4", "soapHandler3",
"soapHandler3", "soapHandler4"};
List<String> resp = handlerTest.pingWithArgs("soapHandler3 inbound stop");
@@ -231,10 +278,9 @@
assertEquals(expected, resp.get(i++));
}
}
-
@Test
- public void testSOAPHandlerHandleMessageReturnsFalseOutboundServerSide() throws PingException {
+ public void testSOAPHandlerHandleMessageReturnsFalseServerOutbound() throws PingException {
String[] expectedHandlers = {"soapHandler3 outbound stop", "soapHandler4", "soapHandler3", "handler2",
"handler1", "handler1", "handler2", "soapHandler3"};
List<String> resp = handlerTest.pingWithArgs("soapHandler3 outbound stop");
@@ -245,10 +291,9 @@
assertEquals(expected, resp.get(i++));
}
}
-
- @Test
- public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientSide() throws Exception {
+ @Test
+ public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientOutbound() throws Exception {
final String clientHandlerMessage = "handler1 client side";
TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
@@ -275,20 +320,8 @@
assertEquals(1, handler2.getCloseInvoked());
}
- // TODO: commented out due to CXF-333
- @Test
- @Ignore
- public void testLogicalHandlerThrowsProtocolExceptionServerSide() throws PingException {
- try {
- handlerTest.pingWithArgs("handler2 inbound throw javax.xml.ws.ProtocolException");
- fail("did not get expected exception");
- } catch (ProtocolException e) {
- // happy now
- }
- }
-
@Test
- public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientSide() throws Exception {
+ public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientOutbound() throws Exception {
final String clientHandlerMessage = "handler1 client side";
TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
@@ -314,57 +347,52 @@
assertEquals(1, handler1.getCloseInvoked());
assertEquals(1, handler2.getCloseInvoked());
}
-
+
@Test
- public void testSOAPHandlerHandleMessageReturnFalseOutboundClientSide() throws Exception {
- final String clientHandlerMessage = "client side";
- TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
- TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false) {
- public boolean handleMessage(LogicalMessageContext ctx) {
- super.handleMessage(ctx);
- try {
- Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- if (outbound) {
- LogicalMessage msg = ctx.getMessage();
- assertNotNull("logical message is null", msg);
- JAXBContext jaxbCtx = JAXBContext.newInstance(PackageUtils
- .getPackageName(PingOneWay.class));
- PingResponse resp = new PingResponse();
- resp.getHandlersInfo().add(clientHandlerMessage);
-
- msg.setPayload(resp, jaxbCtx);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.toString());
- }
- return true;
- }
- };
- TestSOAPHandler soapHandler1 = new TestSOAPHandler(false);
- TestSOAPHandler soapHandler2 = new TestSOAPHandler<SOAPMessageContext>(false) {
- public boolean handleMessage(SOAPMessageContext ctx) {
- super.handleMessage(ctx);
-
- return false;
- }
- };
- addHandlersToChain((BindingProvider)handlerTest, handler1, handler2, soapHandler1, soapHandler2);
-
- List<String> resp = handlerTest.ping();
- assertEquals(clientHandlerMessage, resp.get(0));
-
- assertEquals(2, handler1.getHandleMessageInvoked());
- assertEquals(2, handler2.getHandleMessageInvoked());
- assertEquals(1, soapHandler1.getHandleMessageInvoked());
- assertEquals(1, soapHandler2.getHandleMessageInvoked());
+ public void testSOAPHandlerHandleMessageThrowsRuntimeExceptionServerInbound() throws PingException {
+ try {
+ handlerTest.pingWithArgs("soapHandler3 inbound throw RuntimeException");
+ fail("did not get expected exception");
+ } catch (RuntimeException e) {
+ //FIXME
+ //e.printStackTrace();
+/* assertTrue("Did not get expected exception message", e.getMessage()
+ .indexOf("HandleMessage throws runtime exception") > -1);*/
+ }
+ }
+
+ @Test
+ public void testSOAPHandlerHandleMessageThrowsProtocolExceptionServerInbound() throws PingException {
+ try {
+ handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException");
+ fail("did not get expected WebServiceException");
+ } catch (WebServiceException e) {
+ //FIXME
+/* ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos, true);
+ e.printStackTrace(ps);
+ assertTrue("Did not get expected exception message", baos.toString()
+ .indexOf("HandleMessage throws runtime exception") > -1);
+ assertTrue("Did not get expected javax.xml.ws.soap.SOAPFaultException", baos.toString()
+ .indexOf("javax.xml.ws.soap.SOAPFaultException") > -1);*/
+ }
}
@Test
@Ignore
+ public void testLogicalHandlerHandleMessageThrowsProtocolExceptionServerInbound()
+ throws PingException {
+ try {
+ handlerTest.pingWithArgs("handler2 inbound throw ProtocolException");
+ fail("did not get expected exception");
+ } catch (WebServiceException e) {
+ assertTrue(e.getMessage().indexOf("HandleMessage throws ProtocolException exception") >= 0);
+ }
+ }
+
+ @Test
+ @Ignore
public void testLogicalHandlerHandlerFaultServerSide() {
-
TestHandler<LogicalMessageContext> handler1 = new TestHandler<LogicalMessageContext>(false);
TestHandler<LogicalMessageContext> handler2 = new TestHandler<LogicalMessageContext>(false);
addHandlersToChain((BindingProvider)handlerTest, handler1, handler2);
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java Sun May 13 13:12:18 2007
@@ -103,35 +103,51 @@
String arg = ((PingWithArgs)payload).getHandlersCommand();
StringTokenizer strtok = new StringTokenizer(arg, " ");
- String hid = strtok.nextToken();
- String direction = strtok.nextToken();
- String command = strtok.nextToken();
+ String hid = "";
+ String direction = "";
+ String command = "";
+ if (strtok.countTokens() >= 3) {
+ hid = strtok.nextToken();
+ direction = strtok.nextToken();
+ command = strtok.nextToken();
+ }
- if (outbound) {
- return ret;
+ if (!getHandlerId().equals(hid)) {
+ return true;
}
-
- if (getHandlerId().equals(hid)
- && "inbound".equals(direction)) {
-
- if ("stop".equals(command)) {
+
+ if ("stop".equals(command)) {
+ if (!outbound && "inbound".equals(direction)) {
PingResponse resp = new PingResponse();
resp.getHandlersInfo().addAll(getHandlerInfoList(ctx));
msg.setPayload(resp, jaxbCtx);
ret = false;
- } else if ("throw".equals(command)) {
- throwException(strtok.nextToken());
+ } else if (outbound && "outbound".equals(direction)) {
+ ret = false;
+ }
+ } else if ("throw".equals(command)) {
+ String exceptionType = null;
+ if (strtok.hasMoreTokens()) {
+ exceptionType = strtok.nextToken();
}
+ if (exceptionType != null && !outbound && "inbound".equals(direction)) {
+ if ("RuntimeException".equals(exceptionType)) {
+ throw new RuntimeException("HandleMessage throws runtime exception");
+ } else if ("ProtocolException".equals(exceptionType)) {
+ throw new ProtocolException("HandleMessage throws ProtocolException exception");
+ }
+ } else if (exceptionType != null && outbound && "outbound".equals(direction)) {
+ if ("RuntimeException".equals(exceptionType)) {
+ throw new RuntimeException("HandleMessage throws RuntimeException exception");
+ } else if ("ProtocolException".equals(exceptionType)) {
+ throw new ProtocolException("HandleMessage throws ProtocolException exception");
+ }
+ }
+
}
}
- return ret;
- }
-
- private void throwException(String exType) {
- if (exType.contains("ProtocolException")) {
- throw new ProtocolException("from server handler");
- }
+ return ret;
}
private boolean handlePingMessage(boolean outbound, T ctx) {
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java?view=diff&rev=537652&r1=537651&r2=537652
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java Sun May 13 13:12:18 2007
@@ -25,7 +25,9 @@
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.ProtocolException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
@@ -108,7 +110,7 @@
getHandlerInfoList(ctx).add(getHandlerId());
}
}
- } catch (Exception e) {
+ } catch (SOAPException e) {
e.printStackTrace();
}
return continueProcessing;
@@ -151,13 +153,17 @@
String hid = "";
String direction = "";
String command = "";
- if (strtok.countTokens() == 3) {
+ if (strtok.countTokens() >= 3) {
hid = strtok.nextToken();
direction = strtok.nextToken();
command = strtok.nextToken();
}
- if (getHandlerId().equals(hid) && "stop".equals(command)) {
+ if (!getHandlerId().equals(hid)) {
+ return true;
+ }
+
+ if ("stop".equals(command)) {
if (!outbound && "inbound".equals(direction)) {
// remove the incoming request body.
Document doc = body.getOwnerDocument();
@@ -183,9 +189,28 @@
} else if (outbound && "outbound".equals(direction)) {
ret = false;
}
- }
+ } else if ("throw".equals(command)) {
+ String exceptionType = null;
+ if (strtok.hasMoreTokens()) {
+ exceptionType = strtok.nextToken();
+ }
+ if (exceptionType != null && !outbound && "inbound".equals(direction)) {
+ if ("RuntimeException".equals(exceptionType)) {
+ throw new RuntimeException("HandleMessage throws runtime exception");
+ } else if ("ProtocolException".equals(exceptionType)) {
+ throw new ProtocolException("HandleMessage throws runtime exception");
+ }
+ } else if (exceptionType != null && outbound && "outbound".equals(direction)) {
+ if ("RuntimeException".equals(exceptionType)) {
+ throw new RuntimeException("HandleMessage throws ProtocolException exception");
+ } else if ("ProtocolException".equals(exceptionType)) {
+ throw new ProtocolException("HandleMessage throws ProtocolException exception");
+ }
+ }
+
+ }
- } catch (Exception e) {
+ } catch (SOAPException e) {
e.printStackTrace();
}