【发布时间】:2017-05-25 19:11:53
【问题描述】:
在 Spring Boot 1.4.3 中,我公开了一个 SOAP Web 服务端点,它在端口 8080 上成功运行。
为了运行健康检查,我还需要公开一个 RESTful API。我尝试使用执行器和休息控制器:
@RestController
public class RESTapis {
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/health")
public String healthCheck() {
return "ACK";
}
}
但在这两种情况下,我都会得到相同的响应:HTTP 405(不允许的方法)。
如果我禁用 Web 服务,REST api 将返回 HTTP 200。
如何让 SOAP Web 服务和 REST 同时工作?
这是网络服务配置:
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/*");
}
}
【问题讨论】:
-
你能展示你的 pom 和两个请求的例子吗?
标签: spring web-services rest http spring-boot