You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ro...@apache.org on 2007/07/24 18:57:59 UTC
svn commit: r559103 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/core/controller/
src/org/apache/axis2/jaxws/handler/ test/org/apache/axis2/jaxws/handler/
test/org/apache/axis2/jaxws/sample/
Author: rott
Date: Tue Jul 24 09:57:57 2007
New Revision: 559103
URL: http://svn.apache.org/viewvc?view=rev&rev=559103
Log:
client app should get exception when client outbound handler throws exception on oneway invoke
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerInvokerUtils.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=559103&r1=559102&r2=559103
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Tue Jul 24 09:57:57 2007
@@ -154,7 +154,7 @@
*
* @param ic
*/
- public void invokeOneWay(InvocationContext ic) {
+ public void invokeOneWay(InvocationContext ic) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Invocation pattern: one-way");
}
@@ -181,6 +181,13 @@
if (success) {
prepareRequest(request);
doInvokeOneWay(request);
+ } else { // the outbound handler chain must have had a problem, and we've reversed directions
+ // check to see if problem is due to a handler throwing an exception. If so, throw it,
+ // even in this oneWay invoke.
+ Exception e = request.getCausedByException();
+ if (e != null) {
+ throw (Exception)e.getCause();
+ }
}
return;
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?view=diff&rev=559103&r1=559102&r2=559103
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Tue Jul 24 09:57:57 2007
@@ -277,11 +277,12 @@
} else {
callCloseHandlers(0, handlers.size() - 1, direction);
}
- if (savedException != null) {
- // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw any
- // other runtime exception --> No response" case.
- throw savedException;
- }
+ }
+ if (savedException != null) {
+ // we have a saved exception, throw it (JAX-WS 9.3.2.1 "Throw
+ // ProtocolException or any other runtime exception --> No
+ // response" case.
+ throw savedException;
}
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerInvokerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerInvokerUtils.java?view=diff&rev=559103&r1=559102&r2=559103
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerInvokerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerInvokerUtils.java Tue Jul 24 09:57:57 2007
@@ -18,6 +18,7 @@
*/
package org.apache.axis2.jaxws.handler;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.jaxws.message.Protocol;
import javax.xml.ws.handler.Handler;
@@ -116,11 +117,17 @@
}
} catch (RuntimeException re) {
/*
- * handler framework should only throw an exception here if
- * we are in the server outbound case. Make sure the message
- * context and message are transformed.
+ * handler framework will throw an exception here on client outbound flow and
+ * server outbound flow. Make sure the message context and message are transformed
+ * and the exception is saved on the message context.
*/
HandlerChainProcessor.convertToFaultMessage(mepMessageCtx, re, proto);
+ if (mepMessageCtx.getRequestMessageContext() != null) {
+ mepMessageCtx.getRequestMessageContext().setCausedByException(new AxisFault("", re));
+ }
+ if (mepMessageCtx.getResponseMessageContext() != null) {
+ mepMessageCtx.getResponseMessageContext().setCausedByException(new AxisFault("", re));
+ }
return false;
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java?view=diff&rev=559103&r1=559102&r2=559103
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java Tue Jul 24 09:57:57 2007
@@ -562,7 +562,6 @@
// reset result
result = "";
- // we want one false response:
soaphandler1_MessageResultDesired = ResultDesired.TRUE;
soaphandler1_FaultResultDesired = ResultDesired.TRUE;
soaphandler2_MessageResultDesired = ResultDesired.TRUE;
@@ -575,11 +574,16 @@
HandlerChainProcessor processor = new HandlerChainProcessor(handlers, Protocol.soap11);
MessageContext mc1 = new MessageContext();
mc1.setMEPContext(new MEPContext(mc1));
- processor.processChain(mc1.getMEPContext(),
- HandlerChainProcessor.Direction.IN,
- HandlerChainProcessor.MEP.REQUEST,
- false);
-
+ Exception e = null;
+ try {
+ processor.processChain(mc1.getMEPContext(),
+ HandlerChainProcessor.Direction.IN,
+ HandlerChainProcessor.MEP.REQUEST,
+ false);
+ } catch (ProtocolException pe) {
+ e = pe;
+ }
+ assertNotNull(e);
// no handleFault calls
assertEquals("S2m:S1m:L1m:L1c:S1c:S2c:", result);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?view=diff&rev=559103&r1=559102&r2=559103
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java Tue Jul 24 09:57:57 2007
@@ -85,12 +85,11 @@
TestLogger.logger.debug("test: " + getName());
AddNumbersHandlerService service = new AddNumbersHandlerService();
- AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
BindingProvider p = (BindingProvider)proxy;
- p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- axisEndpoint);
- int total = proxy.addNumbersHandler(10,10);
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ int total = proxy.addNumbersHandler(10, 10);
assertEquals("With handler manipulation, total should be 3 less than a proper sumation.", 17, total);
TestLogger.logger.debug("Total (after handler manipulation) = " + total);
@@ -285,8 +284,6 @@
}
}
-
- // TODO: disabled until handler support is more complete
public void testAddNumbersClientProtoAndLogicalHandler() {
try{
TestLogger.logger.debug("----------------------------------");
@@ -422,6 +419,38 @@
}
}
+ public void testOneWayWithException() {
+ try {
+ TestLogger.logger.debug("----------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ AddNumbersHandlerService service = new AddNumbersHandlerService();
+ AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+ BindingProvider p = (BindingProvider) proxy;
+
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ p.getRequestContext().put("myClientKey", "myClientVal");
+
+ List<Handler> handlers = p.getBinding().getHandlerChain();
+ if (handlers == null)
+ handlers = new ArrayList<Handler>();
+ handlers.add(new AddNumbersClientLogicalHandler());
+ handlers.add(new AddNumbersClientProtocolHandler());
+ p.getBinding().setHandlerChain(handlers);
+
+ BindingProvider bp = (BindingProvider) proxy;
+ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+ // value 99 will trigger exception from AddNumbersClientLogicalHandler
+ proxy.oneWayInt(99);
+ fail("Should have got an exception, but did not.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertEquals(e.getMessage(), "I don't like the value 99");
+ }
+ TestLogger.logger.debug("----------------------------------");
+ }
+
/*
* A callback implementation that can be used to collect the exceptions
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org