Author: ningjiang
Date: Mon Oct 22 08:42:26 2012
New Revision: 1400798
URL: http://svn.apache.org/viewvc?rev=1400798&view=rev
Log:
CXF-4583 Fixed the Empty soap response issue When the logical handler return
false processing the outbound message.
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java?rev=1400798&r1=1400797&r2=1400798&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
Mon Oct 22 08:42:26 2012
@@ -171,12 +171,13 @@ public class LogicalHandlerOutIntercepto
LogicalHandlerInInterceptor.class.getName());
observer.onMessage(responseMsg);
}
+ return;
}
} else {
// server side - abort
- //System.out.println("Logical handler server side
aborting");
+ // Even return false, also should try to set the
XMLStreamWriter using
+ // reader or domWriter, or the SOAPMessage's body maybe
empty.
}
- return;
}
if (origMessage != null) {
message.setContent(SOAPMessage.class, origMessage);
@@ -195,8 +196,6 @@ public class LogicalHandlerOutIntercepto
throw new Fault(e);
}
}
-
}
-
}
Modified:
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java?rev=1400798&r1=1400797&r2=1400798&view=diff
==============================================================================
---
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
(original)
+++
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
Mon Oct 22 08:42:26 2012
@@ -431,6 +431,21 @@ public class HandlerInvocationTest exten
}
@Test
+ public void testLogicHandlerHandleMessageReturnFalseServerOutbound()
throws PingException {
+ String[] expectedHandlers = {"server handler1 outbound stop",
"soapHandler4",
+ "soapHandler3", "handler2", "handler1",
"handler1"};
+
+ List<String> resp = handlerTest.pingWithArgs("server handler1 outbound
stop");
+
+ assertEquals(expectedHandlers.length, resp.size());
+
+ int i = 0;
+ for (String expected : expectedHandlers) {
+ assertEquals(expected, resp.get(i++));
+ }
+ }
+
+ @Test
public void testSOAPHandlerHandleMessageReturnsFalseServerInbound() throws
PingException {
String[] expectedHandlers = {"soapHandler4", "soapHandler3",
"soapHandler4"};
List<String> resp = handlerTest.pingWithArgs("soapHandler3 inbound
stop");
Modified:
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java?rev=1400798&r1=1400797&r2=1400798&view=diff
==============================================================================
---
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
(original)
+++
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
Mon Oct 22 08:42:26 2012
@@ -168,12 +168,33 @@ public class TestHandler<T extends Logic
return ret;
}
- private boolean handlePingMessage(boolean outbound, T ctx) {
+ private boolean checkServerOutBindStopHandler(boolean outbound, T ctx) {
+ if (outbound) {
+ LogicalMessage msg = ctx.getMessage();
+ Object obj = msg.getPayload(jaxbCtx);
+ if (obj instanceof PingResponse) {
+ // only check if we need call for the server response handler
false
+ PingResponse origResp = (PingResponse)obj;
+ for (String handler : origResp.getHandlersInfo()) {
+ if (handler.indexOf("server") == 0 &&
handler.indexOf(getHandlerId()) > 0
+ && handler.indexOf("stop") > 0) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ private boolean handlePingMessage(boolean outbound, T ctx) {
LogicalMessage msg = ctx.getMessage();
addHandlerId(msg, ctx, outbound);
- return getHandleMessageRet();
- }
+ if (checkServerOutBindStopHandler(outbound, ctx)) {
+ return false;
+ } else {
+ return getHandleMessageRet();
+ }
+ }
private void addHandlerId(LogicalMessage msg, T ctx, boolean outbound) {