davsclaus opened a new pull request, #30603: URL: https://github.com/apache/camel/pull/30603
## Description [CAMEL-27389](https://issues.apache.org/jira/browse/CAMEL-27389): a cxf consumer (a SOAP service) in Camel JBang and Camel Main is now served on the **platform-http server** (Vert.x). That's the server that also serves REST, platform-http routes, the health checks and the dev consoles. Until now Camel JBang downloaded the Undertow transport and started a separate server. This works the way the CXF extension of Quarkus serves SOAP services on the Vert.x server of Quarkus. - **The address of a consumer is a path**, such as `cxf:/orders`, served under `/services` (the `camel.cxf.path` option). That's the same as `cxf.path` on Spring Boot and `quarkus.cxf.path` on Quarkus, so the URL stays the same after `camel export`. - **A full URL fails at startup**: `cxf:http://0.0.0.0:9000/orders` on a consumer fails with a message that says to use a path. The producer (a SOAP client) is not changed. - **Same port, bind address, TLS and authentication** (`camel.server.*`) as the rest of the integration. The name of the authenticated user is the principal of the request. - **Camel JBang: always platform-http**, even with Jetty or Undertow on the classpath, with no fallback. **Camel Main: opt-in** by adding `camel-cxf-platform-http` (a `ContextServicePlugin`), so existing apps that bring Jetty or Undertow keep working. ### How it works - For a path address, CXF already creates a `ServletDestination`, as it does behind the CXF servlet of Spring Boot. - `CxfPlatformHttpTransport` is a CXF `ServerLifeCycleListener`. When the CXF server of a consumer starts, it adds a route for `<camel.cxf.path><address>` on the `VertxPlatformHttpRouter`. When the server stops, it removes the route, so a stopped route answers 404 and a restarted one is served again. - The same class is the `HttpDestinationFactory`. CXF asks it only for an address that starts with `http`, and it rejects those with the clear message above. - camel-cxf-soap now registers `ServerLifeCycleListener` beans of the registry on the bus of a cxf consumer, next to the `HttpDestinationFactory` beans it already registers. - Each request runs on a worker thread and goes to `AbstractHTTPDestination.invoke(...)` through lean servlet facades: - **request:** request line, headers, query, addresses and user; - **response:** status, headers, content type and body. The bodies are **streamed both ways**: a paused request is read with `fetch(1)`, and the response is chunked, waiting for drain when the write queue is full. The endpoint address per request is set the way the CXF servlet does it (default `disableAddressUpdates`). Sessions, dispatchers, form parameters and parts are not supported. - `camel.cxf.useXForwardedHeaders` (default **false**, as for the CXF servlet) takes the scheme, host and port of the request URL, and so of the `?wsdl` address, from `X-Forwarded-*`. - Camel JBang: the auto-configure script of camel-cxf-soap downloads the module instead of Undertow. It binds the transport with a starter that runs `MainHttpServerFactory.setupHttpServer`, so the HTTP server starts only when the first cxf **consumer** starts, not for a producer only. - **This also fixes a bug on main:** the old script fails to compile when the CLI runs from the launcher, because the classes of `org.apache.camel.main.download` are not visible to the joor compiler there. I reproduced it with the launcher built from main. The new script calls those classes by reflection. ### Export - **Camel Main:** adds `camel-cxf-platform-http` and `camel-platform-http-main` for an integration with `camel-cxf-soap` (4.24 onwards), which turns the HTTP server on. Trade-off: an integration with only a cxf producer gets the HTTP server too, as the export cannot tell a consumer from a producer (every component is stubbed and autoStartup is off). Before this PR, a Main export of a cxf consumer had no transport at all. - **Spring Boot / Quarkus:** use their starter and extension as before. `camel.cxf.path` is mapped to `cxf.path` and `quarkus.cxf.path`, and `camel.cxf.useXForwardedHeaders` to `cxf.servlet.init.use-x-forwarded-headers` and to the `quarkus.http.proxy.*` options. ### Commits 1. The module, the camel-cxf-soap hook and the JBang script. 2. The export changes. 3. The docs (cxf page and 4.24 upgrade guide). ## Tests - `CxfPlatformHttpTest` (POJO consumers on a `VertxPlatformHttpServer`): - SOAP call; - two consumers on one server; - `?wsdl` gives the address of the request; - `publishedEndpointUrl`; - forwarded headers ignored by default; - **SOAP 1.2**; - **MTOM** attachment both ways (3 MB); - **16 MB message streamed** both ways; - **WS-Security UsernameToken** (right, wrong and no password); - stopping and starting the route; - an unknown service is 404. - `CxfPlatformHttpForwardedTest`: the WSDL gives the address of the proxy with `X-Forwarded-Proto/Host/Port`. - `CxfPlatformHttpPathTest`: `camel.server.path=/api` and `camel.cxf.path=soap/` give `/api/soap/greeter`. - `CxfPlatformHttpAddressTest`: a full URL fails at startup, there's a clear error without a platform-http server, and the path helpers. - `ProjectExporterTest.cxfConsumerIsServedOnTheHttpServerOfTheRuntime` checks the Main, Spring Boot and Quarkus exports. - **End to end with the Camel CLI** (the launcher built from this branch): `camel run` of a RAW cxf consumer at `cxf:/orders` logs `cxf consumer served on the platform-http server at /services/orders`. curl of a SOAP request to `http://localhost:18089/services/orders` returns 200 with the reply of the route. The same route with `cxf:http://0.0.0.0:19099/orders` fails at startup with the new message. - Locally: the tests of camel-cxf-platform-http (18), `ProjectExporterTest` (32), a few camel-cxf-soap consumer and WS-Security tests (24), `-Psourcecheck`, and the docs xref check. ## Follow-up The `soap-source` Kamelet (apache/camel-kamelets): its `address` becomes a path. The kamelets session will do that in a Kamelet PR once this is merged. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
