3

I can't reach XSD schema. Here is my configuration:

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>

spring-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>

WSDL is accessible on [http://localhost:port/spring-ws-server-0.1-SNAPSHOT/services/boo.wsdl], but how can I expose XSD and what will be the URL?

sasynkamil
  • 859
  • 2
  • 12
  • 23

3 Answers3

3

I've been able to expose my XSD's without using Spring-MVC for it by defining something like this in my @Configuration class:

private ClassPathResource messagesXsdResource = new ClassPathResource("messages.xsd");

@Bean
public SimpleXsdSchema messages() {
    return new SimpleXsdSchema(messagesXsdResource);
}

You should take a look at this question as well, that explains how to do this in XML.

Community
  • 1
  • 1
evandongen
  • 1,995
  • 17
  • 19
  • 1
    So how do you access messages.xsd then from the browser if you do this? – ACV Mar 04 '21 at 17:36
  • @ACV I'm not sure since this was almost 8 years ago ;-) IIRC, you can access it by beanname.xsd, in this case messages.xsd. – evandongen Mar 06 '21 at 14:05
  • thanks @evandongen. I managed to get it working by putting the xsd on a publicly available path (like `public` under `resources` in spring boot for example), yeah time flies :) – ACV Mar 06 '21 at 22:52
1

I'm afraid this is not possible, at least not automatically like your WSDLs are exposed. Spring WS doesn't intend to make your XSDs available like it does with the static and generated WSDLs. Of course, you can make your XSDs available through a simple servlet or through MVC (if you're using MVC as well).

Oliver Marienfeld
  • 1,154
  • 9
  • 17
  • 2
    Not sure why this is accepted answer because you can actually do it. See @evandongen answer or https://stackoverflow.com/a/42724574/1766166. – zygimantus Feb 07 '18 at 12:11
0

If you're using Spring Boot, whatever you put under the public folder which you can create under resources, will be publicly available.

You can put your xsd there and point your wsdl to that definition:

   <xsd:schema>
      <xsd:import namespace="http://jaxws.com.your.ns" schemaLocation="/your.xsd"/>
    </xsd:schema>

Now this will make your xsd available at http://localhost:8080/your.xsd

ACV
  • 9,964
  • 5
  • 76
  • 81