This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 79ad77e0b116 CAMEL-27389: camel-cxf - serve SOAP endpoints on the
platform-http server in Camel Main and Camel JBang (#30603)
79ad77e0b116 is described below
commit 79ad77e0b1165d9fdef0e4cd542a0ecf21d95a44
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 18:55:33 2026 +0100
CAMEL-27389: camel-cxf - serve SOAP endpoints on the platform-http server
in Camel Main and Camel JBang (#30603)
A new module, camel-cxf-platform-http, serves the SOAP services of cxf
consumers on the platform-http server (Vert.x) of Camel Main and Camel
JBang,
under the base path camel.cxf.path (default /services), like cxf.path on
Spring Boot and quarkus.cxf.path on Quarkus. The address of a cxf consumer
is
a path; a full URL fails at startup. Requests run on a worker thread through
a small servlet facade, and the request and response bodies are streamed.
The X-Forwarded-* headers are used only with camel.cxf.useXForwardedHeaders.
camel-cxf-soap registers ServerLifeCycleListener beans from the registry on
the bus of a consumer, which the module uses to mount and unmount a service.
Camel JBang always uses the module (no more Undertow download), and starts
the
HTTP server only when the first cxf consumer starts. Its auto-configure
script
uses reflection, as the old script did not compile in the launcher. In Camel
Main the module is opt-in. camel export maps camel.cxf.path to cxf.path and
quarkus.cxf.path, and a Main export adds the module and platform-http-main.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
bom/camel-bom/pom.xml | 5 +
catalog/camel-allcomponents/pom.xml | 5 +
.../org/apache/camel/catalog/docs.properties | 1 +
.../apache/camel/catalog/docs/cxf-component.adoc | 24 +
.../camel/catalog/docs/cxf-platform-http.adoc | 91 +++
.../org/apache/camel/catalog/others.properties | 1 +
.../camel/catalog/others/cxf-platform-http.json | 15 +
.../camel-cxf/camel-cxf-platform-http/pom.xml | 77 +++
.../services/org/apache/camel/other.properties | 7 +
.../src/generated/resources/cxf-platform-http.json | 15 +
.../src/main/docs/cxf-platform-http.adoc | 91 +++
.../http/CxfPlatformHttpContextServicePlugin.java | 42 ++
.../cxf/platform/http/CxfPlatformHttpHandler.java | 137 +++++
.../platform/http/CxfPlatformHttpTransport.java | 261 +++++++++
.../cxf/platform/http/VertxServletInputStream.java | 202 +++++++
.../platform/http/VertxServletOutputStream.java | 202 +++++++
.../cxf/platform/http/VertxServletRequest.java | 620 +++++++++++++++++++++
.../cxf/platform/http/VertxServletResponse.java | 330 +++++++++++
.../org.apache.camel.spi.ContextServicePlugin | 18 +
.../platform/http/CxfPlatformHttpAddressTest.java | 75 +++
.../http/CxfPlatformHttpForwardedTest.java | 73 +++
.../cxf/platform/http/CxfPlatformHttpPathTest.java | 66 +++
.../cxf/platform/http/CxfPlatformHttpTest.java | 162 ++++++
.../platform/http/CxfPlatformHttpTestSupport.java | 90 +++
.../cxf/platform/http/GreeterService.java | 36 ++
.../src/test/resources/junit-platform.properties | 19 +
.../src/test/resources/log4j2.properties | 35 ++
.../src/main/docs/cxf-component.adoc | 24 +
.../camel/component/cxf/jaxws/CxfEndpoint.java | 14 +
components/camel-cxf/pom.xml | 1 +
.../others/examples/json/cxf-platform-http.json | 1 +
docs/components/modules/others/nav.adoc | 1 +
.../modules/others/pages/cxf-platform-http.adoc | 1 +
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 20 +
.../dsl/jbang/run/export/CamelMainExporter.java | 9 +
.../camel/dsl/jbang/run/export/Exporter.java | 13 +
.../dsl/jbang/run/export/QuarkusExporter.java | 12 +
.../dsl/jbang/run/export/SpringBootExporter.java | 10 +
.../dsl/jbang/run/export/ProjectExporterTest.java | 49 ++
.../resources/auto-configure/camel-cxf-soap.java | 52 +-
parent/pom.xml | 5 +
.../apache/camel/maven/packaging/MojoHelper.java | 3 +-
42 files changed, 2891 insertions(+), 24 deletions(-)
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index b3be0b98b06e..393e8296265b 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -722,6 +722,11 @@
<artifactId>camel-cxf-common</artifactId>
<version>4.24.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <version>4.24.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf-rest</artifactId>
diff --git a/catalog/camel-allcomponents/pom.xml
b/catalog/camel-allcomponents/pom.xml
index ed9296bf215a..4ad62bf6e5ff 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -617,6 +617,11 @@
<artifactId>camel-cxf-common</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf-rest</artifactId>
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
index 079d22920dfd..258289d076ec 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
@@ -145,6 +145,7 @@ crypto-dataformat
csv-dataformat
customLoadBalancer-eip
cxf-component
+cxf-platform-http
cxfrs-component
cyberark-vault-component
dapr-component
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc
index 19220de80b96..fe18d35a0c96 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc
@@ -129,6 +129,30 @@ Using CXF with Spring Boot or Quarkus comes automatic
integrated with the embedd
See more details in the https://cxf.apache.org/docs/http-transport.html[CXF
Transport] documentation.
+=== Camel JBang and Camel Main: the platform-http server
+
+In Camel JBang (the Camel CLI), a cxf consumer is served on the platform-http
server, the same Vert.x HTTP server
+(port, bind address, TLS and authentication of `camel.server.*`) that serves
REST and platform-http routes. In a Camel
+Main application, add the `camel-cxf-platform-http` dependency (with
`camel-platform-http-main`) to do the same. See
+xref:others:cxf-platform-http.adoc[CXF Platform HTTP].
+
+The address of the consumer is then a path, served under `/services` (the
`camel.cxf.path` option), as on Spring Boot
+(`cxf.path`) and Quarkus (`quarkus.cxf.path`):
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: cxf:/orders
+ parameters:
+ wsdlURL: classpath:orders.wsdl
+ steps:
+ - to: direct:order
+----
+
+The service is at `\http://localhost:8080/services/orders`. An address with a
scheme and a host, such as
+`\http://0.0.0.0:9000/orders`, fails when the route starts. The cxf producer
still takes a full URL.
+
== WS-Security UsernameToken
The `wsSecurity` options set up a WS-Security UsernameToken without Java code.
The producer sends a UsernameToken in
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-platform-http.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-platform-http.adoc
new file mode 100644
index 000000000000..3d5d91a25b84
--- /dev/null
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-platform-http.adoc
@@ -0,0 +1,91 @@
+= CXF Platform HTTP Component
+:doctitle: CXF Platform HTTP
+:shortname: cxf-platform-http
+:artifactid: camel-cxf-platform-http
+:description: Serve the SOAP services of cxf consumers on the platform-http
server (Vert.x) in Camel Main and Camel JBang
+:since: 4.24
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The `camel-cxf-platform-http` module serves the SOAP services of the
xref:ROOT:cxf-component.adoc[cxf] consumers of a
+Camel Main or Camel JBang application on its platform-http server
(xref:platform-http-main.adoc[Platform HTTP Main]),
+the Vert.x HTTP server that also serves REST, platform-http routes, the health
checks and the dev consoles. The SOAP
+services use the same port, bind address, TLS and authentication
(`camel.server.*`), and no HTTP server of their own
+(such as Jetty or Undertow) is needed.
+
+It works the way the CXF extension of Quarkus serves SOAP services on the
Vert.x server of Quarkus.
+
+Camel JBang uses it for every cxf consumer. In a Camel Main application, add
the dependency, with
+`camel-platform-http-main`, and turn on the HTTP server:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.port=8080
+----
+
+On Spring Boot and Quarkus, use their own transport instead:
`camel-cxf-soap-starter` serves the services through the
+CXF servlet under `cxf.path`, and the CXF extension of Quarkus under
`quarkus.cxf.path` (both default `/services`).
+
+== The address of a service
+
+The address of a cxf consumer is a path, such as `/orders`. The service is
served under a base path, default
+`/services`, the same as `cxf.path` on Spring Boot and `quarkus.cxf.path` on
Quarkus, so the URL of the service stays the
+same after a `camel export`:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: cxf:/orders
+ parameters:
+ wsdlURL: classpath:orders.wsdl
+ dataFormat: PAYLOAD
+ steps:
+ - to: direct:order
+----
+
+With the default port, the service is at
`\http://localhost:8080/services/orders`, and its WSDL at
+`\http://localhost:8080/services/orders?wsdl`. With `camel.server.path` set,
it is under that path too.
+
+An address with a scheme and a host, such as `\http://0.0.0.0:9000/orders`,
fails when the route starts, as the host and
+port are those of the platform-http server. The cxf producer (a SOAP client)
is not changed and still takes a full URL.
+
+Each request runs on a worker thread, as CXF is blocking. The request and the
response are streamed, so a large message
+or an MTOM attachment is not held in memory as a whole.
+
+== Options
+
+[width="100%",cols="2,1,5",options="header"]
+|===
+| Option | Default | Description
+| `camel.cxf.path` | `/services` | The path that the services are served under
on the platform-http server. A service with
+address `/orders` is at `<path>/orders`. `camel export` sets `cxf.path`
(Spring Boot) or `quarkus.cxf.path` (Quarkus)
+to it.
+| `camel.cxf.useXForwardedHeaders` | `false` | Whether the scheme, host and
port of the request URL come from the
+`X-Forwarded-Proto`, `X-Forwarded-Host` and `X-Forwarded-Port` headers, and
the client address from `X-Forwarded-For`.
+The request URL is the base of the address that the WSDL at `?wsdl` gives.
Turn it on only behind a proxy that sets
+these headers, as a client can set them too.
+|===
+
+The address in the WSDL comes from the URL of the request, unless the endpoint
has the `publishedEndpointUrl` option.
+
+== Security
+
+The authentication of the platform-http server
(`camel.server.authenticationEnabled`) applies to the SOAP services too;
+the name of the user is the principal of the request, which CXF gives the
service. Message security, such as
+WS-Security, is configured on the cxf endpoint as before.
+
+HTTP sessions are not supported, and the roles of the user are not known to
CXF (`isUserInRole` is false).
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
index 76c4ed053c30..a6a0e8679c5d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
@@ -8,6 +8,7 @@ cloudevents
cluster
componentdsl
console
+cxf-platform-http
dataweave
debug
diagram
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/cxf-platform-http.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/cxf-platform-http.json
new file mode 100644
index 000000000000..58564e09a7ef
--- /dev/null
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/cxf-platform-http.json
@@ -0,0 +1,15 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "cxf-platform-http",
+ "title": "CXF Platform HTTP",
+ "description": "Serve the SOAP services of cxf consumers on the
platform-http server (Vert.x) in Camel Main and Camel JBang",
+ "deprecated": false,
+ "firstVersion": "4.24.0",
+ "label": "soap,webservice,http",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-cxf-platform-http",
+ "version": "4.24.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-cxf/camel-cxf-platform-http/pom.xml
b/components/camel-cxf/camel-cxf-platform-http/pom.xml
new file mode 100644
index 000000000000..cb71f601be1c
--- /dev/null
+++ b/components/camel-cxf/camel-cxf-platform-http/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-parent</artifactId>
+ <version>4.24.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Camel :: CXF :: Platform HTTP</name>
+ <description>Serve the SOAP services of cxf consumers on the platform-http
server (Vert.x) in Camel Main and Camel JBang</description>
+
+ <properties>
+ <firstVersion>4.24.0</firstVersion>
+ <label>soap,webservice,http</label>
+ <title>CXF Platform HTTP</title>
+ <supportLevel>Preview</supportLevel>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-soap</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-platform-http-vertx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ <version>${jakarta-servlet-api-version}</version>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-junit6</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>${cxf-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/META-INF/services/org/apache/camel/other.properties
b/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 000000000000..fdf083451c93
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=cxf-platform-http
+groupId=org.apache.camel
+artifactId=camel-cxf-platform-http
+version=4.24.0-SNAPSHOT
+projectName=Camel :: CXF :: Platform HTTP
+projectDescription=Serve the SOAP services of cxf consumers on the
platform-http server (Vert.x) in Camel Main and Camel JBang
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/cxf-platform-http.json
b/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/cxf-platform-http.json
new file mode 100644
index 000000000000..58564e09a7ef
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/generated/resources/cxf-platform-http.json
@@ -0,0 +1,15 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "cxf-platform-http",
+ "title": "CXF Platform HTTP",
+ "description": "Serve the SOAP services of cxf consumers on the
platform-http server (Vert.x) in Camel Main and Camel JBang",
+ "deprecated": false,
+ "firstVersion": "4.24.0",
+ "label": "soap,webservice,http",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-cxf-platform-http",
+ "version": "4.24.0-SNAPSHOT"
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/docs/cxf-platform-http.adoc
b/components/camel-cxf/camel-cxf-platform-http/src/main/docs/cxf-platform-http.adoc
new file mode 100644
index 000000000000..3d5d91a25b84
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/docs/cxf-platform-http.adoc
@@ -0,0 +1,91 @@
+= CXF Platform HTTP Component
+:doctitle: CXF Platform HTTP
+:shortname: cxf-platform-http
+:artifactid: camel-cxf-platform-http
+:description: Serve the SOAP services of cxf consumers on the platform-http
server (Vert.x) in Camel Main and Camel JBang
+:since: 4.24
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The `camel-cxf-platform-http` module serves the SOAP services of the
xref:ROOT:cxf-component.adoc[cxf] consumers of a
+Camel Main or Camel JBang application on its platform-http server
(xref:platform-http-main.adoc[Platform HTTP Main]),
+the Vert.x HTTP server that also serves REST, platform-http routes, the health
checks and the dev consoles. The SOAP
+services use the same port, bind address, TLS and authentication
(`camel.server.*`), and no HTTP server of their own
+(such as Jetty or Undertow) is needed.
+
+It works the way the CXF extension of Quarkus serves SOAP services on the
Vert.x server of Quarkus.
+
+Camel JBang uses it for every cxf consumer. In a Camel Main application, add
the dependency, with
+`camel-platform-http-main`, and turn on the HTTP server:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.port=8080
+----
+
+On Spring Boot and Quarkus, use their own transport instead:
`camel-cxf-soap-starter` serves the services through the
+CXF servlet under `cxf.path`, and the CXF extension of Quarkus under
`quarkus.cxf.path` (both default `/services`).
+
+== The address of a service
+
+The address of a cxf consumer is a path, such as `/orders`. The service is
served under a base path, default
+`/services`, the same as `cxf.path` on Spring Boot and `quarkus.cxf.path` on
Quarkus, so the URL of the service stays the
+same after a `camel export`:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: cxf:/orders
+ parameters:
+ wsdlURL: classpath:orders.wsdl
+ dataFormat: PAYLOAD
+ steps:
+ - to: direct:order
+----
+
+With the default port, the service is at
`\http://localhost:8080/services/orders`, and its WSDL at
+`\http://localhost:8080/services/orders?wsdl`. With `camel.server.path` set,
it is under that path too.
+
+An address with a scheme and a host, such as `\http://0.0.0.0:9000/orders`,
fails when the route starts, as the host and
+port are those of the platform-http server. The cxf producer (a SOAP client)
is not changed and still takes a full URL.
+
+Each request runs on a worker thread, as CXF is blocking. The request and the
response are streamed, so a large message
+or an MTOM attachment is not held in memory as a whole.
+
+== Options
+
+[width="100%",cols="2,1,5",options="header"]
+|===
+| Option | Default | Description
+| `camel.cxf.path` | `/services` | The path that the services are served under
on the platform-http server. A service with
+address `/orders` is at `<path>/orders`. `camel export` sets `cxf.path`
(Spring Boot) or `quarkus.cxf.path` (Quarkus)
+to it.
+| `camel.cxf.useXForwardedHeaders` | `false` | Whether the scheme, host and
port of the request URL come from the
+`X-Forwarded-Proto`, `X-Forwarded-Host` and `X-Forwarded-Port` headers, and
the client address from `X-Forwarded-For`.
+The request URL is the base of the address that the WSDL at `?wsdl` gives.
Turn it on only behind a proxy that sets
+these headers, as a client can set them too.
+|===
+
+The address in the WSDL comes from the URL of the request, unless the endpoint
has the `publishedEndpointUrl` option.
+
+== Security
+
+The authentication of the platform-http server
(`camel.server.authenticationEnabled`) applies to the SOAP services too;
+the name of the user is the principal of the request, which CXF gives the
service. Message security, such as
+WS-Security, is configured on the cxf endpoint as before.
+
+HTTP sessions are not supported, and the roles of the user are not known to
CXF (`isUserInRole` is false).
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpContextServicePlugin.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpContextServicePlugin.java
new file mode 100644
index 000000000000..1f1fd88ebd81
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpContextServicePlugin.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ContextServicePlugin;
+
+/**
+ * Switches camel-cxf-platform-http on in a {@link CamelContext}, found on the
classpath ({@code META-INF/services}):
+ * binds the {@link CxfPlatformHttpTransport}, so the cxf consumers of the
context are served on its platform-http
+ * server. The transport reads its options, {@code camel.cxf.path} (default
{@code /services}) and
+ * {@code camel.cxf.useXForwardedHeaders} (default false), when the first
service starts.
+ * <p/>
+ * Camel JBang binds the transport itself (with a starter of its platform-http
server); then the plugin does nothing.
+ */
+public class CxfPlatformHttpContextServicePlugin implements
ContextServicePlugin {
+
+ @Override
+ public void load(CamelContext camelContext) {
+ if
(camelContext.getRegistry().lookupByNameAndType(CxfPlatformHttpTransport.BEAN_NAME,
+ CxfPlatformHttpTransport.class)
+ == null) {
+ CxfPlatformHttpTransport transport = new
CxfPlatformHttpTransport();
+ transport.setCamelContext(camelContext);
+
camelContext.getRegistry().bind(CxfPlatformHttpTransport.BEAN_NAME, transport);
+ }
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpHandler.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpHandler.java
new file mode 100644
index 000000000000..b5ca3070176a
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpHandler.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.util.Collections;
+import java.util.Enumeration;
+
+import jakarta.servlet.ServletConfig;
+import jakarta.servlet.ServletContext;
+
+import io.vertx.core.Context;
+import io.vertx.core.Handler;
+import io.vertx.ext.web.RoutingContext;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.servlet.BaseUrlHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Gives the requests of a path on the platform-http server to the CXF
destination of a cxf consumer, on a worker
+ * thread, as CXF is blocking. The request body is streamed to CXF, and the
response is streamed back.
+ */
+final class CxfPlatformHttpHandler implements Handler<RoutingContext> {
+
+ /**
+ * The request attribute with the address of the endpoint for this
request, as the CXF servlet sets it.
+ */
+ static final String ENDPOINT_ADDRESS =
"org.apache.cxf.transport.endpoint.address";
+
+ private static final Logger LOG =
LoggerFactory.getLogger(CxfPlatformHttpHandler.class);
+ private static final ServletConfig SERVLET_CONFIG = new
PlatformHttpServletConfig();
+
+ private final AbstractHTTPDestination destination;
+ private final String servletPath;
+ private final boolean useXForwardedHeaders;
+
+ CxfPlatformHttpHandler(AbstractHTTPDestination destination, String
servletPath, boolean useXForwardedHeaders) {
+ this.destination = destination;
+ this.servletPath = servletPath;
+ this.useXForwardedHeaders = useXForwardedHeaders;
+ }
+
+ @Override
+ public void handle(RoutingContext rc) {
+ // on the event loop: the stream reads the (paused) request on demand,
from the worker thread
+ Context context = rc.vertx().getOrCreateContext();
+ VertxServletInputStream in = new VertxServletInputStream(context,
rc.request());
+ VertxServletResponse response = new VertxServletResponse(context,
rc.response());
+ context.executeBlocking(() -> {
+ process(rc, in, response);
+ return null;
+ }, false).onFailure(e -> {
+ LOG.warn("Error serving the cxf consumer at {}: {}",
rc.request().path(), e.getMessage(), e);
+ response.fail();
+ });
+ }
+
+ private void process(RoutingContext rc, VertxServletInputStream in,
VertxServletResponse response)
+ throws Exception {
+ VertxServletRequest request = new VertxServletRequest(
+ rc, in, contextPath(rc), servletPath, destination.getPath(),
useXForwardedHeaders);
+ Bus bus = destination.getBus();
+ Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
+ ClassLoaderUtils.ClassLoaderHolder origLoader = null;
+ try {
+ ClassLoader loader = bus != null ?
bus.getExtension(ClassLoader.class) : null;
+ if (loader != null) {
+ origLoader =
ClassLoaderUtils.setThreadContextClassloader(loader);
+ }
+ if (destination.getMessageObserver() == null) {
+ // the consumer is stopping
+ response.sendError(503, "The service is not available");
+ } else {
+ // the address of the endpoint for this request, from its URL,
as the CXF servlet does it
+ String address = destination.getEndpointInfo().getAddress();
+ if (address != null && !address.startsWith("http")) {
+ request.setAttribute(ENDPOINT_ADDRESS,
BaseUrlHelper.getBaseURL(request) + address);
+ }
+ destination.invoke(SERVLET_CONFIG,
SERVLET_CONFIG.getServletContext(), request, response);
+ }
+ response.close();
+ } finally {
+ BusFactory.setThreadDefaultBus(origBus);
+ if (origLoader != null) {
+ origLoader.reset();
+ }
+ }
+ }
+
+ private static String contextPath(RoutingContext rc) {
+ // the path that the router of the platform-http server is mounted at
(camel.server.path)
+ String mount = rc.mountPoint();
+ return CxfPlatformHttpTransport.normalizePath(mount);
+ }
+
+ /**
+ * The CXF destination reads no init parameters and needs no servlet
context.
+ */
+ private static final class PlatformHttpServletConfig implements
ServletConfig {
+ @Override
+ public String getServletName() {
+ return "camel-cxf-platform-http";
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ @Override
+ public String getInitParameter(String name) {
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getInitParameterNames() {
+ return Collections.emptyEnumeration();
+ }
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTransport.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTransport.java
new file mode 100644
index 000000000000..7ab04f5d6a9b
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTransport.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import io.vertx.ext.web.Route;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
+import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.HttpDestinationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Serves the SOAP services of cxf consumers on the platform-http server
(Vert.x) of the CamelContext.
+ * <p/>
+ * The address of a cxf consumer is a path, such as {@code cxf:/orders}. For
such an address CXF creates a servlet
+ * destination, as it does for a service behind the CXF servlet of Spring
Boot. When the CXF server of the consumer
+ * starts, this listener adds a route for {@code <path><address>} (path
default {@code /services}) on the router of the
+ * platform-http server, which gives each request to the destination on a
worker thread. When the server stops, the
+ * route is removed.
+ * <p/>
+ * An address with a scheme and a host (such as {@code
http://0.0.0.0:9000/orders}) would need a server of its own; CXF
+ * asks the {@link HttpDestinationFactory} for it, and this one fails with a
message that says to use a path.
+ * <p/>
+ * camel-cxf-soap registers the beans of the registry of these two types on
the bus of each cxf consumer.
+ */
+public class CxfPlatformHttpTransport implements HttpDestinationFactory,
ServerLifeCycleListener, CamelContextAware {
+
+ /**
+ * The name of the bean of this transport in the registry.
+ */
+ public static final String BEAN_NAME = "camelCxfPlatformHttpTransport";
+ /**
+ * The default path that the services are served under, the same as {@code
cxf.path} of CXF on Spring Boot and
+ * {@code quarkus.cxf.path} of Quarkus CXF.
+ */
+ public static final String DEFAULT_PATH = "/services";
+ /**
+ * The property with the path that the services are served under on the
platform-http server.
+ */
+ public static final String PATH_PROPERTY = "camel.cxf.path";
+ /**
+ * The property that says whether the request URL comes from the
X-Forwarded headers (behind a proxy).
+ */
+ public static final String USE_X_FORWARDED_HEADERS_PROPERTY =
"camel.cxf.useXForwardedHeaders";
+
+ private static final Logger LOG =
LoggerFactory.getLogger(CxfPlatformHttpTransport.class);
+
+ private final Map<String, Mounted> mounted = new ConcurrentHashMap<>();
+ private CamelContext camelContext;
+ private String path;
+ private Boolean useXForwardedHeaders;
+ private Runnable httpServerStarter;
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ public String getPath() {
+ return path != null ? path : DEFAULT_PATH;
+ }
+
+ /**
+ * The path that the services are served under on the platform-http server
(default {@code /services}, or the
+ * {@code camel.cxf.path} property). A service with address {@code
/orders} is at {@code <path>/orders}.
+ */
+ public void setPath(String path) {
+ this.path = normalizePath(path);
+ }
+
+ public boolean isUseXForwardedHeaders() {
+ return useXForwardedHeaders != null && useXForwardedHeaders;
+ }
+
+ /**
+ * Whether the scheme, host and port of the request URL come from the
{@code X-Forwarded-Proto},
+ * {@code X-Forwarded-Host} and {@code X-Forwarded-Port} headers, and the
client address from
+ * {@code X-Forwarded-For}. The request URL is the base of the address
that the WSDL at {@code ?wsdl} gives (unless
+ * the endpoint has a {@code publishedEndpointUrl}). Turn it on only
behind a proxy that sets these headers, as a
+ * client can set them too. Default false, or the {@code
camel.cxf.useXForwardedHeaders} property.
+ */
+ public void setUseXForwardedHeaders(boolean useXForwardedHeaders) {
+ this.useXForwardedHeaders = useXForwardedHeaders;
+ }
+
+ public Runnable getHttpServerStarter() {
+ return httpServerStarter;
+ }
+
+ /**
+ * Called when the first service is served, to start the platform-http
server when it is not running yet (Camel
+ * JBang starts it this way, only when a route has a cxf consumer).
+ */
+ public void setHttpServerStarter(Runnable httpServerStarter) {
+ this.httpServerStarter = httpServerStarter;
+ }
+
+ /**
+ * The paths of the services that are served, under {@link #getPath()}.
+ */
+ public Set<String> getServedPaths() {
+ return Set.copyOf(mounted.keySet());
+ }
+
+ @Override
+ public AbstractHTTPDestination createDestination(EndpointInfo
endpointInfo, Bus bus, DestinationRegistry registry)
+ throws IOException {
+ // CXF asks for a destination of its own only for an address with a
scheme and a host (or without an address)
+ String address = endpointInfo.getAddress();
+ String path = getPath();
+ throw new IllegalArgumentException(
+ "The address of a cxf consumer must be a path, such as
cxf:/orders, but was: " + address
+ + ". The service is served on the
platform-http server under " + path
+ + " (" + path + "/orders); its host
and port are those of the platform-http"
+ + " server (camel.server.host and
camel.server.port).");
+ }
+
+ @Override
+ public void startServer(Server server) {
+ Destination destination = server.getDestination();
+ if (!(destination instanceof AbstractHTTPDestination httpDestination))
{
+ return;
+ }
+ String servicePath = servicePath(httpDestination.getPath());
+ if (servicePath == null) {
+ // not a destination for a path (such as one that another
transport serves)
+ return;
+ }
+ resolveOptions();
+ String path = getPath();
+ Mounted existing = mounted.get(servicePath);
+ if (existing != null) {
+ if (existing.server == server) {
+ // the listener is registered once per cxf endpoint on a bus
that endpoints may share
+ return;
+ }
+ throw new IllegalStateException(
+ "A cxf consumer is already served at " + path +
servicePath + " on the platform-http server");
+ }
+ if (httpServerStarter != null) {
+ httpServerStarter.run();
+ }
+ VertxPlatformHttpRouter router = lookupRouter();
+ CxfPlatformHttpHandler handler = new
CxfPlatformHttpHandler(httpDestination, path, isUseXForwardedHeaders());
+ Route route = router.route(path + servicePath).handler(handler);
+ mounted.put(servicePath, new Mounted(server, route));
+ LOG.info("cxf consumer served on the platform-http server at {}{}",
path, servicePath);
+ }
+
+ @Override
+ public void stopServer(Server server) {
+ mounted.entrySet().removeIf(e -> {
+ if (e.getValue().server == server) {
+ e.getValue().route.remove();
+ LOG.debug("cxf consumer no longer served at {}{}", getPath(),
e.getKey());
+ return true;
+ }
+ return false;
+ });
+ }
+
+ /**
+ * The options that are not set are read from the properties ({@code
camel.cxf.path} and
+ * {@code camel.cxf.useXForwardedHeaders}), when the first service starts,
as the properties are complete then.
+ */
+ private synchronized void resolveOptions() {
+ if (camelContext == null) {
+ return;
+ }
+ PropertiesComponent pc = camelContext.getPropertiesComponent();
+ if (path == null) {
+ pc.resolveProperty(PATH_PROPERTY).ifPresent(this::setPath);
+ }
+ if (useXForwardedHeaders == null) {
+
pc.resolveProperty(USE_X_FORWARDED_HEADERS_PROPERTY).map(Boolean::parseBoolean)
+ .ifPresent(this::setUseXForwardedHeaders);
+ }
+ }
+
+ /**
+ * The path of a destination under {@link #getPath()}, or null when it is
not a path destination. The destination
+ * keeps the address it was created for, while CXF updates the address of
its endpoint to the URL of each request.
+ */
+ static String servicePath(String destinationPath) {
+ String path = destinationPath;
+ if (ObjectHelper.isEmpty(path) || path.contains("://")) {
+ return null;
+ }
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ return path;
+ }
+
+ private VertxPlatformHttpRouter lookupRouter() {
+ Set<VertxPlatformHttpRouter> routers =
camelContext.getRegistry().findByType(VertxPlatformHttpRouter.class);
+ VertxPlatformHttpRouter router = routers.stream()
+ .filter(VertxPlatformHttpRouter::isMainServer)
+ .findFirst()
+ // a bare VertxPlatformHttpServer may have no server type
+ .orElseGet(() -> routers.size() == 1 ?
routers.iterator().next() : null);
+ if (router == null) {
+ throw new IllegalStateException(
+ "A cxf consumer is served on the platform-http server
(camel-cxf-platform-http), which is not"
+ + " running. Enable the HTTP
server of Camel Main (camel.server.enabled=true"
+ + " with camel-platform-http-main
on the classpath).");
+ }
+ return router;
+ }
+
+ static String normalizePath(String path) {
+ if (ObjectHelper.isEmpty(path) || "/".equals(path)) {
+ return "";
+ }
+ String answer = path.trim();
+ if (!answer.startsWith("/")) {
+ answer = "/" + answer;
+ }
+ while (answer.endsWith("/")) {
+ answer = answer.substring(0, answer.length() - 1);
+ }
+ return answer;
+ }
+
+ private record Mounted(Server server, Route route) {
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletInputStream.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletInputStream.java
new file mode 100644
index 000000000000..6af147b36f06
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletInputStream.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import jakarta.servlet.ReadListener;
+import jakarta.servlet.ServletInputStream;
+
+import io.vertx.core.Context;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.http.HttpServerRequest;
+
+/**
+ * A blocking stream of the body of a Vert.x request, read on a worker thread.
The request is paused, and each read that
+ * finds no data fetches the next buffer from the event loop, so no more than
one buffer of the body is held at a time.
+ * <p/>
+ * Created on the event loop, before the request is given to the worker thread.
+ */
+final class VertxServletInputStream extends ServletInputStream {
+
+ private final Context context;
+ private final HttpServerRequest request;
+ private final ReentrantLock lock = new ReentrantLock();
+ private final Condition changed = lock.newCondition();
+ private final Deque<Buffer> queue = new ArrayDeque<>();
+ private boolean ended;
+ private boolean fetching;
+ private Throwable failure;
+ private Buffer current;
+ private int position;
+ private boolean closed;
+
+ VertxServletInputStream(Context context, HttpServerRequest request) {
+ this.context = context;
+ this.request = request;
+ request.pause();
+ if (request.isEnded()) {
+ // no body (or it has been read already)
+ ended = true;
+ } else {
+ request.handler(this::onData);
+ request.endHandler(v -> onEnd());
+ request.exceptionHandler(this::onFailure);
+ }
+ }
+
+ private void onData(Buffer buffer) {
+ lock.lock();
+ try {
+ if (buffer.length() > 0) {
+ queue.add(buffer);
+ }
+ fetching = false;
+ changed.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private void onEnd() {
+ lock.lock();
+ try {
+ ended = true;
+ changed.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private void onFailure(Throwable cause) {
+ lock.lock();
+ try {
+ failure = cause;
+ changed.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * The next buffer of the body, waiting for it, or null at the end of the
body.
+ */
+ private boolean nextBuffer() throws IOException {
+ lock.lock();
+ try {
+ while (queue.isEmpty()) {
+ if (failure != null) {
+ throw new IOException("Error reading the request body: " +
failure.getMessage(), failure);
+ }
+ if (ended || closed) {
+ return false;
+ }
+ if (!fetching) {
+ fetching = true;
+ context.runOnContext(v -> request.fetch(1));
+ }
+ try {
+ // the connection closing (or the idle timeout of the
server) fails the request and wakes us up
+ changed.await(1, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new InterruptedIOException("Interrupted reading the
request body");
+ }
+ }
+ current = queue.poll();
+ position = 0;
+ return true;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private boolean ensureData() throws IOException {
+ while (current == null || position >= current.length()) {
+ if (!nextBuffer()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (!ensureData()) {
+ return -1;
+ }
+ return current.getByte(position++) & 0xff;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (len == 0) {
+ return 0;
+ }
+ if (!ensureData()) {
+ return -1;
+ }
+ int n = Math.min(len, current.length() - position);
+ current.getBytes(position, position + n, b, off);
+ position += n;
+ return n;
+ }
+
+ @Override
+ public int available() {
+ return current != null ? current.length() - position : 0;
+ }
+
+ @Override
+ public boolean isFinished() {
+ lock.lock();
+ try {
+ return ended && queue.isEmpty() && (current == null || position >=
current.length());
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public boolean isReady() {
+ return available() > 0 || isFinished();
+ }
+
+ @Override
+ public void setReadListener(ReadListener readListener) {
+ throw new UnsupportedOperationException("Asynchronous reads are not
supported");
+ }
+
+ @Override
+ public void close() {
+ lock.lock();
+ try {
+ closed = true;
+ queue.clear();
+ current = null;
+ changed.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletOutputStream.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletOutputStream.java
new file mode 100644
index 000000000000..fed4c9e7ea7b
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletOutputStream.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.WriteListener;
+
+import io.vertx.core.Context;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.http.HttpHeaders;
+import io.vertx.core.http.HttpServerResponse;
+
+/**
+ * A blocking stream of the body of a Vert.x response, written on a worker
thread. The bytes are kept until the buffer
+ * is full; a body that fits in the buffer is sent with its length, a larger
one is sent in chunks (unless the length is
+ * set), waiting for the connection to drain when its write queue is full.
+ */
+final class VertxServletOutputStream extends ServletOutputStream {
+
+ static final int DEFAULT_BUFFER_SIZE = 8192;
+
+ private final Context context;
+ private final HttpServerResponse response;
+ private Buffer buffer;
+ private int bufferSize = DEFAULT_BUFFER_SIZE;
+ private boolean committed;
+ private boolean closed;
+
+ VertxServletOutputStream(Context context, HttpServerResponse response) {
+ this.context = context;
+ this.response = response;
+ this.buffer = Buffer.buffer(bufferSize);
+ }
+
+ void setBufferSize(int size) {
+ if (buffer.length() > 0 || committed) {
+ throw new IllegalStateException("The response body has been
written already");
+ }
+ bufferSize = Math.max(size, 1);
+ }
+
+ int getBufferSize() {
+ return bufferSize;
+ }
+
+ boolean isCommitted() {
+ return committed || response.headWritten();
+ }
+
+ void resetBuffer() {
+ if (isCommitted()) {
+ throw new IllegalStateException("The response has been committed");
+ }
+ buffer = Buffer.buffer(bufferSize);
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ ensureOpen();
+ buffer.appendByte((byte) b);
+ if (buffer.length() >= bufferSize) {
+ writeBuffer();
+ }
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ ensureOpen();
+ while (len > 0) {
+ int n = Math.min(len, bufferSize - buffer.length());
+ buffer.appendBytes(b, off, n);
+ off += n;
+ len -= n;
+ if (buffer.length() >= bufferSize) {
+ writeBuffer();
+ }
+ }
+ }
+
+ @Override
+ public void flush() throws IOException {
+ ensureOpen();
+ if (buffer.length() > 0) {
+ writeBuffer();
+ }
+ }
+
+ /**
+ * Commits the response (status and headers) and sends what is buffered.
+ */
+ private void writeBuffer() throws IOException {
+ if (!committed) {
+ committed = true;
+ if (!response.headers().contains(HttpHeaders.CONTENT_LENGTH)) {
+ response.setChunked(true);
+ }
+ }
+ Buffer chunk = buffer;
+ buffer = Buffer.buffer(bufferSize);
+ if (response.closed()) {
+ throw new IOException("The connection is closed");
+ }
+ response.write(chunk);
+ waitForDrain();
+ }
+
+ private void waitForDrain() throws IOException {
+ if (!response.writeQueueFull()) {
+ return;
+ }
+ CompletableFuture<Void> drained = new CompletableFuture<>();
+ context.runOnContext(v -> {
+ if (!response.writeQueueFull() || response.closed()) {
+ drained.complete(null);
+ } else {
+ response.drainHandler(d -> drained.complete(null));
+ }
+ });
+ try {
+ while (true) {
+ try {
+ drained.get(1, TimeUnit.SECONDS);
+ break;
+ } catch (TimeoutException e) {
+ if (response.closed()) {
+ throw new IOException("The connection is closed");
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new InterruptedIOException("Interrupted writing the response
body");
+ } catch (ExecutionException e) {
+ throw new IOException(e.getCause());
+ }
+ if (response.closed()) {
+ throw new IOException("The connection is closed");
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (closed) {
+ return;
+ }
+ closed = true;
+ if (response.ended() || response.closed()) {
+ return;
+ }
+ if (!committed) {
+ // the whole body is in the buffer: send it with its length
+ if (!response.headers().contains(HttpHeaders.CONTENT_LENGTH) &&
!response.isChunked()) {
+ response.putHeader(HttpHeaders.CONTENT_LENGTH,
String.valueOf(buffer.length()));
+ }
+ committed = true;
+ response.end(buffer);
+ } else {
+ response.end(buffer);
+ }
+ }
+
+ boolean isClosed() {
+ return closed;
+ }
+
+ private void ensureOpen() throws IOException {
+ if (closed) {
+ throw new IOException("The response body is closed");
+ }
+ }
+
+ @Override
+ public boolean isReady() {
+ return !response.writeQueueFull();
+ }
+
+ @Override
+ public void setWriteListener(WriteListener writeListener) {
+ throw new UnsupportedOperationException("Asynchronous writes are not
supported");
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletRequest.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletRequest.java
new file mode 100644
index 000000000000..14cbf27c746c
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletRequest.java
@@ -0,0 +1,620 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Principal;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import jakarta.servlet.AsyncContext;
+import jakarta.servlet.DispatcherType;
+import jakarta.servlet.RequestDispatcher;
+import jakarta.servlet.ServletConnection;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletInputStream;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.Cookie;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
+import jakarta.servlet.http.HttpUpgradeHandler;
+import jakarta.servlet.http.Part;
+
+import io.vertx.core.MultiMap;
+import io.vertx.core.http.HttpHeaders;
+import io.vertx.core.http.HttpServerRequest;
+import io.vertx.core.http.HttpVersion;
+import io.vertx.core.net.HostAndPort;
+import io.vertx.core.net.SocketAddress;
+import io.vertx.ext.auth.User;
+import io.vertx.ext.web.RoutingContext;
+
+/**
+ * The servlet request that CXF reads, over a Vert.x request. Only what CXF
uses is supported: the request line,
+ * headers, query parameters, the body as a stream, the addresses, and the
user that the authentication of the
+ * platform-http server has set. There are no sessions, no dispatchers, no
form parameters and no parts.
+ */
+final class VertxServletRequest implements HttpServletRequest {
+
+ private static final AtomicLong REQUEST_IDS = new AtomicLong();
+
+ private final RoutingContext rc;
+ private final HttpServerRequest request;
+ private final ServletInputStream in;
+ private final String contextPath;
+ private final String servletPath;
+ private final String pathInfo;
+ private final boolean useXForwardedHeaders;
+ private final Map<String, Object> attributes = new ConcurrentHashMap<>();
+ private final String requestId =
Long.toString(REQUEST_IDS.incrementAndGet());
+ private String characterEncoding;
+ private BufferedReader reader;
+
+ VertxServletRequest(RoutingContext rc, ServletInputStream in, String
contextPath, String servletPath,
+ String pathInfo, boolean useXForwardedHeaders) {
+ this.rc = rc;
+ this.request = rc.request();
+ this.in = in;
+ this.contextPath = contextPath;
+ this.servletPath = servletPath;
+ this.pathInfo = pathInfo;
+ this.useXForwardedHeaders = useXForwardedHeaders;
+ }
+
+ // attributes
+
+ @Override
+ public Object getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ return Collections.enumeration(attributes.keySet());
+ }
+
+ @Override
+ public void setAttribute(String name, Object o) {
+ if (o == null) {
+ attributes.remove(name);
+ } else {
+ attributes.put(name, o);
+ }
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ attributes.remove(name);
+ }
+
+ // body
+
+ @Override
+ public String getCharacterEncoding() {
+ if (characterEncoding == null) {
+ String type = getContentType();
+ if (type != null) {
+ int pos = type.toLowerCase(Locale.ROOT).indexOf("charset=");
+ if (pos >= 0) {
+ String charset = type.substring(pos + 8).trim();
+ int end = charset.indexOf(';');
+ characterEncoding = (end >= 0 ? charset.substring(0, end)
: charset).trim().replace("\"", "");
+ }
+ }
+ }
+ return characterEncoding;
+ }
+
+ @Override
+ public void setCharacterEncoding(String env) throws
UnsupportedEncodingException {
+ if (reader == null) {
+ if (!Charset.isSupported(env)) {
+ throw new UnsupportedEncodingException(env);
+ }
+ this.characterEncoding = env;
+ }
+ }
+
+ @Override
+ public int getContentLength() {
+ long len = getContentLengthLong();
+ return len > Integer.MAX_VALUE ? -1 : (int) len;
+ }
+
+ @Override
+ public long getContentLengthLong() {
+ String value = request.getHeader(HttpHeaders.CONTENT_LENGTH);
+ if (value == null) {
+ return -1;
+ }
+ try {
+ return Long.parseLong(value.trim());
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ @Override
+ public String getContentType() {
+ return request.getHeader(HttpHeaders.CONTENT_TYPE);
+ }
+
+ @Override
+ public ServletInputStream getInputStream() {
+ return in;
+ }
+
+ @Override
+ public BufferedReader getReader() {
+ if (reader == null) {
+ String charset = getCharacterEncoding();
+ reader = new BufferedReader(
+ new InputStreamReader(in, charset != null ?
Charset.forName(charset) : StandardCharsets.ISO_8859_1));
+ }
+ return reader;
+ }
+
+ // parameters: only those of the query, as a form body is the SOAP message
+
+ @Override
+ public String getParameter(String name) {
+ return rc.queryParams().get(name);
+ }
+
+ @Override
+ public Enumeration<String> getParameterNames() {
+ return Collections.enumeration(rc.queryParams().names());
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ List<String> values = rc.queryParams().getAll(name);
+ return values.isEmpty() ? null : values.toArray(new String[0]);
+ }
+
+ @Override
+ public Map<String, String[]> getParameterMap() {
+ Map<String, String[]> answer = new LinkedHashMap<>();
+ MultiMap params = rc.queryParams();
+ for (String name : params.names()) {
+ answer.put(name, params.getAll(name).toArray(new String[0]));
+ }
+ return answer;
+ }
+
+ // the request line and the addresses
+
+ @Override
+ public String getProtocol() {
+ HttpVersion version = request.version();
+ if (version == HttpVersion.HTTP_2) {
+ return "HTTP/2.0";
+ }
+ return version == HttpVersion.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1";
+ }
+
+ @Override
+ public String getScheme() {
+ String proto = forwarded("X-Forwarded-Proto");
+ return proto != null ? proto.toLowerCase(Locale.ROOT) :
request.scheme();
+ }
+
+ @Override
+ public String getServerName() {
+ String host = forwarded("X-Forwarded-Host");
+ if (host != null) {
+ HostAndPort hp = HostAndPort.parseAuthority(host, -1);
+ return hp != null ? hp.host() : host;
+ }
+ HostAndPort authority = request.authority();
+ if (authority != null) {
+ return authority.host();
+ }
+ SocketAddress local = request.localAddress();
+ return local != null ? local.host() : "localhost";
+ }
+
+ @Override
+ public int getServerPort() {
+ if (useXForwardedHeaders) {
+ String port = forwarded("X-Forwarded-Port");
+ if (port != null) {
+ try {
+ return Integer.parseInt(port.trim());
+ } catch (NumberFormatException e) {
+ // use the host or the scheme
+ }
+ }
+ String host = forwarded("X-Forwarded-Host");
+ if (host != null) {
+ HostAndPort hp = HostAndPort.parseAuthority(host, -1);
+ if (hp != null && hp.port() > 0) {
+ return hp.port();
+ }
+ return defaultPort(getScheme());
+ }
+ if (forwarded("X-Forwarded-Proto") != null) {
+ return defaultPort(getScheme());
+ }
+ }
+ HostAndPort authority = request.authority();
+ if (authority != null) {
+ return authority.port() > 0 ? authority.port() :
defaultPort(getScheme());
+ }
+ return getLocalPort();
+ }
+
+ @Override
+ public String getRemoteAddr() {
+ String forwardedFor = forwarded("X-Forwarded-For");
+ if (forwardedFor != null) {
+ return forwardedFor;
+ }
+ SocketAddress remote = request.remoteAddress();
+ return remote != null ? remote.hostAddress() : null;
+ }
+
+ @Override
+ public String getRemoteHost() {
+ return getRemoteAddr();
+ }
+
+ @Override
+ public int getRemotePort() {
+ SocketAddress remote = request.remoteAddress();
+ return remote != null ? remote.port() : -1;
+ }
+
+ @Override
+ public String getLocalName() {
+ SocketAddress local = request.localAddress();
+ return local != null ? local.host() : null;
+ }
+
+ @Override
+ public String getLocalAddr() {
+ SocketAddress local = request.localAddress();
+ return local != null ? local.hostAddress() : null;
+ }
+
+ @Override
+ public int getLocalPort() {
+ SocketAddress local = request.localAddress();
+ return local != null ? local.port() : -1;
+ }
+
+ @Override
+ public boolean isSecure() {
+ return "https".equals(getScheme());
+ }
+
+ @Override
+ public String getMethod() {
+ return request.method().name();
+ }
+
+ @Override
+ public String getRequestURI() {
+ return request.path();
+ }
+
+ @Override
+ public StringBuffer getRequestURL() {
+ String scheme = getScheme();
+ int port = getServerPort();
+ StringBuffer url = new StringBuffer();
+ url.append(scheme).append("://");
+ String host = getServerName();
+ if (host.indexOf(':') >= 0 && !host.startsWith("[")) {
+ // an IPv6 address
+ url.append('[').append(host).append(']');
+ } else {
+ url.append(host);
+ }
+ if (port > 0 && port != defaultPort(scheme)) {
+ url.append(':').append(port);
+ }
+ url.append(getRequestURI());
+ return url;
+ }
+
+ @Override
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ @Override
+ public String getServletPath() {
+ return servletPath;
+ }
+
+ @Override
+ public String getPathInfo() {
+ return pathInfo;
+ }
+
+ @Override
+ public String getPathTranslated() {
+ return null;
+ }
+
+ @Override
+ public String getQueryString() {
+ return request.query();
+ }
+
+ // headers
+
+ @Override
+ public String getHeader(String name) {
+ return request.getHeader(name);
+ }
+
+ @Override
+ public Enumeration<String> getHeaders(String name) {
+ return Collections.enumeration(request.headers().getAll(name));
+ }
+
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ return Collections.enumeration(request.headers().names());
+ }
+
+ @Override
+ public long getDateHeader(String name) {
+ String value = request.getHeader(name);
+ if (value == null) {
+ return -1;
+ }
+ try {
+ return ZonedDateTime.parse(value,
DateTimeFormatter.RFC_1123_DATE_TIME).toInstant().toEpochMilli();
+ } catch (DateTimeParseException e) {
+ throw new IllegalArgumentException("Header " + name + " is not a
date: " + value, e);
+ }
+ }
+
+ @Override
+ public int getIntHeader(String name) {
+ String value = request.getHeader(name);
+ return value == null ? -1 : Integer.parseInt(value.trim());
+ }
+
+ @Override
+ public Locale getLocale() {
+ return getLocales().nextElement();
+ }
+
+ @Override
+ public Enumeration<Locale> getLocales() {
+ String value = request.getHeader(HttpHeaders.ACCEPT_LANGUAGE);
+ if (value != null) {
+ try {
+ List<Locale> locales =
Locale.LanguageRange.parse(value).stream()
+ .map(range -> Locale.forLanguageTag(range.getRange()))
+ .toList();
+ if (!locales.isEmpty()) {
+ return Collections.enumeration(locales);
+ }
+ } catch (IllegalArgumentException e) {
+ // use the default
+ }
+ }
+ return Collections.enumeration(List.of(Locale.getDefault()));
+ }
+
+ @Override
+ public Cookie[] getCookies() {
+ Collection<io.vertx.core.http.Cookie> cookies = request.cookies();
+ if (cookies.isEmpty()) {
+ return null;
+ }
+ return cookies.stream().map(c -> new Cookie(c.getName(),
c.getValue())).toArray(Cookie[]::new);
+ }
+
+ // the user of the authentication of the platform-http server
+
+ @Override
+ public String getAuthType() {
+ return rc.user() != null ? HttpServletRequest.BASIC_AUTH : null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ User user = rc.user();
+ return user != null ? user.subject() : null;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ String name = getRemoteUser();
+ return name != null ? new PlatformHttpPrincipal(name) : null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ // the roles of the user are not known here
+ return false;
+ }
+
+ @Override
+ public boolean authenticate(HttpServletResponse response) {
+ return rc.user() != null;
+ }
+
+ @Override
+ public void login(String username, String password) {
+ throw new UnsupportedOperationException("Login is done by the
authentication of the platform-http server");
+ }
+
+ @Override
+ public void logout() {
+ throw new UnsupportedOperationException("Logout is not supported");
+ }
+
+ // sessions are not supported
+
+ @Override
+ public String getRequestedSessionId() {
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create) {
+ if (create) {
+ throw new UnsupportedOperationException("HTTP sessions are not
supported");
+ }
+ return null;
+ }
+
+ @Override
+ public HttpSession getSession() {
+ return getSession(true);
+ }
+
+ @Override
+ public String changeSessionId() {
+ throw new IllegalStateException("There is no HTTP session");
+ }
+
+ @Override
+ public boolean isRequestedSessionIdValid() {
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromCookie() {
+ return false;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromURL() {
+ return false;
+ }
+
+ // not supported: parts, upgrades, dispatchers and asynchronous processing
+
+ @Override
+ public Collection<Part> getParts() {
+ throw new UnsupportedOperationException("Parts are not supported");
+ }
+
+ @Override
+ public Part getPart(String name) {
+ throw new UnsupportedOperationException("Parts are not supported");
+ }
+
+ @Override
+ public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) {
+ throw new UnsupportedOperationException("Upgrades are not supported");
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return null;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync() {
+ throw new IllegalStateException("Asynchronous processing is not
supported");
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse) {
+ throw new IllegalStateException("Asynchronous processing is not
supported");
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ return false;
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ // CXF processes the request on this (worker) thread
+ return false;
+ }
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ throw new IllegalStateException("Asynchronous processing is not
supported");
+ }
+
+ @Override
+ public DispatcherType getDispatcherType() {
+ return DispatcherType.REQUEST;
+ }
+
+ @Override
+ public String getRequestId() {
+ return requestId;
+ }
+
+ @Override
+ public String getProtocolRequestId() {
+ return "";
+ }
+
+ @Override
+ public ServletConnection getServletConnection() {
+ return null;
+ }
+
+ private String forwarded(String header) {
+ if (!useXForwardedHeaders) {
+ return null;
+ }
+ String value = request.getHeader(header);
+ if (value == null || value.isBlank()) {
+ return null;
+ }
+ // the first value is the one of the client
+ int comma = value.indexOf(',');
+ return (comma >= 0 ? value.substring(0, comma) : value).trim();
+ }
+
+ private static int defaultPort(String scheme) {
+ return "https".equalsIgnoreCase(scheme) ? 443 : 80;
+ }
+
+ private record PlatformHttpPrincipal(String name) implements Principal {
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletResponse.java
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletResponse.java
new file mode 100644
index 000000000000..2abc3644576f
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/java/org/apache/camel/component/cxf/platform/http/VertxServletResponse.java
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.Cookie;
+import jakarta.servlet.http.HttpServletResponse;
+
+import io.vertx.core.Context;
+import io.vertx.core.http.HttpHeaders;
+import io.vertx.core.http.HttpServerResponse;
+
+/**
+ * The servlet response that CXF writes, over a Vert.x response. Only what CXF
uses is supported: status, headers,
+ * content type and the body.
+ */
+final class VertxServletResponse implements HttpServletResponse {
+
+ private static final DateTimeFormatter HTTP_DATE
+ =
DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneOffset.UTC).withLocale(Locale.US);
+
+ private final HttpServerResponse response;
+ private final VertxServletOutputStream out;
+ private PrintWriter writer;
+ private String contentType;
+ private String characterEncoding;
+ private Locale locale = Locale.getDefault();
+
+ VertxServletResponse(Context context, HttpServerResponse response) {
+ this.response = response;
+ this.out = new VertxServletOutputStream(context, response);
+ }
+
+ /**
+ * Ends the response after CXF has written it.
+ */
+ void close() throws IOException {
+ if (writer != null) {
+ writer.flush();
+ }
+ out.close();
+ }
+
+ /**
+ * Ends the response after a failure (on the event loop).
+ */
+ void fail() {
+ if (response.ended() || response.closed()) {
+ return;
+ }
+ if (response.headWritten()) {
+ // the status is sent already: the client can only see that the
body is cut off
+ response.reset();
+ } else {
+ response.setStatusCode(500).end();
+ }
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ return characterEncoding != null ? characterEncoding :
StandardCharsets.ISO_8859_1.name();
+ }
+
+ @Override
+ public String getContentType() {
+ return contentType;
+ }
+
+ @Override
+ public ServletOutputStream getOutputStream() {
+ return out;
+ }
+
+ @Override
+ public PrintWriter getWriter() {
+ if (writer == null) {
+ writer = new PrintWriter(new OutputStreamWriter(out,
Charset.forName(getCharacterEncoding())));
+ }
+ return writer;
+ }
+
+ @Override
+ public void setCharacterEncoding(String charset) {
+ if (isCommitted() || writer != null) {
+ return;
+ }
+ this.characterEncoding = charset;
+ if (contentType != null) {
+ setContentType(contentType);
+ }
+ }
+
+ @Override
+ public void setContentLength(int len) {
+ setContentLengthLong(len);
+ }
+
+ @Override
+ public void setContentLengthLong(long len) {
+ if (!isCommitted()) {
+ response.putHeader(HttpHeaders.CONTENT_LENGTH,
String.valueOf(len));
+ }
+ }
+
+ @Override
+ public void setContentType(String type) {
+ if (isCommitted() || type == null) {
+ return;
+ }
+ String answer = type;
+ int pos = type.toLowerCase(Locale.ROOT).indexOf("charset=");
+ if (pos >= 0) {
+ String charset = type.substring(pos + 8).trim();
+ int end = charset.indexOf(';');
+ if (end >= 0) {
+ charset = charset.substring(0, end).trim();
+ }
+ if (writer == null) {
+ characterEncoding = charset.replace("\"", "");
+ }
+ } else if (characterEncoding != null) {
+ answer = type + ";charset=" + characterEncoding;
+ }
+ contentType = answer;
+ response.putHeader(HttpHeaders.CONTENT_TYPE, answer);
+ }
+
+ @Override
+ public void setBufferSize(int size) {
+ out.setBufferSize(size);
+ }
+
+ @Override
+ public int getBufferSize() {
+ return out.getBufferSize();
+ }
+
+ @Override
+ public void flushBuffer() throws IOException {
+ if (writer != null) {
+ writer.flush();
+ }
+ out.flush();
+ }
+
+ @Override
+ public void resetBuffer() {
+ out.resetBuffer();
+ }
+
+ @Override
+ public boolean isCommitted() {
+ return out.isCommitted();
+ }
+
+ @Override
+ public void reset() {
+ resetBuffer();
+ response.headers().clear();
+ response.setStatusCode(200);
+ contentType = null;
+ characterEncoding = null;
+ writer = null;
+ }
+
+ @Override
+ public void setLocale(Locale loc) {
+ if (loc != null && !isCommitted()) {
+ this.locale = loc;
+ }
+ }
+
+ @Override
+ public Locale getLocale() {
+ return locale;
+ }
+
+ @Override
+ public void addCookie(Cookie cookie) {
+ // CXF does not set cookies on a SOAP response
+ throw new UnsupportedOperationException("Cookies are not supported");
+ }
+
+ @Override
+ public boolean containsHeader(String name) {
+ return response.headers().contains(name);
+ }
+
+ @Override
+ public String encodeURL(String url) {
+ return url;
+ }
+
+ @Override
+ public String encodeRedirectURL(String url) {
+ return url;
+ }
+
+ @Override
+ public void sendError(int sc, String msg) throws IOException {
+ if (isCommitted()) {
+ throw new IllegalStateException("The response has been committed");
+ }
+ resetBuffer();
+ response.setStatusCode(sc);
+ if (msg != null) {
+ response.putHeader(HttpHeaders.CONTENT_TYPE,
"text/plain;charset=UTF-8");
+ out.write(msg.getBytes(StandardCharsets.UTF_8));
+ }
+ out.close();
+ }
+
+ @Override
+ public void sendError(int sc) throws IOException {
+ sendError(sc, null);
+ }
+
+ @Override
+ public void sendRedirect(String location, int sc, boolean clearBuffer)
throws IOException {
+ if (isCommitted()) {
+ throw new IllegalStateException("The response has been committed");
+ }
+ if (clearBuffer) {
+ resetBuffer();
+ }
+ response.setStatusCode(sc);
+ response.putHeader(HttpHeaders.LOCATION, location);
+ out.close();
+ }
+
+ @Override
+ public void setDateHeader(String name, long date) {
+ setHeader(name, HTTP_DATE.format(Instant.ofEpochMilli(date)));
+ }
+
+ @Override
+ public void addDateHeader(String name, long date) {
+ addHeader(name, HTTP_DATE.format(Instant.ofEpochMilli(date)));
+ }
+
+ @Override
+ public void setHeader(String name, String value) {
+ if (isCommitted() || name == null) {
+ return;
+ }
+ if (HttpHeaders.CONTENT_TYPE.toString().equalsIgnoreCase(name)) {
+ setContentType(value);
+ } else if (value == null) {
+ response.headers().remove(name);
+ } else {
+ response.putHeader(name, value);
+ }
+ }
+
+ @Override
+ public void addHeader(String name, String value) {
+ if (isCommitted() || name == null || value == null) {
+ return;
+ }
+ if (HttpHeaders.CONTENT_TYPE.toString().equalsIgnoreCase(name)) {
+ setContentType(value);
+ } else {
+ response.headers().add(name, value);
+ }
+ }
+
+ @Override
+ public void setIntHeader(String name, int value) {
+ setHeader(name, String.valueOf(value));
+ }
+
+ @Override
+ public void addIntHeader(String name, int value) {
+ addHeader(name, String.valueOf(value));
+ }
+
+ @Override
+ public void setStatus(int sc) {
+ if (!isCommitted()) {
+ response.setStatusCode(sc);
+ }
+ }
+
+ @Override
+ public int getStatus() {
+ return response.getStatusCode();
+ }
+
+ @Override
+ public String getHeader(String name) {
+ return response.headers().get(name);
+ }
+
+ @Override
+ public Collection<String> getHeaders(String name) {
+ return new ArrayList<>(response.headers().getAll(name));
+ }
+
+ @Override
+ public Collection<String> getHeaderNames() {
+ return new LinkedHashSet<>(response.headers().names());
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/main/resources/META-INF/services/org.apache.camel.spi.ContextServicePlugin
b/components/camel-cxf/camel-cxf-platform-http/src/main/resources/META-INF/services/org.apache.camel.spi.ContextServicePlugin
new file mode 100644
index 000000000000..2f82f38fa779
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/main/resources/META-INF/services/org.apache.camel.spi.ContextServicePlugin
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+org.apache.camel.component.cxf.platform.http.CxfPlatformHttpContextServicePlugin
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpAddressTest.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpAddressTest.java
new file mode 100644
index 000000000000..9f3aeccedcc1
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpAddressTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class CxfPlatformHttpAddressTest {
+
+ @Test
+ void fullUrlAddressOfAConsumerFailsAtStartup() throws Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cxf:http://0.0.0.0:9000/orders?" +
CxfPlatformHttpTestSupport.SERVICE_CLASS)
+ .log("${body}");
+ }
+ });
+
+ assertThatThrownBy(context::start)
+ .rootCause()
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("must be a path, such as
cxf:/orders")
+ .hasMessageContaining("http://0.0.0.0:9000/orders")
+ .hasMessageContaining("/services");
+ }
+ }
+
+ @Test
+ void withoutPlatformHttpServerTheConsumerFailsAtStartup() throws Exception
{
+ try (CamelContext context = new DefaultCamelContext()) {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cxf:/orders?" +
CxfPlatformHttpTestSupport.SERVICE_CLASS).log("${body}");
+ }
+ });
+
+ assertThatThrownBy(context::start)
+ .rootCause()
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("camel.server.enabled=true");
+ }
+ }
+
+ @Test
+ void normalizePath() {
+ assertThat(CxfPlatformHttpTransport.normalizePath(null)).isEmpty();
+ assertThat(CxfPlatformHttpTransport.normalizePath("/")).isEmpty();
+
assertThat(CxfPlatformHttpTransport.normalizePath("services")).isEqualTo("/services");
+
assertThat(CxfPlatformHttpTransport.normalizePath("/soap/ws/")).isEqualTo("/soap/ws");
+
assertThat(CxfPlatformHttpTransport.servicePath("orders")).isEqualTo("/orders");
+
assertThat(CxfPlatformHttpTransport.servicePath("http://localhost:9000/orders")).isNull();
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpForwardedTest.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpForwardedTest.java
new file mode 100644
index 000000000000..32eeb1722f1a
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpForwardedTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.net.http.HttpResponse;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * With camel.cxf.useXForwardedHeaders=true, behind a proxy, the WSDL gives
the address of the proxy.
+ */
+public class CxfPlatformHttpForwardedTest extends CxfPlatformHttpTestSupport {
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+
context.getPropertiesComponent().addInitialProperty(CxfPlatformHttpTransport.USE_X_FORWARDED_HEADERS_PROPERTY,
"true");
+ return context;
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cxf:/greeter?" +
SERVICE_CLASS).process(CxfPlatformHttpTestSupport::greeting);
+ }
+ };
+ }
+
+ @Test
+ void wsdlGivesTheAddressOfTheProxy() throws Exception {
+ HttpResponse<String> response = get("/services/greeter?wsdl",
+ "X-Forwarded-Proto", "https", "X-Forwarded-Host",
"proxy.example.com");
+
+
assertThat(response.body()).contains("location=\"https://proxy.example.com/services/greeter\"");
+ }
+
+ @Test
+ void wsdlGivesThePortOfTheProxy() throws Exception {
+ HttpResponse<String> response = get("/services/greeter?wsdl",
+ "X-Forwarded-Proto", "https", "X-Forwarded-Host",
"proxy.example.com, inner.example.com",
+ "X-Forwarded-Port", "8443");
+
+
assertThat(response.body()).contains("location=\"https://proxy.example.com:8443/services/greeter\"");
+ }
+
+ @Test
+ void withoutTheHeadersTheAddressIsThatOfTheRequest() throws Exception {
+ assertThat(get("/services/greeter?wsdl").body())
+ .contains("location=\"" + baseUrl() + "/services/greeter\"");
+ assertThat(greet("/services/greeter", "World", null)).isEqualTo("Hello
World");
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpPathTest.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpPathTest.java
new file mode 100644
index 000000000000..a6849c7e9e6a
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpPathTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.net.http.HttpResponse;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * The services are served under camel.cxf.path, which is under the path of
the platform-http server.
+ */
+public class CxfPlatformHttpPathTest extends CxfPlatformHttpTestSupport {
+
+ @Override
+ protected void configureServer(VertxPlatformHttpServerConfiguration conf) {
+ conf.setPath("/api");
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+
context.getPropertiesComponent().addInitialProperty(CxfPlatformHttpTransport.PATH_PROPERTY,
"soap/");
+ return context;
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cxf:greeter?" +
SERVICE_CLASS).process(CxfPlatformHttpTestSupport::greeting);
+ }
+ };
+ }
+
+ @Test
+ void servedUnderTheServerPathAndTheCxfPath() throws Exception {
+ assertThat(greet("/api/soap/greeter", "World", null)).isEqualTo("Hello
World");
+
+ HttpResponse<String> response = get("/api/soap/greeter?wsdl");
+ assertThat(response.statusCode()).isEqualTo(200);
+ assertThat(response.body()).contains("location=\"" + baseUrl() +
"/api/soap/greeter\"");
+
+
assertThat(get("/api/services/greeter?wsdl").statusCode()).isEqualTo(404);
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTest.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTest.java
new file mode 100644
index 000000000000..e576863a01ed
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.net.http.HttpResponse;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.message.MessageContentsList;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class CxfPlatformHttpTest extends CxfPlatformHttpTestSupport {
+
+ private static final String SOAP12 =
"bindingId=http://www.w3.org/2003/05/soap/bindings/HTTP/";
+
+ private final AtomicReference<String> mtomContentType = new
AtomicReference<>();
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cxf:/greeter?" +
SERVICE_CLASS).process(CxfPlatformHttpTestSupport::greeting);
+
+ from("cxf:/other?" + SERVICE_CLASS)
+ .process(e -> e.getMessage().setBody("Hi " +
e.getIn().getBody(MessageContentsList.class).get(0)));
+
+ from("cxf:/published?" + SERVICE_CLASS +
"&publishedEndpointUrl=https://soap.example.com/ws/published")
+ .process(CxfPlatformHttpTestSupport::greeting);
+
+ from("cxf:/soap12?" + SERVICE_CLASS + "&" +
SOAP12).process(CxfPlatformHttpTestSupport::greeting);
+
+ from("cxf:/mtom?" + SERVICE_CLASS + "&mtomEnabled=true")
+ .process(e -> {
+
mtomContentType.set(e.getIn().getHeader("Content-Type", String.class));
+ byte[] data = (byte[])
e.getIn().getBody(MessageContentsList.class).get(0);
+ e.getMessage().setBody(data);
+ });
+
+ from("cxf:/secure?" + SERVICE_CLASS +
"&wsSecurityUsername=scott&wsSecurityPassword=tiger")
+ .process(CxfPlatformHttpTestSupport::greeting);
+
+ from("cxf:/stoppable?" +
SERVICE_CLASS).routeId("stoppable").process(CxfPlatformHttpTestSupport::greeting);
+ }
+ };
+ }
+
+ @Test
+ void soapRequestOnPlatformHttp() {
+ assertThat(greet("/services/greeter", "World", null)).isEqualTo("Hello
World");
+ }
+
+ @Test
+ void twoConsumersOnTheSameServer() {
+ assertThat(greet("/services/greeter", "World", null)).isEqualTo("Hello
World");
+ assertThat(greet("/services/other", "World", null)).isEqualTo("Hi
World");
+ }
+
+ @Test
+ void wsdlGivesTheAddressOfTheRequest() throws Exception {
+ HttpResponse<String> response = get("/services/greeter?wsdl");
+
+ assertThat(response.statusCode()).isEqualTo(200);
+ assertThat(response.body()).contains("wsdl:definitions")
+ .contains("location=\"" + baseUrl() + "/services/greeter\"");
+ }
+
+ @Test
+ void wsdlGivesThePublishedEndpointUrl() throws Exception {
+ HttpResponse<String> response = get("/services/published?wsdl");
+
+ assertThat(response.statusCode()).isEqualTo(200);
+
assertThat(response.body()).contains("location=\"https://soap.example.com/ws/published\"");
+ }
+
+ @Test
+ void forwardedHeadersAreIgnoredByDefault() throws Exception {
+ HttpResponse<String> response = get("/services/greeter?wsdl",
+ "X-Forwarded-Proto", "https", "X-Forwarded-Host",
"proxy.example.com");
+
+ assertThat(response.body()).contains("location=\"" + baseUrl() +
"/services/greeter\"")
+ .doesNotContain("proxy.example.com");
+ }
+
+ @Test
+ void soap12() throws Exception {
+ assertThat(greet("/services/soap12", "World",
SOAP12)).isEqualTo("Hello World");
+
assertThat(get("/services/soap12?wsdl").body()).contains("http://schemas.xmlsoap.org/wsdl/soap12/");
+ }
+
+ @Test
+ void mtomAttachmentBothWays() {
+ byte[] data = new byte[3 * 1024 * 1024];
+ new Random(42).nextBytes(data);
+ String uri = "cxf:" + baseUrl() + "/services/mtom?" + SERVICE_CLASS +
"&mtomEnabled=true";
+
+ Object out = template.requestBodyAndHeader(uri, data,
CxfConstants.OPERATION_NAME, "echoBinary");
+
+ assertThat((byte[]) ((MessageContentsList)
out).get(0)).isEqualTo(data);
+ // the root part of the MTOM message (CXF gives the route the content
type of the root part)
+ assertThat(mtomContentType.get()).contains("application/xop+xml");
+ }
+
+ @Test
+ void largeMessageIsStreamedBothWays() {
+ String name = "x".repeat(16 * 1024 * 1024);
+
+ assertThat(greet("/services/greeter", name,
null)).hasSize(name.length() + 6).startsWith("Hello xxx");
+ }
+
+ @Test
+ void wsSecurityUsernameToken() {
+ assertThat(greet("/services/secure", "Scott",
"wsSecurityUsername=scott&wsSecurityPassword=tiger"))
+ .isEqualTo("Hello Scott");
+
+ assertThatThrownBy(() -> greet("/services/secure", "Scott",
"wsSecurityUsername=scott&wsSecurityPassword=wrong"))
+ .isInstanceOf(CamelExecutionException.class)
+ .hasRootCauseInstanceOf(SoapFault.class);
+ assertThatThrownBy(() -> greet("/services/secure", "Scott", null))
+ .isInstanceOf(CamelExecutionException.class)
+ .hasRootCauseInstanceOf(SoapFault.class);
+ }
+
+ @Test
+ void stoppingTheConsumerRemovesTheService() throws Exception {
+
assertThat(get("/services/stoppable?wsdl").statusCode()).isEqualTo(200);
+
+ context.getRouteController().stopRoute("stoppable");
+
assertThat(get("/services/stoppable?wsdl").statusCode()).isEqualTo(404);
+
+ context.getRouteController().startRoute("stoppable");
+
assertThat(get("/services/stoppable?wsdl").statusCode()).isEqualTo(200);
+ assertThat(greet("/services/stoppable", "again",
null)).isEqualTo("Hello again");
+ }
+
+ @Test
+ void unknownServiceIsNotFound() throws Exception {
+ assertThat(get("/services/unknown?wsdl").statusCode()).isEqualTo(404);
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTestSupport.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTestSupport.java
new file mode 100644
index 000000000000..2e985a451d22
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/CxfPlatformHttpTestSupport.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
+import
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.cxf.message.MessageContentsList;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+/**
+ * Starts a CamelContext with a platform-http server (Vert.x) on a free port;
camel-cxf-platform-http is switched on by
+ * its context service plugin, as it is on the classpath.
+ */
+public abstract class CxfPlatformHttpTestSupport extends CamelTestSupport {
+
+ static final String SERVICE_CLASS = "serviceClass=" +
GreeterService.class.getName();
+
+ @RegisterExtension
+ AvailablePortFinder.Port port = AvailablePortFinder.find();
+
+ final HttpClient http =
HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ VertxPlatformHttpServerConfiguration conf = new
VertxPlatformHttpServerConfiguration();
+ conf.setBindPort(port.getPort());
+ configureServer(conf);
+ context.addService(new VertxPlatformHttpServer(conf));
+ return context;
+ }
+
+ protected void configureServer(VertxPlatformHttpServerConfiguration conf) {
+ }
+
+ String baseUrl() {
+ return "http://localhost:" + port.getPort();
+ }
+
+ /**
+ * Calls the greet operation with a cxf producer (a SOAP client), which
takes a full URL.
+ */
+ String greet(String address, String name, String options) {
+ String uri = "cxf:" + baseUrl() + address + "?" + SERVICE_CLASS +
(options != null ? "&" + options : "");
+ Object out = template.requestBodyAndHeader(uri, name,
CxfConstants.OPERATION_NAME, "greet");
+ return out instanceof MessageContentsList list ? (String) list.get(0)
: (String) out;
+ }
+
+ HttpResponse<String> get(String pathAndQuery, String... headers) throws
Exception {
+ HttpRequest.Builder builder =
HttpRequest.newBuilder(URI.create(baseUrl() + pathAndQuery))
+ .timeout(Duration.ofSeconds(20)).GET();
+ for (int i = 0; i < headers.length; i += 2) {
+ builder.header(headers[i], headers[i + 1]);
+ }
+ return http.send(builder.build(),
HttpResponse.BodyHandlers.ofString());
+ }
+
+ /**
+ * The greeting of the consumer: the name of the request, in the response.
+ */
+ static void greeting(Exchange exchange) {
+ MessageContentsList in =
exchange.getIn().getBody(MessageContentsList.class);
+ exchange.getMessage().setBody("Hello " + in.get(0));
+ }
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/GreeterService.java
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/GreeterService.java
new file mode 100644
index 000000000000..066133e57aed
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/java/org/apache/camel/component/cxf/platform/http/GreeterService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.platform.http;
+
+import jakarta.jws.WebMethod;
+import jakarta.jws.WebParam;
+import jakarta.jws.WebResult;
+import jakarta.jws.WebService;
+import jakarta.xml.bind.annotation.XmlMimeType;
+
+@WebService(targetNamespace = "http://camel.apache.org/cxf/platform/http",
name = "Greeter")
+public interface GreeterService {
+
+ @WebMethod
+ @WebResult(name = "greeting")
+ String greet(@WebParam(name = "name") String name);
+
+ @WebMethod
+ @WebResult(name = "data")
+ @XmlMimeType("application/octet-stream")
+ byte[] echoBinary(@WebParam(name = "data")
@XmlMimeType("application/octet-stream") byte[] data);
+}
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/resources/junit-platform.properties
b/components/camel-cxf/camel-cxf-platform-http/src/test/resources/junit-platform.properties
new file mode 100644
index 000000000000..a1efdc6fcb41
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/resources/junit-platform.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# CAMEL-26468: print a thread dump when a test hits its @Timeout, to show
where it hangs
+junit.jupiter.execution.timeout.threaddump.enabled = true
diff --git
a/components/camel-cxf/camel-cxf-platform-http/src/test/resources/log4j2.properties
b/components/camel-cxf/camel-cxf-platform-http/src/test/resources/log4j2.properties
new file mode 100644
index 000000000000..4e1431c13efa
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-platform-http/src/test/resources/log4j2.properties
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-cxf-platform-http-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-35.35t] %-5p %-30.30c{1} - %m%n
+logger.spring.name = org.apache.activemq.spring
+logger.spring.level = WARN
+logger.cxf.name = org.apache.camel.component.cxf
+logger.cxf.level = INFO
+logger.converter.name = org.apache.camel.impl.converter
+logger.converter.level = WARN
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
+#rootLogger.appenderRef.out.ref = out
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 19220de80b96..fe18d35a0c96 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
@@ -129,6 +129,30 @@ Using CXF with Spring Boot or Quarkus comes automatic
integrated with the embedd
See more details in the https://cxf.apache.org/docs/http-transport.html[CXF
Transport] documentation.
+=== Camel JBang and Camel Main: the platform-http server
+
+In Camel JBang (the Camel CLI), a cxf consumer is served on the platform-http
server, the same Vert.x HTTP server
+(port, bind address, TLS and authentication of `camel.server.*`) that serves
REST and platform-http routes. In a Camel
+Main application, add the `camel-cxf-platform-http` dependency (with
`camel-platform-http-main`) to do the same. See
+xref:others:cxf-platform-http.adoc[CXF Platform HTTP].
+
+The address of the consumer is then a path, served under `/services` (the
`camel.cxf.path` option), as on Spring Boot
+(`cxf.path`) and Quarkus (`quarkus.cxf.path`):
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: cxf:/orders
+ parameters:
+ wsdlURL: classpath:orders.wsdl
+ steps:
+ - to: direct:order
+----
+
+The service is at `\http://localhost:8080/services/orders`. An address with a
scheme and a host, such as
+`\http://0.0.0.0:9000/orders`, fails when the route starts. The cxf producer
still takes a full URL.
+
== WS-Security UsernameToken
The `wsSecurity` options set up a WS-Security UsernameToken without Java code.
The producer sends a UsernameToken in
diff --git
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
index 43f3efe9fa31..13c15995e036 100644
---
a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
+++
b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java
@@ -97,6 +97,8 @@ import org.apache.cxf.databinding.source.SourceDataBinding;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
import org.apache.cxf.ext.logging.AbstractLoggingInterceptor;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.apache.cxf.feature.Feature;
@@ -595,6 +597,18 @@ public class CxfEndpoint extends DefaultEndpoint
implements AsyncEndpoint, Heade
for (var factory : factories) {
sfb.getBus().setExtension(factory, HttpDestinationFactory.class);
}
+ // add custom server lifecycle listeners (such as
camel-cxf-platform-http, which serves the endpoint on the
+ // platform-http server when the server starts)
+ var listeners =
getCamelContext().getRegistry().findByType(ServerLifeCycleListener.class);
+ if (!listeners.isEmpty()) {
+ ServerLifeCycleManager manager =
sfb.getBus().getExtension(ServerLifeCycleManager.class);
+ if (manager != null) {
+ for (var listener : listeners) {
+ // a listener that is already registered (a shared bus) is
not added again
+ manager.registerListener(listener);
+ }
+ }
+ }
getNullSafeCxfConfigurer().configure(sfb);
}
diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml
index 369933a0f7e9..f39d548cacda 100644
--- a/components/camel-cxf/pom.xml
+++ b/components/camel-cxf/pom.xml
@@ -41,6 +41,7 @@
<module>camel-cxf-transport</module>
<module>camel-cxf-rest</module>
<module>camel-cxf-soap</module>
+ <module>camel-cxf-platform-http</module>
<module>camel-cxf-spring-soap</module>
<module>camel-cxf-spring-common</module>
<module>camel-cxf-spring-rest</module>
diff --git
a/docs/components/modules/others/examples/json/cxf-platform-http.json
b/docs/components/modules/others/examples/json/cxf-platform-http.json
new file mode 120000
index 000000000000..1916ac4d9904
--- /dev/null
+++ b/docs/components/modules/others/examples/json/cxf-platform-http.json
@@ -0,0 +1 @@
+../../../../../../components/camel-cxf/camel-cxf-platform-http/src/generated/resources/cxf-platform-http.json
\ No newline at end of file
diff --git a/docs/components/modules/others/nav.adoc
b/docs/components/modules/others/nav.adoc
index ea4c656d651d..c1a925969a88 100644
--- a/docs/components/modules/others/nav.adoc
+++ b/docs/components/modules/others/nav.adoc
@@ -19,6 +19,7 @@
** xref:cli-connector.adoc[CLI Connector]
** xref:cli-debug.adoc[CLI Debug]
** xref:cloudevents.adoc[Cloudevents]
+** xref:cxf-platform-http.adoc[CXF Platform HTTP]
** xref:cxf-transport.adoc[CXF Transport]
** xref:debug.adoc[Debug]
** xref:diagram.adoc[Diagram]
diff --git a/docs/components/modules/others/pages/cxf-platform-http.adoc
b/docs/components/modules/others/pages/cxf-platform-http.adoc
new file mode 120000
index 000000000000..d07e6f719251
--- /dev/null
+++ b/docs/components/modules/others/pages/cxf-platform-http.adoc
@@ -0,0 +1 @@
+../../../../../components/camel-cxf/camel-cxf-platform-http/src/main/docs/cxf-platform-http.adoc
\ No newline at end of file
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index cdfb92c13282..13affde0c13c 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -1295,6 +1295,26 @@ A route that relied on one of these headers being
returned can return it under a
`cxfBinding` option to a subclass of `DefaultCxfBinding` that overrides
`isHttpRequestHeader` and returns `false` for
the header.
+=== camel-cxf - in Camel JBang a cxf consumer is served on the platform-http
server, and its address is a path
+
+In Camel JBang (the Camel CLI), a `cxf` consumer (a SOAP service) is now
served on the platform-http server, the
+Vert.x HTTP server that also serves REST, platform-http routes and the health
checks, with its port, bind address, TLS
+and authentication (`camel.server.*`). Camel JBang no longer downloads
`cxf-rt-transports-http-undertow` to start a
+separate server on the port of the address, also not when Jetty or Undertow is
on the classpath.
+
+The address of a consumer is now a path, served under `/services` (option
`camel.cxf.path`), the same as `cxf.path` on
+Spring Boot and `quarkus.cxf.path` on Quarkus. Change
`cxf:http://0.0.0.0:9000/orders` to `cxf:/orders`; the
+service is then at `\http://localhost:8080/services/orders` (with
`camel.server.port`). A consumer with an address with a
+scheme and a host fails when the route starts. The `cxf` producer (a SOAP
client) is not changed and still takes a full
+URL.
+
+`camel export` to Camel Main adds `camel-cxf-platform-http` and
`camel-platform-http-main` for an integration with
+`camel-cxf-soap`, and turns on the HTTP server. The export to Spring Boot and
Quarkus uses their CXF starter and
+extension, as before, with `camel.cxf.path` mapped to `cxf.path` and
`quarkus.cxf.path`.
+
+A Camel Main application is not changed: it serves a cxf consumer with the
transport it brings (Jetty or Undertow),
+unless it adds `camel-cxf-platform-http`.
+
=== camel-snmp - the trap consumer receives only the traps of its snmpVersion
The trap consumer (`type=TRAP`) now receives only the traps of the
`snmpVersion` of its endpoint. With `snmpVersion=0`
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
index 9f3f1680ca56..6c434510c1ac 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/CamelMainExporter.java
@@ -342,6 +342,15 @@ class CamelMainExporter extends Exporter {
answer.add("mvn:org.apache.camel:camel-platform-http-jolokia");
}
+ // a cxf consumer is served on the platform-http server, as in camel
run (since 4.24)
+ if (hasCamelArtifact(answer, "camel-cxf-soap") &&
!hasCamelArtifact(answer, "camel-cxf-platform-http")
+ && (request.camelVersion == null ||
VersionHelper.isGE(request.camelVersion, "4.24.0"))) {
+ answer.add("mvn:org.apache.camel:camel-cxf-platform-http");
+ if (!hasCamelArtifact(answer, "camel-platform-http-main")) {
+ answer.add("mvn:org.apache.camel:camel-platform-http-main");
+ }
+ }
+
boolean main = hasCamelArtifact(answer, "camel-platform-http-main");
if (hasOpenapi(answer) && !main) {
// include http server if using openapi
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
index d04e44b06393..2d1607b05aef 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
@@ -1089,6 +1089,19 @@ abstract class Exporter {
return ExportHelper.propertyLine(key, value);
}
+ /**
+ * The path that camel-cxf-platform-http serves the SOAP services of cxf
consumers under (camel-main), which is
+ * {@code cxf.path} on Spring Boot and {@code quarkus.cxf.path} on Quarkus.
+ */
+ protected static final String CXF_PATH = "camel.cxf.path";
+
+ /**
+ * Whether the key is the option of camel-cxf-platform-http that reads the
X-Forwarded headers (camel-main).
+ */
+ protected static boolean isCxfUseXForwardedHeaders(String key) {
+ return "camel.cxf.useXForwardedHeaders".equals(key) ||
"camel.cxf.use-x-forwarded-headers".equals(key);
+ }
+
/**
* Gets the maven repositories
*
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/QuarkusExporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/QuarkusExporter.java
index b6f0a1373bd6..8530ad181e5d 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/QuarkusExporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/QuarkusExporter.java
@@ -329,6 +329,18 @@ class QuarkusExporter extends Exporter {
@Override
protected String applicationPropertyLine(String key, String value) {
+ if (key.startsWith("camel.cxf.")) {
+ // the options of camel-cxf-platform-http (camel-main) are those
of the CXF extension and the HTTP server of
+ // Quarkus
+ if (CXF_PATH.equals(key)) {
+ return super.applicationPropertyLine("quarkus.cxf.path",
value);
+ }
+ if (isCxfUseXForwardedHeaders(key)) {
+ return
super.applicationPropertyLine("quarkus.http.proxy.proxy-address-forwarding",
value) + "\n"
+ +
super.applicationPropertyLine("quarkus.http.proxy.enable-forwarded-host",
value);
+ }
+ return null;
+ }
if (key.startsWith("camel.server.") ||
key.startsWith("camel.management.")) {
// skip "camel.server." or "camel.management." as this is for
camel-main only
return null;
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
index 27a421095456..5d2875d4533d 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/SpringBootExporter.java
@@ -579,6 +579,16 @@ class SpringBootExporter extends Exporter {
@Override
protected String applicationPropertyLine(String key, String value) {
+ if (key.startsWith("camel.cxf.")) {
+ // the options of camel-cxf-platform-http (camel-main) are those
of the CXF servlet on Spring Boot
+ if (CXF_PATH.equals(key)) {
+ return super.applicationPropertyLine("cxf.path", value);
+ }
+ if (isCxfUseXForwardedHeaders(key)) {
+ return
super.applicationPropertyLine("cxf.servlet.init.use-x-forwarded-headers",
value);
+ }
+ return null;
+ }
if (key.startsWith("camel.server.") ||
key.startsWith("camel.management.")) {
// skip "camel.server." or "camel.management." as this is for
camel-main only
return null;
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
index 57ec0c72375d..2e78f94c0fbc 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
@@ -474,6 +474,55 @@ class ProjectExporterTest {
}
}
+ @ParameterizedTest
+ @EnumSource(value = RuntimeType.class, names = { "main", "springBoot",
"quarkus" })
+ void cxfConsumerIsServedOnTheHttpServerOfTheRuntime(RuntimeType runtime)
throws Exception {
+ Path route = writeRoute("soap");
+ DependencyResolver cxf = r -> {
+ Path settings = r.workDir.resolve(ExportHelper.RUN_SETTINGS_FILE);
+ Files.createDirectories(settings.getParent());
+ Files.writeString(settings, """
+ camel.main.routesIncludePattern=file:%s
+ dependency=camel:cxf-soap
+ """.formatted(route));
+ return 0;
+ };
+ Path exportDir = dir.resolve("export");
+ ExportRequest request = request(route, exportDir);
+ request.runtime = runtime;
+ request.applicationProperties
+ = new String[] { "camel.cxf.path=/soap",
"camel.cxf.useXForwardedHeaders=true" };
+
+ StringPrinter printer = new StringPrinter();
+ int exit = new ProjectExporter(new
ExportContext().withPrinter(printer).withDependencyResolver(cxf))
+ .export(request);
+
+ assertThat(exit).as(printer.getOutput()).isZero();
+ String pom = Files.readString(exportDir.resolve("pom.xml"));
+ String properties =
Files.readString(exportDir.resolve("src/main/resources/application.properties"));
+ switch (runtime) {
+ case main -> {
+ // served on the platform-http server, as in camel run
+
assertThat(pom).contains("<artifactId>camel-cxf-platform-http</artifactId>",
+ "<artifactId>camel-platform-http-main</artifactId>");
+ assertThat(properties).contains("camel.cxf.path=/soap",
"camel.cxf.useXForwardedHeaders=true",
+ "camel.server.enabled=true");
+ }
+ case springBoot -> {
+ assertThat(pom).doesNotContain("camel-cxf-platform-http");
+ assertThat(properties).contains("cxf.path=/soap",
"cxf.servlet.init.use-x-forwarded-headers=true")
+ .doesNotContain("camel.cxf.");
+ }
+ default -> {
+ assertThat(pom).doesNotContain("camel-cxf-platform-http");
+ assertThat(properties).contains("quarkus.cxf.path=/soap",
+ "quarkus.http.proxy.proxy-address-forwarding=true",
+ "quarkus.http.proxy.enable-forwarded-host=true")
+ .doesNotContain("camel.cxf.");
+ }
+ }
+ }
+
@ParameterizedTest
@EnumSource(value = RuntimeType.class, names = { "main", "springBoot",
"quarkus" })
void localJarsAreInTheLibDirectoryAsThePomRefersToThem(RuntimeType
runtime) throws Exception {
diff --git
a/dsl/camel-kamelet-main/src/main/resources/auto-configure/camel-cxf-soap.java
b/dsl/camel-kamelet-main/src/main/resources/auto-configure/camel-cxf-soap.java
index be519f81d249..6563c5baffa1 100644
---
a/dsl/camel-kamelet-main/src/main/resources/auto-configure/camel-cxf-soap.java
+++
b/dsl/camel-kamelet-main/src/main/resources/auto-configure/camel-cxf-soap.java
@@ -15,30 +15,36 @@
* limitations under the License.
*/
-// check if we already have CXF transport on classpath
-org.apache.camel.main.download.MavenDependencyDownloader downloader =
context.hasService(org.apache.camel.main.download.MavenDependencyDownloader.class);
-var cxfVersion = downloader.getVersionResolver().resolve("${cxf-version}");
-boolean jetty = downloader.alreadyOnClasspath("org.apache.cxf",
"cxf-rt-transports-http-jetty", cxfVersion);
-boolean undertow = downloader.alreadyOnClasspath("org.apache.cxf",
"cxf-rt-transports-http-undertow", cxfVersion);
-if (jetty || undertow){
- return null;
+// a cxf consumer is served on the platform-http server
(camel-cxf-platform-http), as the CXF extension of Quarkus does
+// on the Vert.x server of Quarkus; the address of a consumer is a path,
served under /services (camel.cxf.path)
+//
+// only the Camel API is used directly: the classes of the Camel CLI are not
visible to the compiler of this script
+// when it runs from the launcher, so they are called by reflection
+var resolver = context.getClassResolver();
+Class downloaderType =
resolver.resolveMandatoryClass("org.apache.camel.main.download.DependencyDownloader");
+Object downloader = context.hasService(downloaderType);
+downloaderType.getMethod("downloadHiddenDependency", String.class,
String.class, String.class)
+ .invoke(downloader, "org.apache.camel", "camel-cxf-platform-http",
context.getVersion());
+
+Class transportType =
resolver.resolveMandatoryClass("org.apache.camel.component.cxf.platform.http.CxfPlatformHttpTransport");
+Object transport =
context.getRegistry().lookupByName("camelCxfPlatformHttpTransport");
+if (transport == null) {
+ transport = transportType.getConstructor().newInstance();
+ transportType.getMethod("setCamelContext",
org.apache.camel.CamelContext.class).invoke(transport, context);
+ context.getRegistry().bind("camelCxfPlatformHttpTransport", transport);
}
-// automatic download cxf transport for undertow and register this with CXF
-context.getRegistry().bind("camelCxfUndertowHttpTransportDownloader", new
org.apache.cxf.transport.http.HttpDestinationFactory() {
- public org.apache.cxf.transport.http.AbstractHTTPDestination
createDestination(org.apache.cxf.service.model.EndpointInfo endpointInfo,
org.apache.cxf.Bus bus, org.apache.cxf.transport.http.DestinationRegistry
registry) throws java.io.IOException {
- downloader.downloadDependency("org.apache.cxf",
"cxf-rt-transports-http-undertow", cxfVersion);
- try {
- Class c =
context.getClassResolver().resolveClass("org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngineFactory");
- Object o =
c.getConstructor(org.apache.cxf.Bus.class).newInstance(bus);
- Class c2 =
context.getClassResolver().resolveClass("org.apache.cxf.transport.http_undertow.UndertowHTTPDestination");
- Object o2 = c2.getConstructor(org.apache.cxf.Bus.class,
org.apache.cxf.transport.http.DestinationRegistry.class,
org.apache.cxf.service.model.EndpointInfo.class, c)
- .newInstance(bus, registry, endpointInfo, o);
- return (org.apache.cxf.transport.http.AbstractHTTPDestination) o2;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+// start the platform-http server when the first cxf consumer starts (not for
a cxf producer only)
+java.lang.reflect.Method setup =
resolver.resolveMandatoryClass("org.apache.camel.main.download.MainHttpServerFactory")
+ .getMethod("setupHttpServer", org.apache.camel.CamelContext.class,
boolean.class);
+Runnable starter = () -> {
+ try {
+ setup.invoke(null, context, false);
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot start the platform-http server
for the cxf consumers", e);
}
-});
+};
+transportType.getMethod("setHttpServerStarter",
Runnable.class).invoke(transport, starter);
-return "Camel CLI will automatic download
org.apache.cxf:cxf-rt-transports-http-undertow:" + cxfVersion + " if needed by
camel-cxf-soap";
\ No newline at end of file
+return "Camel CLI serves cxf consumers on the platform-http server under "
+ + context.resolvePropertyPlaceholders("{{camel.cxf.path:/services}}");
diff --git a/parent/pom.xml b/parent/pom.xml
index 0a929ce57c33..96fa6f572e7b 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1358,6 +1358,11 @@
<artifactId>camel-cxf-common</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf-platform-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf-rest</artifactId>
diff --git
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
index 3ac9fd2a27b4..815a77d30f0e 100644
---
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
+++
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
@@ -62,7 +62,8 @@ public final class MojoHelper {
case "camel-avro-rpc":
return
Collections.singletonList(dir.resolve("camel-avro-rpc-component"));
case "camel-cxf":
- return Arrays.asList(dir.resolve("camel-cxf-soap"),
dir.resolve("camel-cxf-rest"));
+ return Arrays.asList(dir.resolve("camel-cxf-soap"),
dir.resolve("camel-cxf-rest"),
+ dir.resolve("camel-cxf-platform-http"));
case "camel-salesforce":
return
Collections.singletonList(dir.resolve("camel-salesforce-component"));
case "camel-dhis2":