Repository: cxf Updated Branches: refs/heads/master 4005dfa73 -> 2bbdbdab9
[CXF-6198] Adding property for getting SOAPFault for HTTP error code 400 Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2bbdbdab Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2bbdbdab Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2bbdbdab Branch: refs/heads/master Commit: 2bbdbdab92befd79e5083cf7a298f6a931a2e76e Parents: 4005dfa Author: Alessio Soldano <asold...@redhat.com> Authored: Wed Aug 26 09:38:46 2015 +0200 Committer: Alessio Soldano <asold...@redhat.com> Committed: Wed Aug 26 09:39:48 2015 +0200 ---------------------------------------------------------------------- .../apache/cxf/transport/http/HTTPConduit.java | 35 +++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/2bbdbdab/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java ---------------------------------------------------------------------- diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java index 1462a67..ea24009 100644 --- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java +++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java @@ -1554,28 +1554,39 @@ public abstract class HTTPConduit return responseCode == 500 && MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY, false); } - protected void handleResponseInternal() throws IOException { + protected int doProcessResponseCode() throws IOException { Exchange exchange = outMessage.getExchange(); - int responseCode = getResponseCode(); - if (responseCode == -1) { + int rc = getResponseCode(); + if (rc == -1) { LOG.warning("HTTP Response code appears to be corrupted"); } if (exchange != null) { - exchange.put(Message.RESPONSE_CODE, responseCode); + exchange.put(Message.RESPONSE_CODE, rc); } - // This property should be set in case the exceptions should not be handled here - // For example jax rs uses this - boolean noExceptions = MessageUtils.isTrue(outMessage.getContextualProperty( - "org.apache.cxf.transport.no_io_exceptions")); + // "org.apache.cxf.transport.no_io_exceptions" property should be set in case the exceptions + // should not be handled here; for example jax rs uses this - if (responseCode >= 400 && responseCode != 500 && !noExceptions) { - - if (responseCode == 404 || responseCode == 503) { + // "org.apache.cxf.transport.process_fault_on_http_400" property should be set in case a + // soap fault because of a HTTP 400 should be returned back to the client (SOAP 1.2 spec) + + if (rc >= 400 && rc != 500 + && !MessageUtils.isTrue(outMessage.getContextualProperty("org.apache.cxf.transport.no_io_exceptions")) + && (rc > 400 || !MessageUtils.isTrue(outMessage + .getContextualProperty("org.apache.cxf.transport.process_fault_on_http_400")))) { + + if (rc == 404 || rc == 503) { exchange.put("org.apache.cxf.transport.service_not_available", true); } - throw new HTTPException(responseCode, getResponseMessage(), url.toURL()); + + throw new HTTPException(rc, getResponseMessage(), url.toURL()); } + return rc; + } + + protected void handleResponseInternal() throws IOException { + Exchange exchange = outMessage.getExchange(); + int responseCode = doProcessResponseCode(); InputStream in = null; // oneway or decoupled twoway calls may expect HTTP 202 with no content