免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
spring-boot(十)webservice配置

webservices在前幾年是非常流行的,后來rest-api出世后簡直是顛覆了ws的天下.
但是在項目中還是有小部分會使用到ws,這里就簡單介紹下spring-boot添加ws支持

官方的支持也是只給了簡短的說明


想了解更多的支持信息請訪問 spring-ws 相關的文檔

在這里只是簡單介紹如何快速搭建一個ws項目, 案例代碼在 spring-boot(九)websocket配置 基礎之上改造

項目結構圖

在pom中添加ws的依賴, 本案例通過cxf來搭建ws

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-web-services</artifactId>
  4. </dependency>
  5. <dependency>
  6. <groupId>org.apache.cxf</groupId>
  7. <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
  8. <version>3.1.7</version>
  9. </dependency>

在包 hello.jax.ws
新建一個接口 Hello.java

  1. package hello.jax.ws;
  2. /**
  3. * @author majinding888@foxmail.com
  4. * @date 2016-12-30 下午5:28:59
  5. */
  6. import javax.jws.WebMethod;
  7. import javax.jws.WebParam;
  8. import javax.jws.WebResult;
  9. import javax.jws.WebService;
  10. @WebService(name = "Hello")
  11. public interface Hello {
  12. @WebResult()
  13. @WebMethod()
  14. String sayHello(@WebParam(name = "myname") String myname);
  15. }

新建一個實現(xiàn)類 HelloPortImpl.java

  1. package hello.jax.ws;
  2. import javax.jws.WebService;
  3. /**
  4. * @author majinding888@foxmail.com
  5. * @date 2016-12-30 下午5:29:29
  6. */
  7. @WebService
  8. public class HelloPortImpl implements Hello {
  9. public String sayHello(String myname) {
  10. return "Hello, Welcome to CXF Spring boot " + myname + "!!!";
  11. }
  12. }

新建 WebServiceConfig.java 配置,啟用ws

  1. package hello.jax.ws;
  2. /**
  3. * @author majinding888@foxmail.com
  4. * @date 2016-12-30 下午5:30:09
  5. */
  6. import javax.xml.ws.Endpoint;
  7. import org.apache.cxf.Bus;
  8. import org.apache.cxf.jaxws.EndpointImpl;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.context.annotation.Bean;
  11. import org.springframework.context.annotation.Configuration;
  12. @Configuration
  13. public class WebServiceConfig {
  14. @Autowired
  15. private Bus bus;
  16. @Bean
  17. public Endpoint endpoint() {
  18. EndpointImpl endpoint = new EndpointImpl(bus, new HelloPortImpl());
  19. endpoint.publish("/Hello");
  20. return endpoint;
  21. }
  22. }

到此ws環(huán)境就搭建完成,啟動瀏覽器 訪問 http://localhost:666/services/Hello?wsdl

(切記需要在發(fā)布路徑前面增加services這個path)

 

源代碼附件地址: my-springboot-10.zip

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
WebService介紹
Spring-ws示例WebService開發(fā)
Web Service 那點事兒(1)
WebService開發(fā)筆記 3 -- 增強訪問 WebService 的安全性
webservice原理及基于cxf開發(fā)的基本流程
Web Service 那點事兒(4)—— 使用 CXF 開發(fā) REST 服務
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服