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 f81c18abb630 CAMEL-27374: camel-cxf - a producer with wsdlURL and no
address uses the soap:address of the WSDL (#30586)
f81c18abb630 is described below
commit f81c18abb630c6d59114212c9a1b3b7cef6073ef
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 11:31:47 2026 +0100
CAMEL-27374: camel-cxf - a producer with wsdlURL and no address uses the
soap:address of the WSDL (#30586)
A cxf: producer given only wsdlURL, serviceName and portName
(cxf://?wsdlURL=...)
failed with "URI with undefined scheme". The endpoint address is the empty
remaining part of the URI, and CxfEndpoint passed it to the CXF
ClientFactoryBean, where a non-null address replaces the address of the port
in the WSDL.
An empty address is now passed as no address, so CXF uses the address that
the WSDL gives for the port, as it already did for a CxfEndpoint bean
without
an address. The consumer is unchanged, as an empty or relative address is
meaningful there (servlet transport).
Signed-off-by: Claus Ibsen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../org/apache/camel/catalog/components/cxf.json | 2 +-
.../apache/camel/catalog/docs/cxf-component.adoc | 8 +++
.../org/apache/camel/component/cxf/jaxws/cxf.json | 2 +-
.../src/main/docs/cxf-component.adoc | 8 +++
.../camel/component/cxf/jaxws/CxfEndpoint.java | 12 ++--
.../cxf/jaxws/CxfProducerWsdlAddressTest.java | 79 ++++++++++++++++++++++
.../builder/endpoint/StaticEndpointBuilders.java | 12 ++--
.../endpoint/dsl/CxfEndpointBuilderFactory.java | 12 ++--
8 files changed, 121 insertions(+), 14 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json
index 7851f4f5e994..466640e6e11f 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json
@@ -49,7 +49,7 @@
},
"properties": {
"beanId": { "index": 0, "kind": "path", "displayName": "Bean Id", "group":
"common", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The id of a CxfEndpoint bean in the registry to use as this
endpoint. Written in the path of the endpoint URI in place of the service
address, with the prefix bean:, for example bean:orderEndpoint. The component
sets the options of the endpoint UR [...]
- "address": { "index": 1, "kind": "path", "displayName": "Address",
"group": "service", "label": "service", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The service address, for example
http:\/\/localhost:9000\/orders. The consumer receives requests at this
address, and the producer sends requests to it. The CamelDestinationOverrideUrl
header replaces this address for a request that the p [...]
+ "address": { "index": 1, "kind": "path", "displayName": "Address",
"group": "service", "label": "service", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The service address, for example
http:\/\/localhost:9000\/orders. The consumer receives requests at this
address, and the producer sends requests to it. A producer with no address
sends requests to the address that the WSDL (see wsdlURL) [...]
"dataFormat": { "index": 2, "kind": "parameter", "displayName": "Data
Format", "group": "common", "label": "", "required": false, "type": "enum",
"javaType": "org.apache.camel.component.cxf.common.DataFormat", "enum": [
"PAYLOAD", "RAW", "MESSAGE", "CXF_MESSAGE", "POJO" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "POJO", "description":
"How the SOAP message is represented in the Camel message body. POJO: the
parameters of the operation as Java objects [...]
"wrappedStyle": { "index": 3, "kind": "parameter", "displayName": "Wrapped
Style", "group": "common", "label": "", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "description": "Whether to use the document-literal wrapped
style instead of the document-literal bare style for the operations of
serviceClass. Not used for RPC-style operations or when serviceClass is a
Provider. Otherwise, if not set, CXF us [...]
"muteException": { "index": 4, "kind": "parameter", "displayName": "Mute
Exception", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to hide
the exception of a failed exchange from the client. If true, the fault that the
consumer returns does not contain the class or the message of the exception.
This does not apply to a CXF Fa [...]
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 025de9a0256c..94d386e0b242 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
@@ -54,6 +54,14 @@ cxf://someAddress[?options]
Where `someAddress` specifies the CXF endpoint's address. With this URI
format, most of the endpoint details are specified using options.
+A producer can leave out the address when it has a `wsdlURL`: it then sends
the requests to the address that the
+WSDL gives for the port (the `location` of its `soap:address`). Set
`serviceName` and `portName` when the WSDL has
+more than one service or port:
+
+----
+cxf://?wsdlURL=classpath:wsdl/orders.wsdl&serviceName={http://example.com/orders}OrderService&portName={http://example.com/orders}OrderPort&dataFormat=PAYLOAD
+----
+
For either style above, you can append options to the URI as follows:
----
diff --git
a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json
b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json
index 7851f4f5e994..466640e6e11f 100644
---
a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json
+++
b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json
@@ -49,7 +49,7 @@
},
"properties": {
"beanId": { "index": 0, "kind": "path", "displayName": "Bean Id", "group":
"common", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "The id of a CxfEndpoint bean in the registry to use as this
endpoint. Written in the path of the endpoint URI in place of the service
address, with the prefix bean:, for example bean:orderEndpoint. The component
sets the options of the endpoint UR [...]
- "address": { "index": 1, "kind": "path", "displayName": "Address",
"group": "service", "label": "service", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The service address, for example
http:\/\/localhost:9000\/orders. The consumer receives requests at this
address, and the producer sends requests to it. The CamelDestinationOverrideUrl
header replaces this address for a request that the p [...]
+ "address": { "index": 1, "kind": "path", "displayName": "Address",
"group": "service", "label": "service", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The service address, for example
http:\/\/localhost:9000\/orders. The consumer receives requests at this
address, and the producer sends requests to it. A producer with no address
sends requests to the address that the WSDL (see wsdlURL) [...]
"dataFormat": { "index": 2, "kind": "parameter", "displayName": "Data
Format", "group": "common", "label": "", "required": false, "type": "enum",
"javaType": "org.apache.camel.component.cxf.common.DataFormat", "enum": [
"PAYLOAD", "RAW", "MESSAGE", "CXF_MESSAGE", "POJO" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "POJO", "description":
"How the SOAP message is represented in the Camel message body. POJO: the
parameters of the operation as Java objects [...]
"wrappedStyle": { "index": 3, "kind": "parameter", "displayName": "Wrapped
Style", "group": "common", "label": "", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "description": "Whether to use the document-literal wrapped
style instead of the document-literal bare style for the operations of
serviceClass. Not used for RPC-style operations or when serviceClass is a
Provider. Otherwise, if not set, CXF us [...]
"muteException": { "index": 4, "kind": "parameter", "displayName": "Mute
Exception", "group": "consumer", "label": "consumer", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "description": "Whether to hide
the exception of a failed exchange from the client. If true, the fault that the
consumer returns does not contain the class or the message of the exception.
This does not apply to a CXF Fa [...]
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 025de9a0256c..94d386e0b242 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
@@ -54,6 +54,14 @@ cxf://someAddress[?options]
Where `someAddress` specifies the CXF endpoint's address. With this URI
format, most of the endpoint details are specified using options.
+A producer can leave out the address when it has a `wsdlURL`: it then sends
the requests to the address that the
+WSDL gives for the port (the `location` of its `soap:address`). Set
`serviceName` and `portName` when the WSDL has
+more than one service or port:
+
+----
+cxf://?wsdlURL=classpath:wsdl/orders.wsdl&serviceName={http://example.com/orders}OrderService&portName={http://example.com/orders}OrderPort&dataFormat=PAYLOAD
+----
+
For either style above, you can append options to the URI as follows:
----
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 648eb94e4623..3a446a17b255 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
@@ -255,8 +255,10 @@ public class CxfEndpoint extends DefaultEndpoint
implements AsyncEndpoint, Heade
private DataFormat dataFormat = DataFormat.POJO;
@UriPath(label = "service",
description = "The service address, for example
http://localhost:9000/orders. The consumer receives requests at"
- + " this address, and the producer sends requests
to it. The CamelDestinationOverrideUrl header"
- + " replaces this address for a request that the
producer sends over HTTP.")
+ + " this address, and the producer sends requests
to it. A producer with no address sends"
+ + " requests to the address that the WSDL (see
wsdlURL) gives for the port. The"
+ + " CamelDestinationOverrideUrl header replaces
this address for a request that the producer"
+ + " sends over HTTP.")
private String address;
@UriParam(label = "service")
private String wsdlURL;
@@ -744,8 +746,10 @@ public class CxfEndpoint extends DefaultEndpoint
implements AsyncEndpoint, Heade
setServiceFactory(factoryBean, serviceFactoryBean);
}
- // address
- factoryBean.setAddress(getAddress());
+ // address: an empty address (cxf:// with no address) is no address,
so CXF uses the address of the port in
+ // the WSDL instead of overriding it with an empty one
+ String address = getAddress();
+ factoryBean.setAddress(ObjectHelper.isEmpty(address) ? null : address);
// wsdl url
if (getWsdlURL() != null) {
diff --git
a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfProducerWsdlAddressTest.java
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfProducerWsdlAddressTest.java
new file mode 100644
index 000000000000..afc3fba20162
--- /dev/null
+++
b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfProducerWsdlAddressTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.jaxws;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * A producer with no address in its URI calls the address that the WSDL gives
for the port.
+ */
+public class CxfProducerWsdlAddressTest extends CamelTestSupport {
+
+ private static final String SERVICE =
"serviceName={http://camel.apache.org/wsdl-first}PersonService"
+ +
"&portName={http://camel.apache.org/wsdl-first}soap";
+
+ private static final String REQUEST
+ = "<GetPerson
xmlns=\"http://camel.apache.org/wsdl-first/types\"><personId>1</personId></GetPerson>";
+
+ private static final String RESPONSE
+ = "<GetPersonResponse
xmlns=\"http://camel.apache.org/wsdl-first/types\">"
+ +
"<personId>1</personId><ssn>000-000-0000</ssn><name>Bonjour</name></GetPersonResponse>";
+
+ private static AvailablePortFinder.Port port;
+
+ @BeforeAll
+ static void allocatePorts() {
+ port = AvailablePortFinder.find();
+ }
+
+ @AfterAll
+ static void releasePorts() {
+ if (port != null) {
+ port.release();
+ }
+ }
+
+ private static String serviceAddress() {
+ return "http://localhost:" + port.getPort() +
"/CxfProducerWsdlAddressTest/PersonService";
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ // the WSDL this service serves at ?wsdl has its own address
as the soap:address of the port
+ from("cxf://" + serviceAddress() +
"?wsdlURL=classpath:person.wsdl&dataFormat=PAYLOAD&" + SERVICE)
+ .setBody(constant(RESPONSE));
+ }
+ };
+ }
+
+ @Test
+ public void testAddressFromWsdl() {
+ String uri = "cxf://?wsdlURL=RAW(" + serviceAddress() +
"?wsdl)&dataFormat=PAYLOAD&defaultOperationName=GetPerson&"
+ + SERVICE;
+ String reply = template.requestBody(uri, REQUEST, String.class);
+ assertTrue(reply.contains("<name>Bonjour</name>"), reply);
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index f29d4b3e9bff..c1b8677f9c61 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -4464,8 +4464,10 @@ public class StaticEndpointBuilders {
* Path parameter: address
* The service address, for example http://localhost:9000/orders. The
* consumer receives requests at this address, and the producer sends
- * requests to it. The CamelDestinationOverrideUrl header replaces this
- * address for a request that the producer sends over HTTP.
+ * requests to it. A producer with no address sends requests to the address
+ * that the WSDL (see wsdlURL) gives for the port. The
+ * CamelDestinationOverrideUrl header replaces this address for a request
+ * that the producer sends over HTTP.
*
* @param path beanId:address
* @return the dsl builder
@@ -4494,8 +4496,10 @@ public class StaticEndpointBuilders {
* Path parameter: address
* The service address, for example http://localhost:9000/orders. The
* consumer receives requests at this address, and the producer sends
- * requests to it. The CamelDestinationOverrideUrl header replaces this
- * address for a request that the producer sends over HTTP.
+ * requests to it. A producer with no address sends requests to the address
+ * that the WSDL (see wsdlURL) gives for the port. The
+ * CamelDestinationOverrideUrl header replaces this address for a request
+ * that the producer sends over HTTP.
*
* @param componentName to use a custom component name for the endpoint
* instead of the default name
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java
index 943ea8a0beb0..69338eacaff4 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java
@@ -2979,8 +2979,10 @@ public interface CxfEndpointBuilderFactory {
* Path parameter: address
* The service address, for example http://localhost:9000/orders. The
* consumer receives requests at this address, and the producer sends
- * requests to it. The CamelDestinationOverrideUrl header replaces this
- * address for a request that the producer sends over HTTP.
+ * requests to it. A producer with no address sends requests to the
+ * address that the WSDL (see wsdlURL) gives for the port. The
+ * CamelDestinationOverrideUrl header replaces this address for a
+ * request that the producer sends over HTTP.
*
* @param path beanId:address
* @return the dsl builder
@@ -3010,8 +3012,10 @@ public interface CxfEndpointBuilderFactory {
* Path parameter: address
* The service address, for example http://localhost:9000/orders. The
* consumer receives requests at this address, and the producer sends
- * requests to it. The CamelDestinationOverrideUrl header replaces this
- * address for a request that the producer sends over HTTP.
+ * requests to it. A producer with no address sends requests to the
+ * address that the WSDL (see wsdlURL) gives for the port. The
+ * CamelDestinationOverrideUrl header replaces this address for a
+ * request that the producer sends over HTTP.
*
* @param componentName to use a custom component name for the endpoint
* instead of the default name