4

Spring provides the org.springframework.ws.client.core.support.WebServiceGatewaySupport class, which is according to the Spring documentation a

convenient super class for application classes that need Web service access.

The class is apparently designed for extending. It is abstract so it cannot be instantiated as a bean, so I cannot use composition rather than inheritance.

However, when I inherit the class, Spring starts complaining like that:

[WARN] org.springframework.framework.CglibAopProxy - Unable to proxy interface-implementing method [public final void org.springframework.ws.client.core.support.WebServiceGatewaySupport.afterPropertiesSet() throws java.lang.Exception] because it is marked as final: Consider using interface-based JDK proxies instead!

Various resources (e.g. https://github.com/spring-projects/spring-boot/issues/8974) say something like

The warning is safe to ignore if you're not actually calling the xxx method through the proxy

however I am not happy having any warning in the application. It is generally not good to get used to ignore warnings, and furthermore some of our customers insist on the "zero-warning policy".

We need the class only for getting the WebServiceTemplate. We are using it somehow like that:

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

QUESTION:

Is there an alternative way in Spring (actually, we use Spring Boot) to achieve the same result, without extra too much configuration and without warnings?

Maybe Spring has another class with the same functionality designed for composition? Or a static factory method?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
  • As stated you can safely ignore the warning. Simply switching to JDK dynamic proxies might break your application (depending of you have interfaces for all your classes or not and how you do dependency injection). – M. Deinum Jul 24 '17 at 10:26
  • @M.Deinum Ignoring warnings is not a good thing, people get easily accustomed to it. And some of ours customers require a "zero-warning-policy"! And I am wandering if there is a "more proper" way of using this class. – Honza Zidek Jul 24 '17 at 10:29
  • The solutions is in the warning, but when doing so you might (and propably) break other parts of your application. Spring has chosen to use class based proxies for a reason. When disabling that things like `@Transactional` might break because those might be on classes without interfaces. Also if you have interfaces but ignore them and simply inject the full type (instead of programming to interfaces) those will break. So yes you can fix it, but it will probably break your application. – M. Deinum Jul 24 '17 at 10:35
  • @M.Deinum: I understand that. Maybe there is another trick how to achieve it? Maybe Spring has another class with the same functionality designed for composition? I do not like the idea of "Convenient super class for application classes that need XY functionality", this idiom belongs to the last century :) – Honza Zidek Jul 24 '17 at 10:41
  • 1
    The only thing that super class does is provide an instance of a pre-configured `WebServiceTemplate`. You can simply configure the `WebServiceTemplate` instead of extending the super class and inject the template into your class. – M. Deinum Jul 24 '17 at 10:43
  • @M.Deinum: Yes, the only thing we use is its `getWebServiceTemplate()` method. Could you please advice how to "simply configure the WebServiceTemplate instead of extending the super class"? You may formulate it as an answer. – Honza Zidek Jul 24 '17 at 10:53

0 Answers0