当前位置: 首页 > 知识库问答 >
问题:

如何在Spring Boot中使用spring web服务动态WSDL生成?

范翰池
2023-03-14

我学习了Spring Web Services入门教程,并编写了一个示例Web应用程序,该应用程序在/ws/holiday.WSDL上动态生成WSDL,endpoint在/ws/holidayService上服务请求,到目前为止还不错。

现在,我将webapp转换为Spring Boot应用程序:我添加了必要的spring-boot-starter-*依赖项,在带有endpoint的包上面的包中创建了一个@springbootapplication注释类,并且endpoint实现仍然会回复请求。

但是我不能再从现有的XSD中获得生成的WSDL。

server.port = 8090
spring.webservices.wsdl-locations=classpath:/../;classpath:/wsdl
spring.webservices.path=/ws
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 ''

由于我刚开始引导,我不清楚是否支持WSDL动态生成(我只是缺少正确的配置)。

共有1个答案

西门奇希
2023-03-14

通过查看本指南,我进行了以下更改:

删除了web.xml文件,以便添加:

spring.webservices.servlet.init.transformWsdlLocations=true
spring.webservices.path=/ws

application.properties文件。

@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {

    @Bean(name = "holiday")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema schema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("HumanResource");
        wsdl11Definition.setLocationUri("/holidayService/");
        wsdl11Definition.setTargetNamespace("http://mycompany.com/hr/definitions");
        wsdl11Definition.setSchema(schema);
        return wsdl11Definition;
    }

}
spring.webservices.wsdl-locations=classpath:/ws/
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {

    @Bean(name = "holiday-spring")
    public DefaultWsdl11Definition wsdl11DefinitionOne(@Qualifier("holiday-spring-schema") XsdSchema schema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("HumanResource");
        wsdl11Definition.setLocationUri("/holidaySpringService/");
        wsdl11Definition.setTargetNamespace("http://mycompany.com/hr/definitions");
        wsdl11Definition.setSchema(schema);
        return wsdl11Definition;
    }

    @Bean(name = "holiday-winter")
    public DefaultWsdl11Definition wsdl11DefinitionTwo(@Qualifier("holiday-winter-schema") XsdSchema schema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("HumanResource");
        wsdl11Definition.setLocationUri("/holidayWinterService/");
        wsdl11Definition.setTargetNamespace("http://mycompany.com/hr/definitions");
        wsdl11Definition.setSchema(schema);
        return wsdl11Definition;
    }

}
 类似资料:
  • 我正在研究Spring-WS,它基于手动创建的XSD生成WSDL。 我试图使用Spring-WS将Spring Controller RESTFul API服务公开为WSDL。 那么如何在spring webservice调用时传递{customer-id}呢?如何在spring wsdl定义中指定这个url?

  • 问题内容: 如何在Django中提供动态生成的图像? 我有一个html标签 链接到此请求处理程序,该请求处理程序创建一个内存中图像 我还计划将请求更改为AJAX,并添加某种缓存机制,但是我的理解是,这不会影响解决方案的这一部分。 问题答案: 我假设您正在使用PIL(Python影像库)。您需要用(例如,如果要提供PNG图像)替换最后一行: 有关更多信息,请参见此处。

  • 我想使用WSDL url中的数据,我不知道在Python中该怎么做。 谁能帮我举个例子吗 以下是可供参考的WSDL链接:http://43.242.214.173/CWPLService/CWPLonline.svc?WSDL 下面是我尝试过的代码片段。 当我运行代码时,我得到以下错误:suds.typeNotFound:Type not found:“(schema,http://www.w3.

  • 我想创建PHP SOAP服务器,但不明白如何正确地做到这一点。下面是server.php文件: client.php文件: wsdl文件: 日食图像 压缩所有文件 我用Eclipse Web服务XML编辑器创建了WSDL文件。现在我不知道如何创建功能。我得到以下错误: 致命错误:在C:\wamp\www\soap websiteservice wsdl\client中未找到未捕获的SoapFaul

  • 我的springboot微服务依赖于AS400 DB2,当服务启动时,它可能会关闭。该服务有一个配置bean,它有autowired的基于JpaRepository的存储库。在启动期间,当DB2关闭时,我得到以下消息:

  • 我是OSGI的新手。我使用cxf和蓝图开发了一个学生Rest服务。将其部署在karaf中。默认情况下karaf的URL中包含cxf。我发现我可以在etc文件夹中配置属性(org.apache.cxf.servlet.context=/学生),或者我可以在karaf中运行config:编辑/setprop/更新/命令。这样我就可以用一些自定义值替换url中的cxf。但是现在我想从我的url中删除CX