You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ff...@apache.org on 2019/08/22 15:46:00 UTC
[camel] branch camel-2.x updated: [CAMEL-13898]ensure camel-cxf
consumer can propagate protocol headers from camel exchange headers when
throwing a soap fault
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.x by this push:
new fdfa5b4 [CAMEL-13898]ensure camel-cxf consumer can propagate protocol headers from camel exchange headers when throwing a soap fault
fdfa5b4 is described below
commit fdfa5b4c4c7ec301bf39dfc597bd6aaf6dcfeb21
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Aug 22 11:40:58 2019 -0400
[CAMEL-13898]ensure camel-cxf consumer can propagate protocol headers from camel exchange headers when throwing a soap fault
(cherry picked from commit e5bb417c5b1d06c9cee18443f0b30fbc808eae02)
---
.../apache/camel/component/cxf/CxfConsumer.java | 1 +
.../camel/component/cxf/DefaultCxfBinding.java | 41 ++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
index 9baf7d4..7fccf1f 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
@@ -317,6 +317,7 @@ public class CxfConsumer extends DefaultConsumer implements Suspendable {
CxfEndpoint endpoint = (CxfEndpoint)getEndpoint();
CxfBinding binding = endpoint.getCxfBinding();
+ ((DefaultCxfBinding)binding).populateCxfHeaderFromCamelExchangeBeforeCheckError(camelExchange, cxfExchange);
checkFailure(camelExchange, cxfExchange);
binding.populateCxfResponseFromExchange(camelExchange, cxfExchange);
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
index 4c7aa52..ee9eb54 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
@@ -314,6 +314,47 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware
}
}
}
+
+ /**
+ * This method is called by {@link CxfConsumer} to populate a CXF response protocol headers
+ * from a Camel exchange headers before CheckError.
+ * Ensure can send protocol headers back even error/exception thrown
+ */
+ public void populateCxfHeaderFromCamelExchangeBeforeCheckError(Exchange camelExchange,
+ org.apache.cxf.message.Exchange cxfExchange) {
+
+ if (cxfExchange.isOneWay()) {
+ return;
+ }
+
+ // create response context
+ Map<String, Object> responseContext = new HashMap<String, Object>();
+
+ org.apache.camel.Message response;
+ if (camelExchange.getPattern().isOutCapable()) {
+ if (camelExchange.hasOut()) {
+ response = camelExchange.getOut();
+ LOG.trace("Get the response from the out message");
+ } else { // Take the in message as a fall back
+ response = camelExchange.getIn();
+ LOG.trace("Get the response from the in message as a fallback");
+ }
+ } else {
+ response = camelExchange.getIn();
+ LOG.trace("Get the response from the in message");
+ }
+
+ // propagate response context
+ Map<String, Object> camelHeaders = response.getHeaders();
+ extractInvocationContextFromCamel(camelExchange, camelHeaders,
+ responseContext, Client.RESPONSE_CONTEXT);
+
+ propagateHeadersFromCamelToCxf(camelExchange, camelHeaders, cxfExchange,
+ responseContext);
+ if (cxfExchange.getOutMessage() != null) {
+ cxfExchange.getOutMessage().put(Message.PROTOCOL_HEADERS, responseContext.get(Message.PROTOCOL_HEADERS));
+ }
+ }
/**
* This method is called by {@link CxfConsumer} to populate a CXF response exchange