3

Here is a nice example on how to produce a SOAP web service in Spring: https://spring.io/guides/gs/producing-web-service/

This example shows, how to obtian one endpoint and one service. How to obtain the same result with multiple services and endpoints?

MikaelF
  • 3,518
  • 4
  • 20
  • 33
JamesLinux
  • 179
  • 2
  • 5
  • 20

2 Answers2

1

Basing on example from your link, all what you need to do is to add following methods to WebServiceConfig like:

@Bean(name = "webservice2")
public DefaultWsdl11Definition webservice2Wsdl11Definition(XsdSchema webservice2Schema) {
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
    wsdl11Definition.setPortTypeName("webservice2Port");
    wsdl11Definition.setLocationUri("/ws");
    wsdl11Definition.setTargetNamespace("your namespace");
    wsdl11Definition.setSchema(webservice2Schema);
    return wsdl11Definition;
}

@Bean(name="webservice2Schema")
public XsdSchema webservice2Schema() {
    return new SimpleXsdSchema(new ClassPathResource("webservice2.xsd"));
}

And of course create

@Endpoint
public class Webservice2Endpoint

You can use as many webservices as you want in one module.

Mike Adamenko
  • 2,944
  • 1
  • 15
  • 28
1

Okay, it seems, that both answers were correct. I used Mike Adamenkos answer with a little extra tags to get it working.

@Bean(name = "webservice2")
public DefaultWsdl11Definition defaultWsdl11Definition(@Qualifier("Name") XsdSchema webservice2Schema) {
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
    wsdl11Definition.setPortTypeName("webservice2Port");
    wsdl11Definition.setLocationUri("/ws");
    wsdl11Definition.setTargetNamespace("your namespace");
    wsdl11Definition.setSchema(webservice2Schema);
    return wsdl11Definition;
}

@Bean(name = "Name2")
public XsdSchema webservice2Schema() {
    return new SimpleXsdSchema(new ClassPathResource("webservice2.xsd"));
}

So you need to add a name value for the XsdSchema methods so you can get the correct method in your DefaultWsdl11Definition with the @Qualifier tag. Hope this helps!

JamesLinux
  • 179
  • 2
  • 5
  • 20
  • 1
    For me it works without specific tags... BUT you only talk about the wsdl generation (it's what the defaultWsdl11Definition does). Here I have a servlet mapping issue: Having two (or more) WebServices suppose differents mappings. This means different MessageDispatcherServlet....But I can't make Spring deploy more than one servlet because MessageDispatcherServlet have all have the same name. – JN Gerbaux Feb 05 '18 at 15:25