我已按照此帖中的回答在我的应用中公开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.我犯了什么错误?提前谢谢。
答案 0 :(得分:0)
我终于想到了我们。 MessageDispatcherServlet无法处理.xsd的请求,因为web.xml中没有servlet-mapping声明。
两种解决方法..
方法1:更新URL模式以包含/ services /
下的所有内容 <servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
方法2:
添加另一个映射
<servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>.xsd</url-pattern>
</servlet-mapping>
答案 1 :(得分:0)
发布于:
http://www.mytechtip.com/2012/09/static-wsdl-with-imported-xml-schema-in.html
你应该使用:
`<bean
id="temperature-schema"
class="org.springframework.xml.xsd.SimpleXsdSchema">
<property
name="xsd"
value="/WEB-INF/wsdl/temperature-schema.xsd">
</property>
</bean>`
其中id与包含您的架构的文件的名称匹配。