带弹簧启动的 CXF

Vla*_*mir 6 cxf jax-ws spring-boot

我正在尝试让 CXF 和 Sprint Boot 运行良好。我有一个名为 SubscriberApi 的 JAX-WS 服务端点。查看 spring-boot 日志,我看到映射成功:

Mapping servlet: 'CXFServlet' to [/api/*]
Setting the server's publish address to be /SubscriberApi
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法在点击时获得 WSDL:

http://localhost:8080/api/SubscriberApi?wsdl
Run Code Online (Sandbox Code Playgroud)
Mapping servlet: 'CXFServlet' to [/api/*]
Setting the server's publish address to be /SubscriberApi
Run Code Online (Sandbox Code Playgroud)

Cug*_*uga 3

让你的jaxwsEndpointbean返回一个org.apache.cxf.jaxws.EndpointImpl扩展的实例javax.xml.ws.Endpoint

@Autowired
private ApplicationContext applicationContext;

@DependsOn("servletRegistrationBean")
@Bean
public Endpoint jaxwsEndpoint(){
   Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
   EndpointImpl endpoint = new EndpointImpl(bus, subscriberApi());
   endpoint.publish("/SubscriberApi");
   // also showing how to add interceptors
   endpoint.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
   endpoint.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());

   return endpoint;
}
Run Code Online (Sandbox Code Playgroud)

原始帖子不包含可运行的示例,但这应该可以解决问题。

可以在此处找到一个正在运行的示例,其中所有配置都链接在一起: Application.java