diff --git a/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc b/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc index a6f244250fe8..0543f403b478 100644 --- a/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc @@ -68,7 +68,6 @@ With `camel-quarkus-cxf-soap` (no additional dependencies required), you can use ---- import org.apache.camel.builder.RouteBuilder; import {javaxOrJakartaPackagePrefix}.enterprise.context.ApplicationScoped; -import {javaxOrJakartaPackagePrefix}.enterprise.context.SessionScoped; import {javaxOrJakartaPackagePrefix}.enterprise.inject.Produces; import {javaxOrJakartaPackagePrefix}.inject.Named; @@ -89,7 +88,7 @@ public class CxfSoapClientRoutes extends RouteBuilder { } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint beanClient() { final CxfEndpoint result = new CxfEndpoint(); @@ -219,7 +218,6 @@ You can enable verbose logging of SOAP messages for both clients and servers wit import org.apache.camel.builder.RouteBuilder; import org.apache.cxf.ext.logging.LoggingFeature; import {javaxOrJakartaPackagePrefix}.enterprise.context.ApplicationScoped; -import {javaxOrJakartaPackagePrefix}.enterprise.context.SessionScoped; import {javaxOrJakartaPackagePrefix}.enterprise.inject.Produces; import {javaxOrJakartaPackagePrefix}.inject.Named; @@ -240,7 +238,7 @@ public class MyBeans { LoggingFeature prettyLoggingFeature; @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint cxfBeanClient() { final CxfEndpoint result = new CxfEndpoint(); diff --git a/extensions/cxf-soap/runtime/src/main/doc/usage.adoc b/extensions/cxf-soap/runtime/src/main/doc/usage.adoc index cc7a00ec1072..40baca10db6f 100644 --- a/extensions/cxf-soap/runtime/src/main/doc/usage.adoc +++ b/extensions/cxf-soap/runtime/src/main/doc/usage.adoc @@ -17,7 +17,6 @@ With `camel-quarkus-cxf-soap` (no additional dependencies required), you can use ---- import org.apache.camel.builder.RouteBuilder; import {javaxOrJakartaPackagePrefix}.enterprise.context.ApplicationScoped; -import {javaxOrJakartaPackagePrefix}.enterprise.context.SessionScoped; import {javaxOrJakartaPackagePrefix}.enterprise.inject.Produces; import {javaxOrJakartaPackagePrefix}.inject.Named; @@ -38,7 +37,7 @@ public class CxfSoapClientRoutes extends RouteBuilder { } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint beanClient() { final CxfEndpoint result = new CxfEndpoint(); @@ -166,7 +165,6 @@ You can enable verbose logging of SOAP messages for both clients and servers wit import org.apache.camel.builder.RouteBuilder; import org.apache.cxf.ext.logging.LoggingFeature; import {javaxOrJakartaPackagePrefix}.enterprise.context.ApplicationScoped; -import {javaxOrJakartaPackagePrefix}.enterprise.context.SessionScoped; import {javaxOrJakartaPackagePrefix}.enterprise.inject.Produces; import {javaxOrJakartaPackagePrefix}.inject.Named; @@ -187,7 +185,7 @@ public class MyBeans { LoggingFeature prettyLoggingFeature; @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint cxfBeanClient() { final CxfEndpoint result = new CxfEndpoint(); diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java index 7b81ad47821a..ce0fc7baa1fb 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java @@ -23,7 +23,6 @@ import com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -63,7 +62,7 @@ public class CxfSoapClientRoutes extends RouteBuilder { public void configure() { from("direct:simpleUriBean") - .to("cxf:bean:soapClientEndpoint?dataFormat=POJO"); + .to("cxf:bean:soapClientEndpointPojo"); from("direct:simpleUriAddress") .to(String.format("cxf://%s?wsdlURL=%s&dataFormat=POJO&serviceClass=%s", calculatorServiceAddress(), @@ -85,17 +84,17 @@ public void configure() { } } }) - .toD("cxf:bean:soapClientEndpoint?dataFormat=${header.endpointDataFormat}"); + .toD("cxf:bean:soapClientEndpoint${header.endpointDataFormat}"); from("direct:operandsAdd") .setHeader(CxfConstants.OPERATION_NAME).constant("addOperands") - .to("cxf:bean:soapClientEndpoint?dataFormat=POJO"); + .to("cxf:bean:soapClientEndpointPojo"); from("direct:basicAuthAdd") - .to("cxf:bean:basicAuthClientEndpoint?dataFormat=POJO&username={{cq.cxf.it.calculator.auth.basic.user}}&password={{cq.cxf.it.calculator.auth.basic.password}}"); + .to("cxf:bean:basicAuthAddClientEndpoint?username={{cq.cxf.it.calculator.auth.basic.user}}&password={{cq.cxf.it.calculator.auth.basic.password}}"); from("direct:basicAuthAddAnonymous") - .to("cxf:bean:basicAuthClientEndpoint?dataFormat=POJO"); + .to("cxf:bean:basicAuthAddAnonymousClientEndpoint"); } @@ -109,10 +108,29 @@ public LoggingFeature loggingFeature() { } @Produces - @SessionScoped + @ApplicationScoped @Named - CxfEndpoint soapClientEndpoint() { + CxfEndpoint soapClientEndpointPojo() { + return soapClientCxfEndpoint(DataFormat.POJO); + } + + @Produces + @ApplicationScoped + @Named("soapClientEndpointRAW") + CxfEndpoint soapClientEndpointRaw() { + return soapClientCxfEndpoint(DataFormat.RAW); + } + + @Produces + @ApplicationScoped + @Named("soapClientEndpointCXF_MESSAGE") + CxfEndpoint soapClientEndpointCxfMessage() { + return soapClientCxfEndpoint(DataFormat.CXF_MESSAGE); + } + + private CxfEndpoint soapClientCxfEndpoint(DataFormat dataFormat) { final CxfEndpoint result = new CxfEndpoint(); + result.setDataFormat(dataFormat); result.setServiceClass(CalculatorService.class); result.setAddress(calculatorServiceAddress()); result.setWsdlURL(calculatorServiceWsdlUrl()); @@ -121,10 +139,22 @@ CxfEndpoint soapClientEndpoint() { } @Produces - @SessionScoped + @ApplicationScoped @Named - CxfEndpoint basicAuthClientEndpoint() { + CxfEndpoint basicAuthAddClientEndpoint() { + return basicAuthCxfEndpoint(); + } + + @Produces + @ApplicationScoped + @Named + CxfEndpoint basicAuthAddAnonymousClientEndpoint() { + return basicAuthCxfEndpoint(); + } + + private CxfEndpoint basicAuthCxfEndpoint() { final CxfEndpoint result = new CxfEndpoint(); + result.setDataFormat(DataFormat.POJO); result.setServiceClass(BasicAuthCalculatorService.class); result.setAddress(serviceBaseUri + "/calculator-ws/BasicAuthCalculatorService"); result.setWsdlURL("wsdl/BasicAuthCalculatorService.wsdl"); diff --git a/integration-test-groups/cxf-soap/cxf-soap-converter/src/main/java/org/apache/camel/quarkus/component/cxf/soap/converter/it/CxfSoapConverterRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-converter/src/main/java/org/apache/camel/quarkus/component/cxf/soap/converter/it/CxfSoapConverterRoutes.java index 6bc29a7588c1..07112a753544 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-converter/src/main/java/org/apache/camel/quarkus/component/cxf/soap/converter/it/CxfSoapConverterRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-converter/src/main/java/org/apache/camel/quarkus/component/cxf/soap/converter/it/CxfSoapConverterRoutes.java @@ -30,12 +30,12 @@ import io.quarkus.runtime.LaunchMode; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import jakarta.inject.Named; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.cxf.common.CxfPayload; +import org.apache.camel.component.cxf.common.DataFormat; import org.apache.camel.component.cxf.jaxws.CxfEndpoint; import org.apache.camel.converter.jaxp.XmlConverter; import org.apache.camel.wsdl_first.types.GetPerson; @@ -86,9 +86,9 @@ public void configure() { new ArrayList(), elements, null); exchange.getIn().setBody(payload); }) - .toD("cxf:bean:soapConverterEndpoint?address=${header.address}&dataFormat=PAYLOAD"); + .toD("cxf:bean:soapConverterEndpoint?address=${header.address}"); - from("cxf:bean:soapConverterEndpoint?dataFormat=PAYLOAD") + from("cxf:bean:soapConverterEndpointConsumer") .process(exchange -> { String operation = exchange.getIn().getHeader("operation", String.class); if ("pojo".equals(operation)) { @@ -130,16 +130,24 @@ public void configure() { } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint soapConverterEndpoint() { final CxfEndpoint result = new CxfEndpoint(); + result.setDataFormat(DataFormat.PAYLOAD); result.getFeatures().add(loggingFeature); result.setServiceClass(org.apache.camel.wsdl_first.Person.class); result.setAddress("/PayLoadConvert/RouterPort"); return result; } + @Produces + @ApplicationScoped + @Named + CxfEndpoint soapConverterEndpointConsumer() { + return soapConverterEndpoint(); + } + @Produces @ApplicationScoped @Named("loggingFeatureConverter") diff --git a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java index 021345fcf1de..367ed7ebd126 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-metrics/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/metrics/CxfSoapMetricsRoutes.java @@ -20,11 +20,11 @@ import io.quarkiverse.cxf.metrics.QuarkusCxfMetricsFeature; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Named; import org.apache.camel.Message; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.cxf.common.DataFormat; import org.apache.camel.component.cxf.jaxws.CxfEndpoint; import org.apache.camel.quarkus.component.cxf.soap.it.metrics.service.HelloService; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -39,7 +39,7 @@ public class CxfSoapMetricsRoutes extends RouteBuilder { public void configure() { from("direct:clientMetrics") - .to("cxf:bean:clientMetricsEndpoint?dataFormat=POJO"); + .to("cxf:bean:clientMetricsEndpoint"); from("cxf:bean:metricsServiceEndpoint") .process(e -> { @@ -56,10 +56,11 @@ public void configure() { } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint clientMetricsEndpoint() { final CxfEndpoint result = new CxfEndpoint(); + result.setDataFormat(DataFormat.POJO); result.setServiceClass(HelloService.class); result.setAddress("http://localhost:" + port + "/soapservice/hello-metrics"); result.setWsdlURL("wsdl/MetricsHelloService.wsdl"); diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomRoutes.java index 40a62e09d615..28e8808fc4e6 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomRoutes.java @@ -32,7 +32,6 @@ import io.quarkus.runtime.LaunchMode; import jakarta.activation.DataHandler; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -111,6 +110,11 @@ public void configure() { Map headers = exchange.getIn().getHeaders(); String endpointDataFormat = headers.get("endpointDataFormat").toString(); boolean mtomEnabled = Boolean.parseBoolean(headers.get("mtomEnabled").toString()); + if (mtomEnabled) { + headers.put("endpointName", "soapClientMtomEnabledEndpoint" + endpointDataFormat); + } else { + headers.put("endpointName", "soapClientMtomDisabledEndpoint" + endpointDataFormat); + } headers.put("address", getServerUrl() + "/soapservice/mtom-" + (mtomEnabled ? "enabled" : "disabled") + "-" + endpointDataFormat.toLowerCase() + "-mode-image-service"); @@ -142,10 +146,7 @@ public void configure() { } } }) - .choice().when(simple("${header.mtomEnabled} == 'true'")) - .toD("cxf:bean:soapClientMtomEnabledEndpoint?address=${header.address}&mtomEnabled=${header.mtomEnabled}&dataFormat=${header.endpointDataFormat}") - .otherwise() - .toD("cxf:bean:soapClientMtomDisabledEndpoint?address=${header.address}&mtomEnabled=${header.mtomEnabled}&dataFormat=${header.endpointDataFormat}"); + .toD("cxf:bean:${header.endpointName}?address=${header.address}&mtomEnabled=${header.mtomEnabled}&dataFormat=${header.endpointDataFormat}"); from("cxf:bean:soapMtomEnabledServerPojoModeEndpoint?dataFormat=POJO") .to("direct:pojoModeProcessor"); @@ -258,42 +259,56 @@ public LoggingFeature loggingFeature() { } @Produces - @SessionScoped - @Named - CxfEndpoint soapClientMtomEnabledEndpoint() { + @ApplicationScoped + @Named("soapClientMtomEnabledEndpointPOJO") + CxfEndpoint soapClientMtomEnabledEndpointPojo() { return commonCxfEndpoint(true, ""); } @Produces - @SessionScoped - @Named - CxfEndpoint soapClientMtomDisabledEndpoint() { + @ApplicationScoped + @Named("soapClientMtomEnabledEndpointPAYLOAD") + CxfEndpoint soapClientMtomEnabledEndpointPayload() { + return commonCxfEndpoint(true, ""); + } + + @Produces + @ApplicationScoped + @Named("soapClientMtomDisabledEndpointPOJO") + CxfEndpoint soapClientMtomDisabledEndpointPojo() { return commonCxfEndpoint(false, ""); } @Produces - @SessionScoped + @ApplicationScoped + @Named("soapClientMtomDisabledEndpointPAYLOAD") + CxfEndpoint soapClientMtomDisabledEndpointPayload() { + return commonCxfEndpoint(false, ""); + } + + @Produces + @ApplicationScoped @Named CxfEndpoint soapMtomDisabledServerPayloadModeEndpoint() { return commonCxfEndpoint(false, "/mtom-disabled-payload-mode-image-service"); } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint soapMtomEnabledServerPayloadModeEndpoint() { return commonCxfEndpoint(true, "/mtom-enabled-payload-mode-image-service"); } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint soapMtomEnabledServerPojoModeEndpoint() { return commonCxfEndpoint(true, "/mtom-enabled-pojo-mode-image-service"); } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint soapMtomDisabledServerPojoModeEndpoint() { return commonCxfEndpoint(false, "/mtom-disabled-pojo-mode-image-service"); diff --git a/integration-test-groups/cxf-soap/cxf-soap-rest/src/main/java/org/apache/camel/quarkus/component/cxf/soap/rest/it/CxfSoapRestRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-rest/src/main/java/org/apache/camel/quarkus/component/cxf/soap/rest/it/CxfSoapRestRoutes.java index 3d6ea3d029c0..2ab7400fd793 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-rest/src/main/java/org/apache/camel/quarkus/component/cxf/soap/rest/it/CxfSoapRestRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-rest/src/main/java/org/apache/camel/quarkus/component/cxf/soap/rest/it/CxfSoapRestRoutes.java @@ -17,7 +17,6 @@ package org.apache.camel.quarkus.component.cxf.soap.rest.it; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -66,7 +65,7 @@ public LoggingFeature loggingFeatureRest() { } @Produces - @SessionScoped + @ApplicationScoped @Named CxfEndpoint soapClientRestEndpoint() { final CxfEndpoint result = new CxfEndpoint(); diff --git a/integration-test-groups/cxf-soap/cxf-soap-ssl/src/main/java/org/apache/camel/quarkus/component/cxf/soap/ssl/it/CxfSoapSslRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-ssl/src/main/java/org/apache/camel/quarkus/component/cxf/soap/ssl/it/CxfSoapSslRoutes.java index e051dc0e42d7..a29dd2ef1b29 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ssl/src/main/java/org/apache/camel/quarkus/component/cxf/soap/ssl/it/CxfSoapSslRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-ssl/src/main/java/org/apache/camel/quarkus/component/cxf/soap/ssl/it/CxfSoapSslRoutes.java @@ -20,7 +20,6 @@ import io.quarkus.runtime.LaunchMode; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -82,13 +81,13 @@ public void configure() { }) .toD("cxf:bean:${header.endpoint}?address=${header.address}"); - from("cxf:bean:soapSslRouter") + from("cxf:bean:soapSslRouterConsumer") .process("responseProcessor"); } @Produces - @SessionScoped + @ApplicationScoped @Named("soapSslLocalCorrect") CxfEndpoint soapSslLocalCorrect(DefaultHostnameVerifier defaultHostnameVerifier) { final CxfEndpoint result = new CxfEndpoint(); @@ -101,7 +100,7 @@ CxfEndpoint soapSslLocalCorrect(DefaultHostnameVerifier defaultHostnameVerifier) } @Produces - @SessionScoped + @ApplicationScoped @Named("soapSslLocalWrong") CxfEndpoint soapSslLocalWrong(DefaultHostnameVerifier defaultHostnameVerifier) { final CxfEndpoint result = new CxfEndpoint(); @@ -114,7 +113,7 @@ CxfEndpoint soapSslLocalWrong(DefaultHostnameVerifier defaultHostnameVerifier) { } @Produces - @SessionScoped + @ApplicationScoped @Named("soapSslGlobal") CxfEndpoint soapSslGlobal() { final CxfEndpoint result = new CxfEndpoint(); @@ -125,7 +124,7 @@ CxfEndpoint soapSslGlobal() { } @Produces - @SessionScoped + @ApplicationScoped @Named("soapSslRouter") CxfEndpoint soapSslRouter() { final CxfEndpoint result = new CxfEndpoint(); @@ -136,7 +135,14 @@ CxfEndpoint soapSslRouter() { } @Produces - @SessionScoped + @ApplicationScoped + @Named("soapSslRouterConsumer") + CxfEndpoint soapSslRouterConsumer() { + return soapSslRouter(); + } + + @Produces + @ApplicationScoped @Named GreeterService greeterService() { return new GreeterImpl();