前面基于CXF实现了SOAP WS,不过在部署到Websphere的时候碰到了问题:
Caused by: java.lang.IncompatibleClassChangeError:
org.apache.neethi.AssertionBuilderFactory
原因是Websphere自带了neethi 2.x版本,而CXF必须使用3.x版本。
IBM也提供了解决办法,不过有点绕,而且使用share library 也给部署带来了麻烦。
https://www-01.ibm.com/support/docview.wss?uid=swg21964283
试着使用SpringBoot自带的SOAP WS,使用没有CXF方便,但是可以在Websphere部署成功。
具体参考下面的链接,还有例子下载:
https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/
其中的MessageDispatcherServlet直接通过setApplicationContext设置到了Springboot容器,后面的bean可以通过@Autowired 来关联。
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/soap/*");
}
由于是Springboot提供的实现,所以可以和Restful WS 共存。
不过SOAP的实现有点麻烦,没有Restful WS简洁明了。