【笔记】WebService CXF与SSM整合,模拟实名认证功能
来源:互联网 发布:企业app建站源码 编辑:程序博客网 时间:2024/06/06 05:05
之前写的一个校友网项目中的实名认证功能,需要调用学校的学籍系统接口,实现自动实名审核功能。
一、接口开发
【web.xml】
<servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/webservice/*</url-pattern> </servlet-mapping>
【spring-webservice.xml】
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <!-- 自动扫描 --> <context:component-scan base-package="com.jul_11th.*" /> <!-- 定义服务提供者 --> <jaxws:endpoint implementor="#myWebServiceImpl" address="/MyWebService"/></beans>
【服务接口】
package com.jul_11th.webservice;import javax.jws.WebService;@WebServicepublic interface MyWebService { /** * 实名认证服务 */ boolean Authentication(String realName,String id);}
【服务接口实现类】
package com.jul_11th.webservice;import javax.annotation.Resource;import javax.jws.WebService;import org.springframework.stereotype.Component;import com.jul_11th.service.IUserService;@Component("myWebServiceImpl")@WebServicepublic class MyWebServiceImpl implements MyWebService { @Resource(name = "userService") private IUserService userService; public boolean Authentication(String realName, String id) { return userService.Authentication(realName, id); }}
二、服务请求,跨平台接口调用
【Client】
package com.jul_11th.client;//import org.apache.cxf.frontend.ClientProxy;import com.jul_11th.webservice.MyWebService;import com.jul_11th.webservice.MyWebServiceImplService;public class Client { public static void main(String[] args) { MyWebServiceImplService service = new MyWebServiceImplService(); MyWebService hw = service.getMyWebServiceImplPort(); //org.apache.cxf.endpoint.Client client=ClientProxy.getClient(hw); //client.getOutInterceptors().add(new AddHeaderInterceptor("admin","admin")); System.out.println(hw.authentication("张小明", "410423199400000000")); }}
【控制台输出】
七月 07, 2017 10:18:24 上午 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL信息: Creating Service {http://webservice.jul_11th.com/}MyWebServiceImplService from WSDL: http://localhost:8080/SSM/webservice/MyWebService?wsdltrue
阅读全文
0 0
- 【笔记】WebService CXF与SSM整合,模拟实名认证功能
- WebService cxf 与 ssm框架的整合
- webservice-cxf-与spring整合
- WebService -Spring与CXF整合
- WebService学习笔记(六)Spring与CXF整合服务端
- WebService学习笔记(八)Spring与CXF整合客户端
- maven+ssm+cxf整合
- WebService之CXF与Spring的整合
- CXF与Spring整合开发WebService服务
- CXF webService 与 SpringMVC 整合要点
- 笔记:CXF与spring整合
- Cxf Webservice安全认证
- Cxf Webservice安全认证
- Cxf Webservice安全认证
- Cxf Webservice安全认证
- 整合spring与cxf,利用cxf编写webservice
- 整合spring与cxf,利用cxf编写webservice
- 华付实名认证 传统实名认证与华付实名认证的区别
- 关于RXbinding的一些常规使用
- [Caffe]ubuntu无cuda安装caffe
- linux下生成动态库和静态库
- 在springmvc中 @RequestMapping(value={"", "/"})是什么意思?
- myeclipse配置打开jsp默认使用sublime编辑器
- 【笔记】WebService CXF与SSM整合,模拟实名认证功能
- C++基本语法
- DPDK 使用网卡ip/tcp/udp checksum offload
- jenkins保持持续登录后,立即构建报错
- DOC下运行java工程报错:找不到或无法加载主类 xxx
- JNI和NDK编程
- easyui的combotree组件undefined问题
- Oracle索引详细介绍和使用
- 【Caffe】ubuntu14.04+caffe+gpu