webservice配置
服务端配置:
第一步:引用jar包
commons-httpclient.jar
commons-logging.jar
jdom-10.jar
wsdl4j-1.6.1.jar
xbean-spring-2.8.jar
xfire-all-1.2.6.jar
第二步:添加配置文件
路径:WEB-INF/config/xfire-servlet.xml
内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- START SNIPPET: xfire -->
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/userWeb">
<ref bean="sso"/>
</entry>
</map>
</property>
</bean>
<!-- Declare a parent bean with all properties common to both services -->
<bean id="sso" class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory">
<ref bean="xfire.serviceFactory"/>
</property>
<property name="xfire">
<ref bean="xfire"/>
</property>
<property name="serviceBean">
<ref bean="cmsUserWebMng"/>
</property>
<property name="serviceClass">
<value>com.jeecms.cms.manager.main.CmsUserWebMng</value>
</property>
</bean>
<!-- END SNIPPET: xfire -->
</beans>
第三步:修改web。xml
添加配置:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/application-context.xml
/WEB-INF/config/cache-context.xml
/WEB-INF/config/captcha-context.xml
/WEB-INF/config/jeecore-context.xml
/WEB-INF/config/jeecms-context.xml
/WEB-INF/config/xfire-servlet.xml//添加配置
</param-value>
</context-param>
增加:
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/portal/door/services/*</url-pattern>
</servlet-mapping>
第四步:添加接口和实现方法CmsUserWebMng和CmsUserWebMngImpl
CmsUserWebMng:
package com.jeecms.cms.manager.main;
public interface CmsUserWebMng {
public void save(String username, String password, String email, String ip, String realname);
public void update(String oldUsername, String username, String password, String email);
public void delete(String username);
}
CmsUserWebMngImpl
package com.jeecms.cms.manager.main.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeecms.cms.dao.main.CmsUserDao;
import com.jeecms.cms.entity.main.CmsGroup;
import com.jeecms.cms.entity.main.CmsSite;
import com.jeecms.cms.entity.main.CmsUser;
import com.jeecms.cms.entity.main.CmsUserExt;
import com.jeecms.cms.manager.main.CmsGroupMng;
import com.jeecms.cms.manager.main.CmsSiteMng;
import com.jeecms.cms.manager.main.CmsUserExtMng;
import com.jeecms.cms.manager.main.CmsUserSiteMng;
import com.jeecms.cms.manager.main.CmsUserWebMng;
import com.jeecms.common.hibernate3.Updater;
import com.jeecms.core.entity.UnifiedUser;
import com.jeecms.core.manager.UnifiedUserMng;
@Service
@Transactional
public class CmsUserWebMngImpl implements CmsUserWebMng {
public void save(String username, String password, String email, String ip, String realname) {
// TODO Auto-generated method stub
UnifiedUser unifiedUser = unifiedUserMng.save(username, email,
password, ip);
CmsUser user = new CmsUser();
user.forAdmin(unifiedUser, false, false, 8);
CmsGroup group = null;
CmsSite site = cmsSiteMng.findById(1);
group = cmsGroupMng.getRegDef();
if (group == null) {
throw new RuntimeException(
"register default member group not setted!");
}
user.setGroup(group);
user.init();
dao.save(user);
CmsUserExt userExt = new CmsUserExt();
userExt.setRealname(realname);
cmsUserExtMng.save(userExt, user);
cmsUserSiteMng.save(site, user, Byte.parseByte("1"), true);
System.out.println("管理员添加成功");
}
public void update(String oldUsername, String username, String password, String email) {
// TODO Auto-generated method stub
CmsUser bean = dao.findByUsername(oldUsername);
if (bean != null) {
bean.setUsername(username);
bean.setEmail(email);
Updater<CmsUser> updater = new Updater<CmsUser>(bean);
updater.include("email");
CmsUser user = dao.updateByUpdater(updater);
if (!password.equals("")){
unifiedUserMng.update(user.getId(), password, user.getEmail());
}
System.out.println("更新成功");
}
}
public void delete(String username) {
// TODO Auto-generated method stub
CmsUser bean = dao.findByUsername(username);
unifiedUserMng.deleteById(bean.getId());
CmsUser user = dao.deleteById(bean.getId());
if (user != null) {
System.out.println("删除成功");
}
}
public CmsUserDao dao;
private CmsUserExtMng cmsUserExtMng;
private UnifiedUserMng unifiedUserMng;
private CmsGroupMng cmsGroupMng;
private CmsSiteMng cmsSiteMng;
private CmsUserSiteMng cmsUserSiteMng;
@Autowired
public void setDao(CmsUserDao dao) {
this.dao = dao;
}
@Autowired
public void setCmsUserExtMng(CmsUserExtMng cmsUserExtMng) {
this.cmsUserExtMng = cmsUserExtMng;
}
@Autowired
public void setUnifiedUserMng(UnifiedUserMng unifiedUserMng) {
this.unifiedUserMng = unifiedUserMng;
}
@Autowired
public void setCmsGroupMng(CmsGroupMng cmsGroupMng) {
this.cmsGroupMng = cmsGroupMng;
}
@Autowired
public void setCmsSiteMng(CmsSiteMng cmsSiteMng) {
this.cmsSiteMng = cmsSiteMng;
}
@Autowired
public void setCmsUserSiteMng(CmsUserSiteMng cmsUserSiteMng) {
this.cmsUserSiteMng = cmsUserSiteMng;
}
}
第五步:配置接口及实现类
在config/jeecms-context.xml中添加
<bean id="cmsUserWebMng" class="com.jeecms.cms.manager.main.impl.CmsUserWebMngImpl" />
服务端配置成功
客户端:
public void websave(CmsUser bean, String password, String ip){
org.codehaus.xfire.service.Service srModel = new ObjectServiceFactory().create(CmsUserWebMng.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());// 创建工厂实例
String url = Constants.EMSP_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url);
manager.save(bean.getUsername(), password, bean.getEmail(), ip, bean.getRealname());
} catch (Exception e) {
e.printStackTrace();
}
String url2 = Constants.DSPTECH_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url2);
manager.save(bean.getUsername(), password, bean.getEmail(), ip, bean.getRealname());
} catch (Exception e) {
e.printStackTrace();
}
String url3 = Constants.DSPTALENT_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url3);
manager.save(bean.getUsername(), password, bean.getEmail(), ip, bean.getRealname());
} catch (Exception e) {
e.printStackTrace();
}
}
public void webupdate(String oldUsername, String username, String password, String email){
org.codehaus.xfire.service.Service srModel = new ObjectServiceFactory().create(CmsUserWebMng.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());// 创建工厂实例
String url = Constants.EMSP_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url);
manager.update(oldUsername, username, password, email);
} catch (Exception e) {
e.printStackTrace();
}
String url2 = Constants.DSPTECH_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url2);
manager.update(oldUsername, username, password, email);
} catch (Exception e) {
e.printStackTrace();
}
String url3 = Constants.DSPTALENT_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url3);
manager.update(oldUsername, username, password, email);
} catch (Exception e) {
e.printStackTrace();
}
}
public void webdelete(String username){
org.codehaus.xfire.service.Service srModel = new ObjectServiceFactory().create(CmsUserWebMng.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());// 创建工厂实例
String url = Constants.EMSP_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url);
manager.delete(username);
} catch (Exception e) {
e.printStackTrace();
}
String url2 = Constants.DSPTECH_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url2);
manager.delete(username);
} catch (Exception e) {
e.printStackTrace();
}
String url3 = Constants.DSPTALENT_URL;
try{
CmsUserWebMng manager = (CmsUserWebMng)factory.create(srModel, url3);
manager.delete(username);
} catch (Exception e) {
e.printStackTrace();
}
}
webservice配置的更多相关文章
- 找不到对应的webservice配置参数[ProcessService]
在UI端 保存时 界面显示无法保存 且报此错误 “找不到对应的webservice配置参数[ProcessService]” 此下为解决方法: 首先 在[应用管理平台]--[参数模板设置] 找到你的参 ...
- webservice 配置
webservice 配置 <system.web> <!--允许GET/POST请求 --> <webServices> <protocols> &l ...
- jquery ajax跨域访问webservice配置
1.webservice方法 [System.Web.Script.Services.ScriptService] public class TestService : System.Web.Serv ...
- ajax跨域访问 java controller 和 cxf(webservice) 配置方式(CORS)
1. controller跨域访问,配置方式 重点在这里: <mvc:cors> <mvc:mapping path="/*" allowed-origins=& ...
- .NET总结--WebService 配置与设置,发布
发环境 OS:win10 企业版 开发工具:VS2017 IIS版本:6.0 .NET版本:4.6.1 Web Service 简介 Web Service也叫XML Web Service WebS ...
- log4net类库配置、WebService配置
一.类库配置 结构如下图 1.LogUtility类 public class LogUtility { private static readonly log4net.ILog log = log4 ...
- Axis2 WebService(配置、发布、调用)
准备工作 1.下载:axis2-1.5.4-bin.zip,axis2-1.5.4-war.zip 下载地址:http://axis.apache.org/axis2/java/core/ 2.环境变 ...
- springboot 配置webservice接口
导入依赖的jar <!-- webservice cxf --> <dependency> <groupId>org.apache.cxf</groupId& ...
- cxf+spring+数字签名开发webservice(一)
数字证书的准备 下面做的服务端和客户端证书在例子中无法加解密,不知道什么原因,我是使用正式环境中的客户端和服务端进行开发测试的,所以需要大家自己去准备证书,或者有人知道为什么jdk生成 ...
随机推荐
- Codeforces Zepto Code Rush 2014 -C - Dungeons and Candies
这题给的一个教训:Codeforces没有超时这个概念.本来以为1000*(1000+1)/2*10*10要超时的.结果我想多了. 这题由于k层都可能有关系,所以建一个图,每两个点之间连边,边权为n* ...
- Jenkins学习六:修改Jenkins用户的密码
很多时候在使用jenkins的时候忘记密码了,遇到这种情况,可以看看下面的讲解. Jenkins专有用户的数据存放在JENKINS_HOME/users目录.users目录的结构你一看就懂.users ...
- java 12 - 5 带有缓冲区的字符流
字符流为了高效读写,也提供了对应的字符缓冲流. 字符缓冲流:A. BufferedWriter:字符缓冲输出流 B. BufferedReader:字符缓冲输入流 A.BufferedWriter:字 ...
- 转: CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法
from: http://www.linuxde.net/2014/05/15576.html CentOS 6.4安装pip,CentOS安装python包管理安装工具pip的方法 2014/05/ ...
- Gradle多项目构建
1. 创建项目 首先创建项目,名称为 test: mkdir test && cd test gradle init 这时候的项目结构如下: ➜ test tree . ├── bui ...
- 25Mybatis_查询缓存的基本知识
mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存. 一级和二级缓存的示意图:
- 使用POI getCell 获取空的单元格之后在使用的时候报 NullPointerException
解决办法,在得到cell之后先判断cell是否为空,然后再进行逻辑处理. 得到的cell建议使用去除策略(如左对齐,居中等)的cell,不然有可能受到策略影响而导致结果异常. org.apache.p ...
- dxut.h(29): fatal error C1083: Cannot open include file: 'dxsdkver.h': No such file or directory
从网上download一个三维演示模型的软件编译发现报找不到dxsdkver.h文件,网上查阅这是MS的DirectX sdk中的库文件,于是先download DirectX SDK 安装之后,配置 ...
- SpringMVC 中HttpMessageConverter简介和Http请求415 Unsupported Media Type的问题
一.概述: 本文介绍且记录如何解决在SpringMVC 中遇到415 Unsupported Media Type 的问题,并且顺便介绍Spring MVC的HTTP请求信息转换器HttpMessag ...
- 使用mobile.changePage()时出现的问题(转)
使用mobile.changePage()页面跳转,当跳转到目标页面时,目标页面中的初始化js如$().ready()及其他引入的js都无法执 行,重新刷新页面后才会执行.想到changePage() ...