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 aca3f31fc499 CAMEL-27389: camel-jbang - camel generate wsdl scaffolds 
a cxf consumer with a path address (#30609)
aca3f31fc499 is described below

commit aca3f31fc499da49fdf91480870a91e50accf25e
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 20:18:52 2026 +0100

    CAMEL-27389: camel-jbang - camel generate wsdl scaffolds a cxf consumer 
with a path address (#30609)
    
    The consumer scaffold wrote cxf://http://0.0.0.0:<port>/<path> for 
camel-main,
    which fails at start now that a cxf consumer is served on platform-http. It
    now always writes the path (cxf:/orders): Camel Main, Spring Boot and 
Quarkus
    all serve it under /services. The --runtime option is removed, as it no
    longer changes the route.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../modules/ROOT/pages/camel-jbang-projects.adoc   |  7 ++++---
 .../jbang-commands/camel-jbang-generate-wsdl.adoc  |  1 -
 .../camel-jbang-plugin-commands-metadata.json      |  2 +-
 .../core/commands/generate/CodeWsdlGenerator.java  | 12 +----------
 .../core/commands/generate/WsdlRouteScaffold.java  | 24 ++++++++--------------
 .../commands/generate/CodeWsdlGeneratorTest.java   | 21 ++++++++++---------
 .../wsdl/expected/orders-consumer.camel.yaml       |  4 +++-
 7 files changed, 29 insertions(+), 42 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
index b04641079d05..72f67372a0e5 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
@@ -674,9 +674,10 @@ camel generate wsdl orders.wsdl --route=producer 
--operation=getOrder --output=o
 * `consumer` is a SOAP service: a `cxf:` consumer with schema validation, and 
a `choice` with a `when` per operation
 (on the `CamelCxfOperationName` header) that logs the request and returns a 
placeholder response element. The response
 is validated against the schema too, so until you fill in the placeholder the 
caller gets a SOAP fault that names the
-first element it misses. With `--runtime=camel-main` (the default) the 
consumer listens on `0.0.0.0` and the port and
-path of the address of the WSDL, so `camel run` serves it as it is; with 
`spring-boot` or `quarkus` it uses the path,
-which the CXF servlet of the runtime serves.
+first element it misses. The address of the consumer is the path of the 
address of the WSDL, such as `cxf:/orders`
+for `\http://localhost:8080/orders`. Camel Main (with `camel run`), Spring 
Boot and Quarkus all serve it on their HTTP
+server under `/services`, so the same route runs on each of them, at 
`\http://localhost:8080/services/orders` with the
+default port. See xref:next@components:others:cxf-platform-http.adoc[CXF 
Platform HTTP].
 * `producer` is a SOAP client: a route `direct:<operation>` per operation, 
which takes the request element (XML) as
 the body and returns the response element. It removes the `Camel*` headers and 
the CXF operation headers first, so a
 caller cannot choose another operation or address (such as with 
`CamelDestinationOverrideUrl`).
diff --git 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-generate-wsdl.adoc
 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-generate-wsdl.adoc
index 7f0d92ce3525..47d7b3da591a 100644
--- 
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-generate-wsdl.adoc
+++ 
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-generate-wsdl.adoc
@@ -26,7 +26,6 @@ camel generate wsdl [options]
 | `--output` | The file to write the route to (default: stdout) |  | String
 | `--port` | The port (its name), when the service has more than one |  | 
String
 | `--route` | Scaffold a YAML route (consumer or producer) instead of listing 
the WSDL |  | String
-| `--runtime` | The runtime the route is for (camel-main, spring-boot, 
quarkus): camel-main listens on the address of the WSDL, spring-boot and 
quarkus on its path in their CXF servlet | camel-main | RuntimeType
 | `--service` | The service (its name), when the WSDL has more than one |  | 
String
 | `-h,--help` | Display this help and exit |  | boolean
 |===
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
index c5d970b845ae..828db8e6a357 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/generated/resources/META-INF/camel-jbang-plugin-commands-metadata.json
@@ -1,5 +1,5 @@
 {
   "commands": [
-    { "name": "generate", "fullName": "generate", "description": "Generate 
source code", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.generate.CodeGenerator", "plugin": 
"generate", "options": [ { "names": "-h,--help", "description": "Display this 
help and exit", "javaType": "boolean", "type": "boolean" } ], "subcommands": [ 
{ "name": "rest", "fullName": "generate rest", "description": "Generate REST 
DSL source code from OpenApi specification", "sourceClass": "org.apache.camel 
[...]
+    { "name": "generate", "fullName": "generate", "description": "Generate 
source code", "sourceClass": 
"org.apache.camel.dsl.jbang.core.commands.generate.CodeGenerator", "plugin": 
"generate", "options": [ { "names": "-h,--help", "description": "Display this 
help and exit", "javaType": "boolean", "type": "boolean" } ], "subcommands": [ 
{ "name": "rest", "fullName": "generate rest", "description": "Generate REST 
DSL source code from OpenApi specification", "sourceClass": "org.apache.camel 
[...]
   ]
 }
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGenerator.java
 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGenerator.java
index 8ce42862a2f9..d319b95add25 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGenerator.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGenerator.java
@@ -44,9 +44,6 @@ import 
org.apache.camel.dsl.jbang.core.commands.generate.WsdlModel.WsdlException
 import org.apache.camel.dsl.jbang.core.common.CliExitCode;
 import org.apache.camel.dsl.jbang.core.common.CompletionCandidates;
 import org.apache.camel.dsl.jbang.core.common.JsonOutput;
-import org.apache.camel.dsl.jbang.core.common.RuntimeCompletionCandidates;
-import org.apache.camel.dsl.jbang.core.common.RuntimeTypeConverter;
-import org.apache.camel.dsl.jbang.run.common.RuntimeType;
 import org.apache.camel.util.json.JsonArray;
 import org.apache.camel.util.json.JsonObject;
 
@@ -103,13 +100,6 @@ public class CodeWsdlGenerator extends CamelCommand {
     @Option(name = "operation", description = "The operations to list or 
scaffold (use commas to separate them; default: all)")
     String operation;
 
-    @Option(name = "runtime",
-            description = "The runtime the route is for 
(${COMPLETION-CANDIDATES}): camel-main listens on the address of"
-                          + " the WSDL, spring-boot and quarkus on its path in 
their CXF servlet",
-            defaultValue = "camel-main",
-            completer = RuntimeCompletionCandidates.class, converter = 
RuntimeTypeConverter.class)
-    RuntimeType runtime = RuntimeType.main;
-
     @Override
     public boolean isJsonOutput() {
         return jsonOutput;
@@ -209,7 +199,7 @@ public class CodeWsdlGenerator extends CamelCommand {
         WsdlRouteScaffold scaffold = new WsdlRouteScaffold(p, selected(p, 
operations), wsdlUrl());
         String yaml;
         try {
-            yaml = "consumer".equals(route) ? scaffold.consumer(runtime) : 
scaffold.producer();
+            yaml = "consumer".equals(route) ? scaffold.consumer() : 
scaffold.producer();
         } catch (WsdlException e) {
             return error(CliExitCode.FAILURE, e.getMessage());
         }
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/WsdlRouteScaffold.java
 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/WsdlRouteScaffold.java
index 1a515cd6c71b..72a7e5666862 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/WsdlRouteScaffold.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/WsdlRouteScaffold.java
@@ -32,7 +32,6 @@ import javax.xml.namespace.QName;
 import org.apache.camel.dsl.jbang.core.commands.generate.WsdlModel.Operation;
 import org.apache.camel.dsl.jbang.core.commands.generate.WsdlModel.Port;
 import 
org.apache.camel.dsl.jbang.core.commands.generate.WsdlModel.WsdlException;
-import org.apache.camel.dsl.jbang.run.common.RuntimeType;
 import org.yaml.snakeyaml.DumperOptions;
 import org.yaml.snakeyaml.Yaml;
 
@@ -81,19 +80,14 @@ final class WsdlRouteScaffold {
     }
 
     /**
-     * A route with a cxf: consumer for the port, with a choice of one when 
per operation.
-     *
-     * @param runtime the runtime: camel-main (and the Camel CLI) gets an 
absolute address on 0.0.0.0, spring-boot and
-     *                quarkus the path, which their CXF servlet serves
+     * A route with a cxf: consumer for the port, with a choice of one when 
per operation. The address of the consumer
+     * is the path of the address of the port: Camel Main 
(camel-cxf-platform-http), Spring Boot and Quarkus all serve
+     * it on their HTTP server, under the path of their CXF services (default 
/services).
      */
-    String consumer(RuntimeType runtime) throws WsdlException {
+    String consumer() throws WsdlException {
         check();
-        URI address = address();
-        int p = address.getPort() != -1 ? address.getPort() : DEFAULT_PORT;
-        String path = address.getRawPath();
-        String uri = RuntimeType.springBoot == runtime || RuntimeType.quarkus 
== runtime
-                ? "cxf://" + path
-                : "cxf://http://0.0.0.0:"; + p + path;
+        String path = address().getRawPath();
+        String uri = "cxf:" + path;
 
         Map<String, Object> parameters = new LinkedHashMap<>();
         parameters.put("wsdlURL", wsdlUrl);
@@ -137,9 +131,9 @@ final class WsdlRouteScaffold {
         sb.append("# Each operation returns a placeholder response: replace it 
with the response element.\n");
         sb.append("# The request and the response are validated against the 
schema of the WSDL (schemaValidationEnabled):\n");
         sb.append("# until it is filled in, the placeholder gives a SOAP fault 
that names the first element it misses.\n");
-        if (RuntimeType.springBoot == runtime || RuntimeType.quarkus == 
runtime) {
-            sb.append("# The CXF servlet of the runtime serves the address 
").append(path).append(".\n");
-        }
+        sb.append("# The address is the path ").append(path)
+                .append(" of the WSDL address: the HTTP server of the runtime 
serves it under /services,\n");
+        sb.append("# such as 
http://localhost:8080/services";).append(path).append(" with the default 
port.\n");
         return sb + dump(List.of(Map.of("route", route)));
     }
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGeneratorTest.java
 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGeneratorTest.java
index 1cba3bac1480..b1a49cacdf41 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGeneratorTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeWsdlGeneratorTest.java
@@ -50,8 +50,6 @@ import org.apache.camel.util.json.JsonObject;
 import org.apache.camel.util.json.Jsoner;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -109,7 +107,7 @@ class CodeWsdlGeneratorTest {
         RouteDefinition route = load(yaml).get(0);
         assertThat(route.getId()).isEqualTo("OrderService");
         assertThat(route.getInput().getEndpointUri())
-                .startsWith("cxf://http://0.0.0.0:18081/orders?";)
+                .startsWith("cxf:/orders?")
                 .contains("wsdlURL=file:" + ORDERS, "dataFormat=PAYLOAD", 
"schemaValidationEnabled=true",
                         "serviceName={http://example.com/orders}OrderService";,
                         "portName={http://example.com/orders}OrderPort";);
@@ -152,14 +150,17 @@ class CodeWsdlGeneratorTest {
         
assertThat(load(printer.getStdout())).extracting(RouteDefinition::getId).containsExactly("placeOrder");
     }
 
-    @ParameterizedTest
-    @ValueSource(strings = { "spring-boot", "quarkus" })
-    void aSpringBootOrQuarkusConsumerListensOnThePathOfTheAddress(String 
runtime) throws Exception {
-        assertThat(run(ORDERS, "--route=consumer", "--runtime=" + 
runtime)).as(printer.getOutput()).isZero();
+    @Test
+    void theConsumerAddressIsThePathOfTheWsdlAddress() throws Exception {
+        // the WSDL address is http://localhost:18081/orders: a cxf consumer 
takes only the path, as Camel Main
+        // (camel-cxf-platform-http), Spring Boot and Quarkus serve it on 
their own HTTP server
+        assertThat(run(ORDERS, 
"--route=consumer")).as(printer.getOutput()).isZero();
 
         String yaml = printer.getStdout();
         assertValid(yaml);
-        
assertThat(load(yaml).get(0).getInput().getEndpointUri()).startsWith("cxf:///orders?");
+        String uri = load(yaml).get(0).getInput().getEndpointUri();
+        assertThat(uri).startsWith("cxf:/orders?").doesNotContain("0.0.0.0", 
"localhost", "18081");
+        assertThat(yaml).contains("uri: cxf:/orders\n", 
"http://localhost:8080/services/orders";);
     }
 
     @Test
@@ -190,7 +191,7 @@ class CodeWsdlGeneratorTest {
         assertThat(yaml).doesNotContain("secret", "user", "tenant");
         assertThat(printer.getStderr()).contains("user info", "query");
         RouteDefinition route = load(yaml).get(0);
-        
assertThat(route.getInput().getEndpointUri()).startsWith("cxf://http://0.0.0.0:8443/ws/notify?";);
+        
assertThat(route.getInput().getEndpointUri()).startsWith("cxf:/ws/notify?");
         ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(1);
         // notify is one-way: only a log
         assertThat(choice.getWhenClauses().get(0).getOutputs()).hasSize(1);
@@ -232,7 +233,7 @@ class CodeWsdlGeneratorTest {
                 .as(chosen.getOutput()).isZero();
         assertValid(chosen.getStdout());
         assertThat(load(chosen.getStdout()).get(0).getInput().getEndpointUri())
-                .startsWith("cxf://http://0.0.0.0:9001/stock12?";)
+                .startsWith("cxf:/stock12?")
                 
.contains("portName={http://example.com/stock/service}StockSoap12";);
     }
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/resources/wsdl/expected/orders-consumer.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/resources/wsdl/expected/orders-consumer.camel.yaml
index 9c04e765034e..99ffcbc54dba 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/resources/wsdl/expected/orders-consumer.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/test/resources/wsdl/expected/orders-consumer.camel.yaml
@@ -21,11 +21,13 @@
 # Each operation returns a placeholder response: replace it with the response 
element.
 # The request and the response are validated against the schema of the WSDL 
(schemaValidationEnabled):
 # until it is filled in, the placeholder gives a SOAP fault that names the 
first element it misses.
+# The address is the path /orders of the WSDL address: the HTTP server of the 
runtime serves it under /services,
+# such as http://localhost:8080/services/orders with the default port.
 - route:
     id: OrderService
     description: The OrderService SOAP service, port OrderPort
     from:
-      uri: cxf://http://0.0.0.0:18081/orders
+      uri: cxf:/orders
       parameters:
         wsdlURL: file:src/test/resources/wsdl/orders.wsdl
         serviceName: '{http://example.com/orders}OrderService'

Reply via email to