This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/4.0.x-fixes by this push:
new 263dc47ea4 [CXF-9119]Spring Boot runtime : property placeholder in xml
bean of jaxws:client not resolved correctly
263dc47ea4 is described below
commit 263dc47ea4b4f44f996154553ad23b7fd1216676
Author: Freeman Fang <[email protected]>
AuthorDate: Fri Mar 14 15:14:22 2025 -0400
[CXF-9119]Spring Boot runtime : property placeholder in xml bean of
jaxws:client not resolved correctly
(cherry picked from commit 45949fc629c4d6922480717fa0672580abf1fee1)
---
.../jaxws/CxfJaxwsAutoConfiguration.java | 2 +-
.../systest/jaxws/spring/boot/SpringJaxwsTest.java | 31 +++++++++++++++++++-
.../src/test/resources/application-jaxws.yml | 4 ++-
.../src/test/resources/spring/jaxws-client.xml | 34 ++++++++++++++++++++++
4 files changed, 68 insertions(+), 3 deletions(-)
diff --git
a/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/jaxws/CxfJaxwsAutoConfiguration.java
b/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/jaxws/CxfJaxwsAutoConfiguration.java
index c4d41b38e0..c8cb94fdcf 100644
---
a/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/jaxws/CxfJaxwsAutoConfiguration.java
+++
b/integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/jaxws/CxfJaxwsAutoConfiguration.java
@@ -39,7 +39,7 @@ public class CxfJaxwsAutoConfiguration {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory
beanFactory) throws BeansException {
- final var beans =
beanFactory.getBeansOfType(CommonAnnotationBeanPostProcessor.class);
+ final var beans =
beanFactory.getBeansOfType(CommonAnnotationBeanPostProcessor.class, true,
false);
// The {@code javax.xml.ws.WebServiceContext} interface should
be ignored since it will
// be resolved by the CXF's JAX-WS runtime.
beans.forEach((name, bean) ->
bean.ignoreResourceType(WebServiceContext.class.getName()));
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
index 0bddbb12e4..eedfb70c2e 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
@@ -37,6 +37,7 @@ import jakarta.xml.ws.Service.Mode;
import jakarta.xml.ws.WebServiceException;
import jakarta.xml.ws.soap.SOAPFaultException;
import org.apache.cxf.Bus;
+import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.metrics.MetricsFeature;
@@ -47,12 +48,15 @@ import
org.apache.cxf.systest.jaxws.resources.HelloServiceImpl;
import org.apache.cxf.testutil.common.TestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ImportResource;
import org.springframework.test.context.ActiveProfiles;
import io.micrometer.core.instrument.MeterRegistry;
@@ -64,6 +68,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+
import static java.util.stream.Collectors.toMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -73,13 +78,19 @@ import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.empty;
+@SpringBootApplication
@SpringBootTest(
webEnvironment = WebEnvironment.RANDOM_PORT,
- classes = SpringJaxwsTest.TestConfig.class,
+ classes = {
+ SpringJaxwsTest.TestConfig.class,
+
+ },
properties = {
"cxf.metrics.server.max-uri-tags=2"
})
+@ImportResource("classpath:spring/jaxws-client.xml")
@ActiveProfiles("jaxws")
+
public class SpringJaxwsTest {
private static final String DUMMY_REQUEST_BODY = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\">"
@@ -92,6 +103,9 @@ public class SpringJaxwsTest {
@Autowired
private MeterRegistry registry;
+ @Autowired
+ private ApplicationContext applicationContext;
+
@Autowired
private MetricsProvider metricsProvider;
@@ -304,6 +318,16 @@ public class SpringJaxwsTest {
entry("status", "200"));
}
+ @Test
+ public void testJaxwsFromXmlProxy() throws MalformedURLException {
+ final HelloService api = createApiFromSpringXml();
+ //ensure the property placeholder is resolved
+ assertThat("http://localhost:port/Service/HelloV1")
+ .isEqualTo(ClientProxy.getClient(api).getConduit().
+ getTarget().getAddress().getValue());
+
+ }
+
@Test
public void testJaxwsProxyFailedMetric() {
final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
@@ -385,6 +409,11 @@ public class SpringJaxwsTest {
return factory.create(HelloService.class);
}
+ private HelloService createApiFromSpringXml() {
+ return this.applicationContext.getBean("cxfClient",
+ HelloService.class);
+ }
+
private String sendSoapRequest(String requestBody, final String
serviceName) throws MalformedURLException {
String address = "http://localhost:" + port + "/Service/" +
serviceName;
diff --git a/systests/spring-boot/src/test/resources/application-jaxws.yml
b/systests/spring-boot/src/test/resources/application-jaxws.yml
index 49c747e5d7..85ad519e8f 100644
--- a/systests/spring-boot/src/test/resources/application-jaxws.yml
+++ b/systests/spring-boot/src/test/resources/application-jaxws.yml
@@ -2,4 +2,6 @@ cxf:
path: /Service
metrics:
jaxrs:
- enabled: false
\ No newline at end of file
+ enabled: false
+my:
+ address: http://localhost:port/Service/HelloV1
diff --git a/systests/spring-boot/src/test/resources/spring/jaxws-client.xml
b/systests/spring-boot/src/test/resources/spring/jaxws-client.xml
new file mode 100644
index 0000000000..15af357568
--- /dev/null
+++ b/systests/spring-boot/src/test/resources/spring/jaxws-client.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws https://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="cxfClient" id="cxfClient"
+
serviceClass="org.apache.cxf.systest.jaxws.resources.HelloService"
+ address="${my.address}" />
+
+
+</beans>
+