【发布时间】:2015-02-11 04:51:50
【问题描述】:
我已经按照这篇文章中的答案在我的应用程序中公开了 xsd - Is there a way to expose a static XSD in Spring WS 2?
我的 web.xml
<servlet>
<servlet-name>ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springws-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>/services</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>*.wsdl</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/airlinemvc-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
springws-servlet.xml
<sws:annotation-driven />
<sws:static-wsdl id="airline" location="/WEB-INF/wsdl/airlineservice.wsdl"/>
<sws:dynamic-wsdl id="airlineWS"
portTypeName="AirlineServicePortType"
locationUri="http://localhost:8080/airline/services/"
createSoap11Binding="true"
createSoap12Binding="true" >
<sws:xsd location="/WEB-INF/schemas/AirlineService.xsd"/>
</sws:dynamic-wsdl>
<bean id="AirlineTypes" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schemas/AirlineTypes.xsd"/>
</bean>
<bean id="AirlineService" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/schemas/AirlineService.xsd"/>
</bean>
现在我想从浏览器访问 AirlineService.xsd。我尝试去http://localhost:8080/airline/AirlineService.xsd 和http://localhost:8080/airline/services/AirlineService.xsd - 他们都返回404。我犯了什么错误?提前致谢。
【问题讨论】:
-
你不要把它们放在 WEB-INF 文件夹之外并通过localhost:8080/airline/schemas/AirlineService.xsd访问它们
-
@Koitoer 这很可能会起作用,但我的代码为什么不起作用真的很困扰我。我只是照原样复制了样本,但仍然没有运气。
标签: spring spring-mvc spring-ws