From 55c46014d42aa65a2e2621344924179554504fbd Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Wed, 20 May 2026 10:30:53 +0200 Subject: [PATCH] CAMEL-23526: camel-cxf - align Exchange header constant names with Camel naming convention (#23326) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CAMEL-23526: camel-cxf - align Exchange header constant names with Camel naming convention Rename the Exchange header string values in CxfConstants (camel-cxf-common, shared by camel-cxf and camel-cxfrs) from operationName / operationNamespace to CamelCxfOperationName / CamelCxfOperationNamespace. The Java field names (OPERATION_NAME, OPERATION_NAMESPACE) are unchanged so routes and code that reference the constants symbolically continue to work without changes; routes that set the headers by their literal string value must be updated. Updates the single test that set the headers by literal value, the CxfProducer javadoc and the component documentation references, adds a 4.21 upgrade-guide entry, and regenerates the component metadata, catalog, and endpoint DSL. Consistent with the same alignment applied in CAMEL-23508, CAMEL-23515 and CAMEL-23506. Reported by Claude Code on behalf of Andrea Cosentino Signed-off-by: Andrea Cosentino * CAMEL-23526: camel-cxf - update cxfrs SimpleConsumer literal operationName usages after header constant rename The previous commit renamed the CxfConstants.OPERATION_NAME header value to CamelCxfOperationName. The cxfrs SimpleConsumer dispatch idiom routes on the operation by its literal header name, so the test/itest routes that used the old literal value were no longer matched and failed: - camel-cxf-rest and camel-cxf-spring-rest CxfRsConsumerSimpleBindingTest / CxfRsConsumerSimpleBindingImplTest: simple("direct:${header.operationName}") updated to simple("direct:${header.CamelCxfOperationName}"). - camel-itest JettyRecipientListCxfIssueTest: literal "operationName" header updated to "CamelCxfOperationName". Also expands the camel-cxf 4.21 upgrade-guide entry with an explicit before/after for the documented cxfrs SimpleConsumer dispatch idiom, since the rename changes that public pattern for existing user routes. Reported by Claude Code on behalf of Andrea Cosentino Signed-off-by: Andrea Cosentino * CAMEL-23526: camel-cxf - document cross-transport propagation pattern for the renamed operation header After the constant rename, CxfConstants.OPERATION_NAME = "CamelCxfOperationName" is filtered by transport HeaderFilterStrategy (JmsHeaderFilterStrategy, HttpHeaderFilterStrategy, etc.) at every transport boundary, by design — Camel* headers are framework-internal and are not propagated over the wire. For routes that bridge an external transport (JMS, HTTP, ...) into a cxf: producer and select the SOAP operation from a sender-supplied header, the documented pattern is to carry the operation in a non-Camel-prefixed application header and map it to CamelCxfOperationName in the route between the transport `from` and the cxf: `to`. - Adds the carrier-header mapping to the JmsToCxfInOutTest route context (between the JMS `from` and the cxf: `to`) and aligns the test code to send the operation through the carrier header instead of CxfConstants.OPERATION_NAME. - Aligns JettyRecipientListCxfIssueTest with the same carrier-header convention for the cross-HTTP path. - Expands the 4.21 upgrade-guide entry with an explicit before/after example for the cross-transport bridge pattern, applicable to JMS, HTTP-based transports, and any other transport whose default HeaderFilterStrategy filters Camel*. Reported by Claude Code on behalf of Andrea Cosentino Signed-off-by: Andrea Cosentino --------- Signed-off-by: Andrea Cosentino --- .../apache/camel/catalog/components/cxf.json | 4 +- .../camel/catalog/components/cxfrs.json | 2 +- .../cxf/common/message/CxfConstants.java | 4 +- .../camel/component/cxf/jaxrs/cxfrs.json | 2 +- .../src/main/docs/cxfrs-component.adoc | 2 +- .../CxfRsConsumerSimpleBindingImplTest.java | 2 +- .../CxfRsConsumerSimpleBindingTest.java | 2 +- .../apache/camel/component/cxf/jaxws/cxf.json | 4 +- .../src/main/docs/cxf-component.adoc | 2 +- .../component/cxf/jaxws/CxfProducer.java | 2 +- .../CxfRsConsumerSimpleBindingImplTest.java | 2 +- .../CxfRsConsumerSimpleBindingTest.java | 2 +- .../cxf/CxfPayloadProviderRouterTest.java | 6 +- .../pages/camel-4x-upgrade-guide-4_14.adoc | 74 +++++++++++++++++++ .../dsl/CxfEndpointBuilderFactory.java | 12 +-- .../dsl/CxfRsEndpointBuilderFactory.java | 6 +- .../JettyRecipientListCxfIssueTest.java | 3 + .../itest/greeter/JmsToCxfInOutTest.java | 9 ++- .../greeter/JmsToCxfInOutTest-context.xml | 8 ++ 19 files changed, 119 insertions(+), 29 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json index d454b3460fe84..b057820062f29 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json @@ -34,8 +34,8 @@ "useGlobalSslContextParameters": { "index": 6, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." } }, "headers": { - "operationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, - "operationNamespace": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation namespace.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAMESPACE" }, + "CamelCxfOperationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, + "CamelCxfOperationNamespace": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation namespace.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAMESPACE" }, "CamelDestinationOverrideUrl": { "index": 2, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The destination override url", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#DESTINATION_OVERRIDE_URL" }, "ResponseContext": { "index": 3, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The response context", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#RESPONSE_CONTEXT" }, "CamelAuthentication": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "javax.security.auth.Subject", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The authentication", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#AUTHENTICATION" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json index 27ff27c9900f6..3b7ccbef31034 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxfrs.json @@ -33,7 +33,7 @@ "useGlobalSslContextParameters": { "index": 5, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." } }, "headers": { - "operationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, + "CamelCxfOperationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, "CamelAuthentication": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "javax.security.auth.Subject", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The authentication", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#AUTHENTICATION" }, "CamelHttpMethod": { "index": 2, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The http method to use", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#HTTP_METHOD" }, "CamelHttpPath": { "index": 3, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The http path", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#HTTP_PATH" }, diff --git a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/message/CxfConstants.java b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/message/CxfConstants.java index f7210e2ce1547..8a1b760b13e9f 100644 --- a/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/message/CxfConstants.java +++ b/components/camel-cxf/camel-cxf-common/src/main/java/org/apache/camel/component/cxf/common/message/CxfConstants.java @@ -46,9 +46,9 @@ public final class CxfConstants { public static final String PROTOCOL_NAME_RES = "res"; @Metadata(description = "The name of the operation.", javaType = "String") - public static final String OPERATION_NAME = "operationName"; + public static final String OPERATION_NAME = "CamelCxfOperationName"; @Metadata(description = "The operation namespace.", javaType = "String", applicableFor = SCHEME_CXF) - public static final String OPERATION_NAMESPACE = "operationNamespace"; + public static final String OPERATION_NAMESPACE = "CamelCxfOperationNamespace"; public static final String SPRING_CONTEXT_ENDPOINT = "bean:"; @Metadata(description = "The destination override url", javaType = "String", applicableFor = SCHEME_CXF) public static final String DESTINATION_OVERRIDE_URL = Exchange.DESTINATION_OVERRIDE_URL; diff --git a/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json b/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json index 27ff27c9900f6..3b7ccbef31034 100644 --- a/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json +++ b/components/camel-cxf/camel-cxf-rest/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxrs/cxfrs.json @@ -33,7 +33,7 @@ "useGlobalSslContextParameters": { "index": 5, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." } }, "headers": { - "operationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, + "CamelCxfOperationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, "CamelAuthentication": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "javax.security.auth.Subject", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The authentication", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#AUTHENTICATION" }, "CamelHttpMethod": { "index": 2, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The http method to use", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#HTTP_METHOD" }, "CamelHttpPath": { "index": 3, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The http path", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#HTTP_PATH" }, diff --git a/components/camel-cxf/camel-cxf-rest/src/main/docs/cxfrs-component.adoc b/components/camel-cxf/camel-cxf-rest/src/main/docs/cxfrs-component.adoc index 9042ad7e9111b..af191dd4bd5dd 100644 --- a/components/camel-cxf/camel-cxf-rest/src/main/docs/cxfrs-component.adoc +++ b/components/camel-cxf/camel-cxf-rest/src/main/docs/cxfrs-component.adoc @@ -190,7 +190,7 @@ Serviced by the following route: [source,java] -------------------------------------------------------------------------------------------- from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer") - .recipientList(simple("direct:${header.operationName}")); + .recipientList(simple("direct:${header.CamelCxfOperationName}")); from("direct:newCustomer") .log("Request: type=${header.type}, active=${header.active}, customerData=${body}"); diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java index becba92d8a579..3aceac0080c5a 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java @@ -68,7 +68,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() { from(CXF_RS_ENDPOINT_URI) - .recipientList(simple("direct:${header.operationName}")); + .recipientList(simple("direct:${header.CamelCxfOperationName}")); from("direct:getCustomer").process(new Processor() { @Override diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java index dd3473c9a2b62..c8c41757b0be6 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java @@ -85,7 +85,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from(CXF_RS_ENDPOINT_URI) - .recipientList(simple("direct:${header.operationName}")); + .recipientList(simple("direct:${header.CamelCxfOperationName}")); from("direct:getCustomer").process(new Processor() { public void process(Exchange exchange) throws Exception { diff --git a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json index d454b3460fe84..b057820062f29 100644 --- a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json +++ b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json @@ -34,8 +34,8 @@ "useGlobalSslContextParameters": { "index": 6, "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters." } }, "headers": { - "operationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, - "operationNamespace": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation namespace.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAMESPACE" }, + "CamelCxfOperationName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the operation.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAME" }, + "CamelCxfOperationNamespace": { "index": 1, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation namespace.", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#OPERATION_NAMESPACE" }, "CamelDestinationOverrideUrl": { "index": 2, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The destination override url", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#DESTINATION_OVERRIDE_URL" }, "ResponseContext": { "index": 3, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The response context", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#RESPONSE_CONTEXT" }, "CamelAuthentication": { "index": 4, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "javax.security.auth.Subject", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The authentication", "constantName": "org.apache.camel.component.cxf.common.message.CxfConstants#AUTHENTICATION" }, diff --git a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc index 3665755c97524..6e8979e2aa3b7 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc @@ -438,7 +438,7 @@ As an alternative, you can add a message header for it as demonstrated in https: You can configure the CXF endpoint with the Spring configuration file shown below, and you can also embed the endpoint into the `camelContext` tags. When you are invoking the service endpoint, you can set the -`operationName` and `operationNamespace` headers to explicitly state +`CamelCxfOperationName` and `CamelCxfOperationNamespace` headers to explicitly state which operation you are calling. [source,xml] diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java index 60ffb26646a31..63595d90da900 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java @@ -410,7 +410,7 @@ private Object[] getParams(CxfEndpoint endpoint, Exchange exchange) * null: *

*
    - *
  • Using the in message header "operationName".
  • + *
  • Using the in message header "CamelCxfOperationName".
  • *
  • Using the defaultOperationName option value from the CxfEndpoint.
  • *
  • Using the first operation which is find from the CxfEndpoint Operations list.
  • *
      diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java index becba92d8a579..3aceac0080c5a 100644 --- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java +++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java @@ -68,7 +68,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() { from(CXF_RS_ENDPOINT_URI) - .recipientList(simple("direct:${header.operationName}")); + .recipientList(simple("direct:${header.CamelCxfOperationName}")); from("direct:getCustomer").process(new Processor() { @Override diff --git a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java index 736ba3f15ef89..05b6139980bcf 100644 --- a/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java +++ b/components/camel-cxf/camel-cxf-spring-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java @@ -85,7 +85,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from(CXF_RS_ENDPOINT_URI) - .recipientList(simple("direct:${header.operationName}")); + .recipientList(simple("direct:${header.CamelCxfOperationName}")); from("direct:getCustomer").process(new Processor() { public void process(Exchange exchange) throws Exception { diff --git a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadProviderRouterTest.java b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadProviderRouterTest.java index 7b8ada2c688a9..870881e0b9ed6 100644 --- a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadProviderRouterTest.java +++ b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfPayloadProviderRouterTest.java @@ -22,6 +22,7 @@ import javax.xml.namespace.QName; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.cxf.common.message.CxfConstants; import org.apache.cxf.interceptor.Fault; import org.apache.cxf.message.Message; import org.apache.cxf.phase.AbstractPhaseInterceptor; @@ -68,8 +69,9 @@ protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from("cxf:bean:routerEndpoint?synchronous=true&dataFormat=PAYLOAD") - .setHeader("operationNamespace", constant("http://camel.apache.org/cxf/jaxws/dispatch")) - .setHeader("operationName", constant("Invoke")) + .setHeader(CxfConstants.OPERATION_NAMESPACE, + constant("http://camel.apache.org/cxf/jaxws/dispatch")) + .setHeader(CxfConstants.OPERATION_NAME, constant("Invoke")) .to("cxf:bean:serviceEndpoint?synchronous=true&dataFormat=PAYLOAD"); } }; diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc index 2d6206f483299..c9d86be01cd00 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc @@ -355,3 +355,77 @@ outbound regex. Headers starting with `Camel` / `camel` (case-insensitive), `bre component with the rest of the Camel component catalog. Routes that relied on receiving these header names on inbound SNS messages can supply a custom `headerFilterStrategy` to restore the previous behaviour. + +=== camel-cxf + +The Exchange header constants in `CxfConstants` (module `camel-cxf-common`, shared +by `camel-cxf` and `camel-cxfrs`) have been renamed to follow the Camel naming +convention used across the rest of the component catalog. The Java field names are +unchanged; only the header string values have changed: + +[options="header"] +|=== +| Constant | Previous value | New value +| `CxfConstants.OPERATION_NAME` | `operationName` | `CamelCxfOperationName` +| `CxfConstants.OPERATION_NAMESPACE` | `operationNamespace` | `CamelCxfOperationNamespace` +|=== + +Routes that reference the constant symbolically (for example +`setHeader(CxfConstants.OPERATION_NAME, ...)`) continue to work without changes. +Routes that set the header by its literal string value (for example +`setHeader("operationName", ...)`) must be updated to use the new value +(`setHeader("CamelCxfOperationName", ...)`). + +In particular, the documented `cxfrs` `SimpleConsumer` dispatch idiom that routes +on the operation name by its literal header name must be updated: + +[source,java] +---- +// before +from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer") + .recipientList(simple("direct:${header.operationName}")); + +// after +from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer") + .recipientList(simple("direct:${header.CamelCxfOperationName}")); +---- + +==== Behaviour change: cross-transport propagation of the operation header + +Because the renamed header value now begins with `Camel`, it is filtered by the +standard transport `HeaderFilterStrategy` (`JmsHeaderFilterStrategy`, +`HttpHeaderFilterStrategy`, etc.) when crossing a transport boundary, by design +— `Camel*` headers are framework-internal and are not propagated over the wire. + +Routes that bridge an external transport (JMS, HTTP, ...) into a `cxf:` producer +and select the SOAP operation from a header supplied by the sender must +therefore carry the operation in a non-`Camel`-prefixed application header and +map it to `CxfConstants.OPERATION_NAME` (`CamelCxfOperationName`) in the route +between the transport `from` and the `cxf:` `to`: + +[source,xml] +---- + + + + + + + + + + + + ${header.operationName} + + + + +---- + +The same pattern applies to HTTP-based bridges (`platform-http`/`jetty`/`netty +-http`/`http` -> `cxf:`) and any other transport whose default +`HeaderFilterStrategy` filters `Camel*` headers. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java index d7955cecfcfbb..ddad0322eb9e9 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java @@ -2653,10 +2653,10 @@ public static class CxfHeaderNameBuilder { * * Group: common * - * @return the name of the header {@code operationName}. + * @return the name of the header {@code CxfOperationName}. */ - public String operationName() { - return "operationName"; + public String cxfOperationName() { + return "CamelCxfOperationName"; } /** * The operation namespace. @@ -2665,10 +2665,10 @@ public String operationName() { * * Group: common * - * @return the name of the header {@code operationNamespace}. + * @return the name of the header {@code CxfOperationNamespace}. */ - public String operationNamespace() { - return "operationNamespace"; + public String cxfOperationNamespace() { + return "CamelCxfOperationNamespace"; } /** * The destination override url. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java index 6809d5d46be47..860bc11635c9d 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java @@ -2171,10 +2171,10 @@ public static class CxfRsHeaderNameBuilder { * * Group: common * - * @return the name of the header {@code operationName}. + * @return the name of the header {@code CxfOperationName}. */ - public String operationName() { - return "operationName"; + public String cxfOperationName() { + return "CamelCxfOperationName"; } /** * The authentication. diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JettyRecipientListCxfIssueTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JettyRecipientListCxfIssueTest.java index 842582b36b00a..c9fa542aabbb2 100644 --- a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JettyRecipientListCxfIssueTest.java +++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JettyRecipientListCxfIssueTest.java @@ -57,6 +57,9 @@ void testJettyRecipientListCxf() { // send a message to jetty Exchange out = template.request("http://0.0.0.0:{{RecipientListCxfTest.port3}}/myapp", exchange -> { + // Use the non-Camel-prefixed carrier header convention so it survives + // the HTTP transport boundary; the receiver maps it to the renamed + // CxfConstants.OPERATION_NAME value before any cxf: call. exchange.getIn().setHeader("operationName", "greetMe"); exchange.getIn().setBody(request); }); diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java index 585bc1060b713..73358bc6b1773 100644 --- a/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java +++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java @@ -17,7 +17,6 @@ package org.apache.camel.itest.greeter; import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.cxf.common.message.CxfConstants; import org.apache.camel.itest.utils.extensions.JmsServiceExtension; import org.apache.camel.test.AvailablePortFinder; import org.apache.camel.test.spring.junit5.CamelSpringTest; @@ -49,12 +48,16 @@ public class JmsToCxfInOutTest { void testJmsToCxfInOut() { assertNotNull(template); - String out = template.requestBodyAndHeader("jms:queue:bridge.cxf", "Willem", CxfConstants.OPERATION_NAME, "greetMe", + // The CXF operation header value now begins with "Camel" and is therefore + // filtered by JmsHeaderFilterStrategy at the transport boundary. Send the + // operation as a non-Camel-prefixed carrier header; the route maps it to + // CxfConstants.OPERATION_NAME between the JMS from and the cxf: to. + String out = template.requestBodyAndHeader("jms:queue:bridge.cxf", "Willem", "operationName", "greetMe", String.class); assertEquals("Hello Willem", out); // call for the other operation - out = template.requestBodyAndHeader("jms:queue:bridge.cxf", new Object[0], CxfConstants.OPERATION_NAME, "sayHi", + out = template.requestBodyAndHeader("jms:queue:bridge.cxf", new Object[0], "operationName", "sayHi", String.class); assertEquals("Bonjour", out); } diff --git a/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml b/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml index 72c51505e7a40..e392f778c3bbe 100644 --- a/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml +++ b/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml @@ -68,6 +68,14 @@ + + + ${header.operationName} +