我无法访问XSD架构。这是我的配置:
的web.xml
<servlet>
<servlet-name>spring-ws</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>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
弹簧-WS-servlet.xml中
<sws:annotation-driven/>
<context:component-scan base-package="example.ws.endpoint"/>
<sws:dynamic-wsdl id="boo"
portTypeName="BooResource"
locationUri="/services/">
<sws:xsd location="classpath:example/ws/schema/Boo.xsd"/>
</sws:dynamic-wsdl>
可以在[http:// localhost:port / spring-ws-server-0.1-SNAPSHOT / services / boo.wsdl]上访问WSDL,但是如何公开XSD以及URL是什么?
答案 0 :(得分:2)
我已经能够在不使用Spring-MVC的情况下通过在我的@Configuration
类中定义类似的内容来公开我的XSD:
private ClassPathResource messagesXsdResource = new ClassPathResource("messages.xsd");
@Bean
public SimpleXsdSchema messages() {
return new SimpleXsdSchema(messagesXsdResource);
}
您还应该查看this question,它解释了如何在XML中执行此操作。
答案 1 :(得分:1)
我担心这是不可能的,至少不会像你的WSDL那样自动暴露。 Spring WS不打算像使用静态和生成的WSDL那样使您的XSD可用。当然,您可以通过简单的servlet或通过MVC使您的XSD可用(如果您也使用MVC)。
答案 2 :(得分:0)
如果您使用的是 Spring Boot,那么您在 public
下创建的 resources
文件夹下的任何内容都将公开可用。
您可以将您的 xsd 放在那里并将您的 wsdl 指向该定义:
<xsd:schema>
<xsd:import namespace="http://jaxws.com.your.ns" schemaLocation="/your.xsd"/>
</xsd:schema>
现在这将使您的 xsd 在 http://localhost:8080/your.xsd