Apache Cxf WebService整合Spring(2)

来源:互联网 发布:mac口红a17是什么颜色 编辑:程序博客网 时间:2024/05/20 18:41

Apache Cxf WebService整合Spring(2)

分类: WebService 60人阅读 评论(0) 收藏 举报

六:部署项目,启动Tomcat,发布WebService,在浏览器输入http://localhost:8080/Spring-Cxf-Demo/lzw/cxf?wsdl




七:配置apache-cxf(在环境变量Path中加入:;F:\Java\WebService\CXF\apache-cxf-2.7.6\bin)




八:生成客户端代码

(1)在本地建立Test 工程


(2)在src目录下输入 wsdl2java http://localhost:8080/Spring-Cxf-Demo/lzw/cxf?wsdl



九:添加测试代码

   

[java] view plaincopyprint?
  1. package com.lzw.springcxf.client;  
  2.   
  3. import java.util.List;  
  4.   
  5. import com.lzw.springcxf.service.ClubModel;  
  6. import com.lzw.springcxf.service.HandleService;  
  7. import com.lzw.springcxf.service.PlayerModel;  
  8. import com.lzw.springcxf.service.impl.HandleServiceTest;  
  9.   
  10. public class WSClient {  
  11.       
  12.     public static void main(String[] args) {  
  13.           
  14.         HandleServiceTest factory = new HandleServiceTest();  
  15.           
  16.         HandleService handleService = factory.getHandleServiceImplPort();  
  17.           
  18.         System.out.println(handleService.sayName("内马尔"));  
  19.           
  20.         ClubModel clubModel = new ClubModel();  
  21.         clubModel.setClubId(1111);  
  22.         clubModel.setClubName("巴塞罗那");  
  23.         clubModel.setCountry("西班牙");  
  24.           
  25.         List<PlayerModel> players = handleService.getPlayerByClub(clubModel);  
  26.         for (PlayerModel play:players) {  
  27.             System.out.println(play.getPlayerName());  
  28.         }  
  29.     }  
  30. }  

控制台输出:

[java] view plaincopyprint?
  1. 本次西班牙国家德比的最佳球员是:内马尔  
  2. 梅西  
  3. 内马尔  
0 0
原创粉丝点击