CXF的使用(一)introduce

本文介绍了一种利用CXF框架实现Java Web服务的方法。该方法将整个系统分为API、服务器和服务客户端三部分,通过定义Java接口和DTO来处理参数和结果,避免了直接处理XML和WSDL文件。
CXF的使用(一)introduce

reference BLOG
http://wiki.springside.org.cn/display/SpringSide3/CXF

We just do the webservice serverside and clientside in a java object way, not wsdl and xml way. First we have the whole system devided into 3 parts.

1. api part
api part defined the methods and functions we need, we put all these in java interfaces, we defined the DTO(data transfer object) to hold all the information in parameters and results.

we have the whole api stucture like this:
com.sillycat.webservice.api.constants hold the constants that define the namespace of webservice
com.sillycat.webservice.api.interfaces define the java interfaces
com.sillycat.webservice.api.models define the parameters in java pojo format
com.sillycat.webservice.api.results define the response in java pojo format

the api part will be made to be a jar file to use in both side serverside and clientside. The serverside use this to be a standard and interface to implementation
The clientside use this to be a java api to call the web service.

2. server part
we just implement the api above the implements of our manager.
we have the whole server structure like this:
com.sillycat.core we just put the business logic codes here and implement our bussiness bean AccountManagerImpl here.
com.sillycat.webservice.ws we call AccountManagerImp0l to implement the ws interface here

the server part will be made to be a war file to deploy in web container and we can see the wsdl file here:
http://localhost:8080/easycxfserver/ws/userservice?wsdl

3. client part
we just treat the webservice api as a normal spring bean use spring configuration, we must get the api.jar and the url of webservice.

The only thing we need to do is to put this in our configuration file easycxfclient/conf/ws-client-context.xml:
<jaxws:client id="userService" serviceClass="com.sillycat.webservice.api.interfaces.UserService"
address="http://localhost:8080/easycxfserver/ws/userservice" />

And then ,call userService in easycxfclient/test/com/sillycat/webservice/api/interfaces/UserServiceTest.java like this:
@Test
public void authUser() {
AuthUserResult result = userService.authUser("admin", "admin");
assertEquals(true, result.isValid());
}

In this way, we do not care about xml or wsdl, all that we are dealing with are java objects. But the shortcoming is that every time when we want to change the api.jar, the client side and server side need to changes there jars and change their codes.
多源数据接入 支持校园各业务系统数据接入:包括教务系统(学生成绩、课程信息)、学工系统(奖惩记录、资助信息)、后勤系统(宿舍分配、能耗数据)、图书馆系统(借阅记录、馆藏信息)、卡通系统(消费数据、门禁记录)等。 接入方式:提供数据库直连(MySQL、SQL Server)、文件导入(CSV、Excel、JSON)、API 接口调用等多种方式,支持实时同步与定时批量同步。 数据标准化与治理 建立校园数据标准体系:统数据格式(如日期格式、学号编码规则)、定义核心数据元(如 “学生” 包含学号、姓名、专业等必选字段)、规范代码集(如性别代码 “1 - 男,2 - 女”)。 数据清洗:自动检测并处理缺失值、重复值、异常值(如成绩 > 100 分),通过规则引擎实现数据校验(如 “学生年龄需在 16-30 岁之间”)。 元数据管理:记录数据来源、格式、更新频率、负责人等信息,生成数据血缘图谱,追踪数据从产生到应用的全生命周期。 二、数据共享与交换核心功能 分布式数据存储 基于 Hadoop HDFS 实现海量数据存储:结构化数据(成绩、消费记录)存入 HBase,非结构化数据(文档、图片、视频)直接存储于 HDFS,日志类数据通过 Flume 采集至 HDFS。 支持数据分片与副本机制,确保数据高可用(默认 3 副本存储),满足校园 PB 级数据存储需求。 数据交换引擎 构建点对点数据交换通道:各部门系统可通过交换引擎向平台上传数据或申请获取授权数据,支持同步 / 异步交换模式。 交换流程管理:定义数据交换规则(如 “学工系统每日向平台同步新增学生信息”),记录交换日志(成功 / 失败状态、数据量),失败时自动重试。 数据脱敏:对敏感数据(如身份证号、银行卡号)在交换过程中进行脱敏处理(如显示 “110********5678”),兼顾共享与隐私保护。
用户信息管理 支持用户注册(手机号 / 社交账号登录)、个人信息完善(如年龄、性别、饮食禁忌、偏好菜系等)。 记录用户行为数据:浏览历史、收藏 / 点赞美食、评分记录(1-5 星)、消费记录(如外卖订单、到店消费)、搜索关键词等。 美食数据管理 存储美食基础信息:名称、分类(中餐 / 西餐 / 日料等)、子类别(川菜 / 粤菜 / 汉堡等)、食材、口味标签(辣 / 甜 / 清淡等)、价格区间、商家信息(名称、地址、评分)、图片等。 支持商家入驻与信息更新,管理员审核美食数据合规性(如食材描述真实性)。 二、协同过滤推荐核心功能 基于用户的协同过滤(User-based CF) 计算用户相似度:通过用户对美食的评分、浏览记录等行为,使用余弦相似度 / 皮尔逊相关系数识别 “相似用户群体”(如用户 A 和用户 B 对 80% 的川菜评分致)。 生成推荐:向目标用户推送 “相似用户喜欢但目标用户未体验过” 的美食(如相似用户高分推荐的新川菜馆)。 基于物品的协同过滤(Item-based CF) 计算美食相似度:分析用户对不同美食的共同评分 / 点击行为,挖掘美食间的关联(如 “点过麻婆豆腐的用户中有 70% 也点过回锅肉”)。 生成推荐:为用户推送 “与已喜欢美食相似” 的菜品(如用户刚收藏了水煮鱼,推荐酸菜鱼、毛血旺)。 混合推荐策略 结合两种协同过滤算法结果,根据场景动态调整权重(如冷启动用户优先基于物品的推荐,活跃用户侧重基于用户的推荐)。 融合用户显式偏好(如标注 “不吃辣”)过滤推荐结果,避免无效推荐。 三、用户交互与推荐展示 个性化推荐页 首页展示 “为你推荐” 列表,按推荐优先级排序,显示美食图片、名称、匹配度(如 “98% 的相似用户喜欢”)、用户评分、距离(适用于到店推荐)等。 支持按场景筛选推荐(如 “午餐推荐”“周末聚餐推荐”“性价比推荐”)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值