CXF 发布 Web Service
来源:互联网 发布:百度网盘无限试用 mac 编辑:程序博客网 时间:2024/06/15 01:29
使用CXF框架开发
①.CXF : xfire–>xfire + celtrix
做web service开发的开源框架
②.开发Server端:
加入cxf的Jar包即可,其它不需要动
测试CXF支持的数据类型
1.基本类型
–int,float,boolean等
2.引用类型
–String
–集合:数组,List, Set, Map
–自定义类型 Student
@WebService
public class DataTypesImpl implements DataTypeWS { //SEI接口实现类
public boolean addStudent(Student s) {
System.out.println("server addStudent()" +s);
return true;
}
public Student getStudentById(int id) {
System.out.println("server getStudentById()" +id);
return new Student(id,"CAT",1000);
}
public List<Student> getStudentByPrice(float price) {
System.out.println("server getStudentByPrice()" +price);
List<Student> list=new ArrayList<Student>();
list.add(new Student(1,"tg1",price+1));
list.add(new Student(2,"tg2",price+2));
list.add(new Student(3,"tg3",price+3));
return list;
}
public Map<Integer, Student> getAllStudentMap() {
System.out.println("server getAllStudentMap()" );
Map<Integer,Student> map=new HashMap<Integer, Student>();
map.put(1,new Student(1,"TG1",123));
map.put(2,new Student(2,"TG2",143));
map.put(3,new Student(3,"TG3",153));
return map;
}
public class serviceTest2 { //发布服务
/**
* @param args
*/
public static void main(String[] args) {
//客户端发送web service请求的url
String address="http://127.0.0.1:8888/tg_ws_cxf/datatypews";
//处理请求的SEI对象
DataTypeWS dataTypesImpl=new DataTypesImpl();
//发布web service
//Endpoint.publish("http://127.0.0.1/person_ws/HelloWS", hellows);
Endpoint.publish(address, dataTypesImpl);
System.out.println("web service 发布成功");
}
--------------------------------------------------------------------------
(中间必须先生成客户端代码 打开cmd .. 见我的上一篇博客http://blog.csdn.net/tanggao1314/article/details/48393205 图2
public class ClientTest { //客户端测试
/**
* @param args
*/
public static void main(String[] args) {
DataTypesImplService factory=new DataTypesImplService();
DataTypeWS dataTypeWS=factory.getDataTypesImplPort();
boolean s=dataTypeWS.addStudent(new Student());
System.out.println(s);
List<Student> list=dataTypeWS.getStudentByPrice(12);
System.out.println(list);
Return r=dataTypeWS.getAllStudentMap();
List<com.tg.web.service.GetAllStudentMapResponse.Return.Entry> entrys=r.getEntry();
for(com.tg.web.service.GetAllStudentMapResponse.Return.Entry entry:entrys){
Integer id=entry.getKey();
Student student=entry.getValue();
System.out.println(id+"-"+student);
}
}
1 0
- CXF 发布 Web Service
- CXF 发布Web Service - JaxWsWebServicePublisherBeanPostProcessor
- 使用cxf发布Web Service
- 用cxf发布和调用web service
- Spring CXF Mybatis 发布 Web Service 实例
- 用cxf发布和调用web service
- Cxf:构建web service和发布web service
- CXF发布web service时,hibernate关系循环的问题
- CXF实战之在Tomcat中发布Web Service(二)
- Web Service Jaxws注解、CXF注解和发布
- 基于Maven在Spring中集成CXF,发布Web Service
- 基于Maven在Spring中集成CXF,发布Web Service
- 9.Web Service Spring整合CXF之发布服务
- Java CXF RestFul风格的web service发布与调用
- web service cxf demo
- CXF Web Service Tutorial
- CXF调用web service
- Java Web Service-CXF
- LeetCode_power-of-two
- 【D2】Python一周入门
- linux 学习笔记之权限管理命令
- VMWare下linux安装及中文语言包安装详细步骤
- IOS开发之手势——UIGestureRecognizer 共存
- CXF 发布 Web Service
- 分析JAVA应用CPU占用过高的问题
- Objective-C基础知识之(五):NSString
- Java学习笔记---设计模式工厂方法模式
- c语言-预处理指令
- TCP三次握手、四次挥手
- excel/csv导入postgresql
- Linux 系统安全 及 lnmp 安装
- iOS导航栏NavigationBar的颜色,按钮和标题以及字体颜色