【发布时间】:2019-02-27 23:59:19
【问题描述】:
我关注了Spring Web Services Getting Started tutorial,并整理了一个示例 Web 应用程序,该应用程序在 /ws/holiday.wsdl 动态生成 WSDL,并且端点在 /ws/holidayService 处为请求提供服务,到目前为止一切顺利。
现在我正在将该 web 应用程序转换为 Spring Boot 应用程序:我添加了必要的 spring-boot-starter-* 依赖项,在具有端点的包中创建了一个 @SpringBootApplication 注释类,并且端点实现仍然回复请求。
但我无法再从现有 XSD 中获取生成的 WSDL。
这是application.properties(我尝试将 XSD 放在多个位置):
server.port = 8090
spring.webservices.wsdl-locations=classpath:/../;classpath:/wsdl
spring.webservices.path=/ws
这是Run as -> Spring Boot App 日志(我在 Eclipse 中):
ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13df2a8c: startup date [Mon Sep 24 14:40:44 CEST 2018]; root of context hierarchy
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$22b02c9a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
.w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
o.apache.catalina.core.StandardService : Starting service [Tomcat]
org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.0.2m 2 Nov 2017]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2093 ms
o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
o.s.b.w.servlet.ServletRegistrationBean : Servlet messageDispatcherServlet mapped to [/ws/*]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13df2a8c: startup date [Mon Sep 24 14:40:44 CEST 2018]; root of context hierarchy
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8090 (http) with context path ''
Spring Boot documentation on Web Service 说:
Spring Boot 提供 Web 服务自动配置,因此您只需定义 Endpoints。
使用 spring-boot-starter-webservices 模块可以轻松访问 Spring Web Services 功能。
SimpleWsdl11Definition 和 SimpleXsdSchema bean 可以分别为您的 WSDL 和 XSD 自动创建。为此,请配置它们的位置,如下例所示:
spring.webservices.wsdl-locations=classpath:/wsdl
由于我是 Boot 新手,我不清楚是否支持 WSDL 动态生成(我只是缺少正确的配置)。
【问题讨论】:
-
@SimonMartinelli 如果我没记错的话,该页面使用了显式的 WSDL;但是,我想我找到了基于this guide 的解决方案
标签: java spring web-services spring-boot