user3403462
user3403462

Reputation: 121

Spring :How to generate WSDL at run time if XSD provided as input

I have to create simulator where on run time WSDL files can be generated if XSD file is given as input. For this i am using Spring Web Services and JAXB API to generate WSDL from given XSD file.

After all the sample programs , i have understood that java classes can be generated with help of JAXB on running maven file but still we need to manually write the serviceEndpoint class , hence it seems difficult to generate ServiceEndpoint class for the given xsd file.

I want to know is it possible to generate serviceEndpoint class as well for the given xsd on the run time and compiled as well.

In short i want to automate whole process of WSDL generation if XSD file is given as input as runtime.

Upvotes: 0

Views: 9331

Answers (2)

zygimantus
zygimantus

Reputation: 3777

Make sure that you use ServletRegistrationBean with defined URL mapping, etc., like this:

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
      MessageDispatcherServlet servlet = new MessageDispatcherServlet();
      servlet.setApplicationContext(applicationContext);
      servlet.setTransformWsdlLocations(true);
      return new ServletRegistrationBean(servlet, "/ws/*");
}

If your XSD schema is named test.xsd then you can access your WSDL at runtime here: http://localhost:8080/ws/test.wsdl

Upvotes: 0

Samantha Catania
Samantha Catania

Reputation: 5316

Spring automatically exposes the WSDL generated from your configuration. See section 5.3.1.1 from the official documentation

Upvotes: 2

Related Questions