我在使用DefaultWsdl11Definition
自动生成wsdl时遇到问题ContactServiceOperations.xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://com/blog/samples/webservices/contactservice"
xmlns:Contact="http://webservices.samples.blog.com" targetNamespace="http://com/blog/samples/webservices/Contact"
elementFormDefault="qualified">
<xsd:import namespace="http://webservices.samples.blog.com"
schemaLocation="Contact.xsd" />
<xsd:element name="ContactRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Id" type="xsd:integer" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ContactResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Contact" type="Contact:Contact" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
springapp-servlet.xml中
<mvc:annotation-driven />
<sws:annotation-driven />
<context:component-scan base-package="*" />
<bean id="ContactService"
class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schemaCollection">
<bean
class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="inline" value="true" />
<property name="xsds">
<list>
<value>/xsd/ContactServiceOperations.xsd</value>
</list>
</property>
</bean>
</property>
<property name="portTypeName" value="ContactService" />
<property name="locationUri" value="http://localhost:8080/SpringWS/ContactService/" />
</bean>
的web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>/jsp/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>webservices</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>webservices</servlet-name>
<url-pattern>*.wsdl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>webservices</servlet-name>
<url-pattern>/ContactService/*</url-pattern>
</servlet-mapping>
我可以毫无错误地启动Tomcat。然后,我访问此URL:
http://localhost:8080/SpringWS/ContactService/contactService.wsdl
浏览器显示空白页而不是生成wsdl。
也许我的配置有问题。有什么想法帮助我吗?
由于
答案 0 :(得分:0)
更正了这一点,ContactService.wsdl
localhost:8080/SpringWS/ContactService/ContactService.wsdl
答案 1 :(得分:0)
问题在于您的web.xml文件。尝试为DispatcherServlet和MessageDispatcherServlet提供不同的上下文文件。
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
.....
...
<servlet>
<servlet-name>webservices</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springws-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
答案 2 :(得分:0)
我在运行Spring Boot演示时遇到过类似的经历。如果您的问题与我的问题类似,那么 正在运作。 Spring向wsdl发送xml标题,即
<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions ...
我使用Firefox并在显示空白屏幕之前闪烁wsdl。因此,查看页面源会显示完整的wsdl文件。
使用Spring Boot注释有一个简单的可下载示例: