2016-09-08 3 views
2

Я хочу сделать SpringBoot приложения в Java с помощью следующей Soap веб-службы:Spring Boot Soap Web-Service (Java) - сначала код?

@WebService 
public class HelloWorld 
{ 
    @WebMethod 
    public String sayHello(String name) 
    { 
     return "Hello world, " + name; 
    } 
} 

Я хочу, чтобы получить WSDL ... Я думаю, что я должен создать конечные точки или отображение службы? Как я могу это сделать?

без пружинного ботинка он работает, потому что файл в папке WEB-INF с кодом:

<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'> 
    <endpoint name='HelloWorld' implementation='web.service.soap.HelloWorld' url-pattern='/HelloWorld'/> 
</endpoints> 

и

<servlet> 
     <servlet-name>jaxws-servlet</servlet-name> 
     <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>jaxws-servlet</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

ответ

2

Добавить пружинно-загрузочный стартер-WS и орг. apache.cxf cxf-bundle зависит от вашего проекта.

И создайте файл конфигурации, чтобы разоблачить ваши веб-службы. Пример такой конфигурации:

@Configuration 
@EnableWs 
public class WebServicesConfig { 
    @Autowired 
    private HelloWorld helloWorld; // your web service component 

    @Bean 
    public ServletRegistrationBean wsDispatcherServlet() { 
     CXFServlet cxfServlet = new CXFServlet(); 
     return new ServletRegistrationBean(cxfServlet, "/services/*"); 
    } 

    @Bean(name="cxf") 
    public SpringBus springBus() { 
     return new SpringBus(); 
    } 

    @Bean 
    public Endpoint helloWorldEndpoint() { 
     EndpointImpl endpoint = new EndpointImpl(springBus(), helloWorld); 
     endpoint.publish("helloWorld"); 
     return endpoint; 
    } 
} 

Чтобы получить доступ к WSDL: http://localhost:8080/services/helloWorld?wsdl (путь может отличаться)

Смежные вопросы