是否有另一种方法可以在Spring Boot中获取WebServiceTemplate而不是WebServiceGatewaySupport#getWebServiceTemplate()?

Spring提供了org.springframework.ws.client.core.support.WebServiceGatewaySupport类,它是根据Spring文档 a

方便的超类,适用于需要Web服务访问的应用程序类。

该课程显然是为扩展而设计的 。 它是abstract所以它不能被实例化为bean,所以我不能使用组合而不是inheritance 。

但是,当我inheritance该类时,Spring开始抱怨:

[WARN] org.springframework.framework.CglibAopProxy – 无法代理接口实现方法 [public final void org.springframework.ws.client.core.support.WebServiceGatewaySupport.afterPropertiesSet()throws java.lang.Exception] 因为它被标记最后考虑使用基于接口的JDK代理!

各种资源(例如https://github.com/spring-projects/spring-boot/issues/8974 )说的像

如果您实际上没有通过代理调用xxx方法,则可以安全地忽略该警告

但是我很高兴在申请中发出任何警告。 习惯忽略警告通常不好,而且我们的一些客户坚持“零警告政策”。

我们只需要该类来获取WebServiceTemplate 。 我们正在以某种方式使用它:

 response = getWebServiceTemplate().marshalSendAndReceive( uri, request, new SoapActionCallback(soapAction)); 

题:

在Spring中是否有另一种方法(实际上,我们使用Spring Boot )来实现相同的结果,而无需额外的配置和没有警告

也许Spring有另一个具有相同function的类用于组合? 还是静态工厂方法?