This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 6a8e80c2f5 Test CXF with WS-Addressing enforced
6a8e80c2f5 is described below
commit 6a8e80c2f57551cc361e89fb6925861d8dcbad0f
Author: Peter Palaga <[email protected]>
AuthorDate: Wed Jun 24 08:11:13 2026 +0200
Test CXF with WS-Addressing enforced
---
.../cxf-soap/cxf-soap-server/pom.xml | 17 ++++++
.../cxf/soap/server/it/CxfSoapRoutes.java | 39 ++++++++++++++
.../soap/server/it/WsAddressingClientResource.java | 39 ++++++++++++++
.../cxf/soap/server/it/WsAddressingService.java | 35 +++++++++++++
.../cxf/soap/server/it/CxfSoapServiceTest.java | 61 ++++++++++++++++++++++
5 files changed, 191 insertions(+)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml
b/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml
index 3f4100acfa..4532fa0f64 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml
+++ b/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml
@@ -39,6 +39,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
@@ -145,6 +149,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-cxf-soap-deployment</artifactId>
diff --git
a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
index e490c41520..a95d403018 100644
---
a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
+++
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java
@@ -42,6 +42,8 @@ import org.apache.camel.util.xml.StringSource;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.ws.addressing.WSAddressingFeature;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
@ApplicationScoped
public class CxfSoapRoutes extends RouteBuilder {
@@ -50,6 +52,9 @@ public class CxfSoapRoutes extends RouteBuilder {
@Named("loggingFeatureServer")
LoggingFeature loggingFeature;
+ @ConfigProperty(name = "quarkus.http.test-port")
+ int httpTestPort;
+
public static final String response = "<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:ser=\"http://it.server.soap.cxf.component.quarkus.camel.apache.org/\">\n"
+
" <soapenv:Header/>\n" +
@@ -121,6 +126,14 @@ public class CxfSoapRoutes extends RouteBuilder {
from(String.format("cxf:textServiceResponseFromImpl?serviceClass=%s&address=/text-service-impl",
TextService.class.getName()))
.toD("bean:" + TextServiceImpl.class.getName() +
"?method=${header.operationName}");
+
+ from("cxf:bean:wsAddressingServerEndpoint")
+ .routeId("ws-addressing-server")
+ .setBody().simple("Hello ${body} from WS-Addressing service");
+
+ from("direct:wsAddressingClient")
+ .routeId("ws-addressing-client")
+ .to("cxf:bean:wsAddressingClientEndpoint");
}
private String alterTextByTextOperation(String operation, String text) {
@@ -187,4 +200,30 @@ public class CxfSoapRoutes extends RouteBuilder {
return result;
}
+ @Produces
+ @ApplicationScoped
+ @Named
+ CxfEndpoint wsAddressingServerEndpoint() {
+ final CxfEndpoint result = new CxfEndpoint();
+ result.setServiceClass(WsAddressingService.class);
+ result.setAddress("/ws-addressing");
+ result.getFeatures().add(loggingFeature);
+ final WSAddressingFeature wsAddr = new WSAddressingFeature();
+ wsAddr.setAddressingRequired(true);
+ result.getFeatures().add(wsAddr);
+ return result;
+ }
+
+ @Produces
+ @ApplicationScoped
+ @Named
+ CxfEndpoint wsAddressingClientEndpoint() {
+ final CxfEndpoint result = new CxfEndpoint();
+ result.setServiceClass(WsAddressingService.class);
+ result.setAddress("http://localhost:" + httpTestPort +
"/soapservice/ws-addressing");
+ result.getFeatures().add(loggingFeature);
+ result.getFeatures().add(new WSAddressingFeature());
+ return result;
+ }
+
}
diff --git
a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingClientResource.java
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingClientResource.java
new file mode 100644
index 0000000000..895e06d5fb
--- /dev/null
+++
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingClientResource.java
@@ -0,0 +1,39 @@
+/*
+ * 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.quarkus.component.cxf.soap.server.it;
+
+import jakarta.inject.Inject;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.ProducerTemplate;
+
+@Path("/cxf-soap-server/ws-addressing")
+public class WsAddressingClientResource {
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @POST
+ @Path("/client/hello")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String hello(String body) {
+ return producerTemplate.requestBody("direct:wsAddressingClient", body,
String.class);
+ }
+
+}
diff --git
a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingService.java
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingService.java
new file mode 100644
index 0000000000..1793d0af08
--- /dev/null
+++
b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/WsAddressingService.java
@@ -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.
+ */
+package org.apache.camel.quarkus.component.cxf.soap.server.it;
+
+import jakarta.jws.WebMethod;
+import jakarta.jws.WebParam;
+import jakarta.jws.WebResult;
+import jakarta.jws.WebService;
+import jakarta.jws.soap.SOAPBinding;
+import jakarta.jws.soap.SOAPBinding.ParameterStyle;
+
+@WebService(targetNamespace = WsAddressingService.TARGET_NS, name =
"WsAddressingService", serviceName = "WsAddressingService")
+@SOAPBinding(parameterStyle = ParameterStyle.BARE)
+public interface WsAddressingService {
+ String TARGET_NS =
"http://it.server.soap.cxf.component.quarkus.camel.apache.org/wsaddressing";
+ String HELLO_ACTION = TARGET_NS + "/WsAddressingService/hello";
+
+ @WebMethod(operationName = "hello", action = HELLO_ACTION)
+ @WebResult(name = "helloResponse", targetNamespace = TARGET_NS)
+ String hello(@WebParam(name = "helloRequest", targetNamespace = TARGET_NS)
String text);
+}
diff --git
a/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java
b/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java
index b292b6e23a..5281b8565a 100644
---
a/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java
+++
b/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java
@@ -34,6 +34,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static
io.quarkiverse.cxf.test.internal.QuarkusCxfInternalTestUtil.anyNs;
+import static io.restassured.RestAssured.given;
@QuarkusTest
class CxfSoapServiceTest {
@@ -111,4 +112,64 @@ class CxfSoapServiceTest {
Assertions.assertEquals(input.toLowerCase(),
textService.lowerCase(input));
}
+ @Test
+ public void wsAddressingWithHeaders() {
+ final String soapRequest = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
+ + " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""
+ + " xmlns:ns=\"" + WsAddressingService.TARGET_NS + "\">\n"
+ + " <soap:Header>\n"
+ + " <wsa:Action>" + WsAddressingService.HELLO_ACTION +
"</wsa:Action>\n"
+ + "
<wsa:MessageID>urn:uuid:12345678-1234-1234-1234-123456789012</wsa:MessageID>\n"
+ + " <wsa:ReplyTo>\n"
+ + "
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>\n"
+ + " </wsa:ReplyTo>\n"
+ + " <wsa:To>" + getServerUrl() +
"/soapservice/ws-addressing</wsa:To>\n"
+ + " </soap:Header>\n"
+ + " <soap:Body>\n"
+ + " <ns:helloRequest>World</ns:helloRequest>\n"
+ + " </soap:Body>\n"
+ + "</soap:Envelope>";
+
+ given()
+ .header("Content-Type", "text/xml")
+ .body(soapRequest)
+ .when()
+ .post("/soapservice/ws-addressing")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.containsString("Hello World from
WS-Addressing service"));
+ }
+
+ @Test
+ public void wsAddressingWithoutHeaders() {
+ final String soapRequest = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
+ + " xmlns:ns=\"" + WsAddressingService.TARGET_NS + "\">\n"
+ + " <soap:Header/>\n"
+ + " <soap:Body>\n"
+ + " <ns:helloRequest>World</ns:helloRequest>\n"
+ + " </soap:Body>\n"
+ + "</soap:Envelope>";
+
+ given()
+ .header("Content-Type", "text/xml")
+ .body(soapRequest)
+ .when()
+ .post("/soapservice/ws-addressing")
+ .then()
+ .statusCode(500)
+ .body(CoreMatchers
+ .containsString("A required header representing a
Message Addressing Property is not present"));
+ }
+
+ @Test
+ public void wsAddressingClient() {
+ given()
+ .body("CamelClient")
+ .when()
+ .post("/cxf-soap-server/ws-addressing/client/hello")
+ .then()
+ .statusCode(200)
+ .body(CoreMatchers.containsString("Hello CamelClient from
WS-Addressing service"));
+ }
+
}