使用xFire webservice框架的问题记载。
目前项目要求:
1.发布web应用程序,通过http协议的方式进行交互。
2.调用webservice head 用户名,密码验证。
3.使用webservice调用传递,接受复杂对象类型(map(String name,String name))。
4.xFire webservice + remedy api + java 代理模式实现 ar 与其它系统流程进行交互进行。
解决技术问题
1. webservice 复杂对象的传递问题
2. remedy api 增加 java 代理模式,多层封装技术。
3.webservcie 项目迁移
ncl_remedy_ws 项目结构
----------------------------------------------------------------------
package com.yjm.comm;
import java.util.HashMap;
public interface InCommInfo {
public String example(String example);
public String md(HashMap<String, String> md);
public String cd(HashMap<String, String> cd);
}
----------------------------------------------------------------------
package com.yjm.comm;
import java.util.HashMap;
import org.apache.log4j.Logger;
import com.yjm.webapp.ConnApp;
/**
* code by yangjm version 1.0
**/
public class InCommInfoImpl implements InCommInfo {
private static Logger log = Logger.getLogger(InCommInfoImpl.class);
public String example(String s) {
return "success!";
}
public String cd(HashMap<String, String> cd) {
ConnApp connApp = new ConnApp();
connApp.dcConnApp(cd);
connApp = null;
log.info("Cteate Data !");
return "success!";
}
public String md(HashMap<String, String> md) {
ConnApp connApp = new ConnApp();
connApp.dmConnApp(md);
connApp = null;
log.info("Modify Data ! ChangeID: " + md.get("ChangeID"));
return "success!";
}
}
-----------------------------------------------------------------------------------
package com.yjm.datamanage;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
import com.bmc.arsys.api.Entry;
import com.bmc.arsys.api.Value;
import com.yjm.pojo.RemedyConfigPojo;
public class DataManage {
private RemedyConfigPojo mRemedyConfigPojo;
private Entry mEntry;
private ARServerUser mrerpo;
private DataMaping mDataMaping;
private static Logger log= Logger.getLogger(DataManage.class);
public void DadaManage() {
}
public Map<Integer, Value> pData(){
return null;
}
public void setmRemedyConfigPojo(RemedyConfigPojo mRemedyConfigPojo) {
this.mRemedyConfigPojo = mRemedyConfigPojo;
}
public RemedyConfigPojo getmRemedyConfigPojo() {
return mRemedyConfigPojo;
}
public DataManage(RemedyConfigPojo mRemedyConfigPojo) {
this.mRemedyConfigPojo = mRemedyConfigPojo;
this.mrerpo=mRemedyConfigPojo.getMrerpo();
mDataMaping= new DataMaping();
}
public HashMap<Integer, Value> ivParse(HashMap<String, String> commHashMap){
return mDataMaping.ivMap(commHashMap);
}
public void ce(HashMap<Integer, Value> mHashMap,String f) {
if ("".equals(mHashMap)) {
log.info("数据处理为空!");
} else {
mEntry = new Entry(mHashMap);
try {
mrerpo.createEntry(f, mEntry);
} catch (ARException e) {
log.info("----create--id-----error------");
e.printStackTrace();
}
}
}
public void me(HashMap<Integer, Value> mHashMap,String f,String ei) {
try {
mEntry=mrerpo.getEntry(f, ei, null);
} catch (ARException e) {
log.info("----get----entry----error!");
e.printStackTrace();
}
try{
mEntry.putAll(mHashMap);
mrerpo.setEntry(f, ei, mEntry, null, 0);
}catch(Exception e){
log.info("----modify---databaseid---error---");
e.printStackTrace();
}
}
/*
* Code by yangjianming version 1.0
*/
public void setmEntry(Entry mEntry) {
this.mEntry = mEntry;
}
public Entry getmEntry() {
return mEntry;
}
public void setMrerpo(ARServerUser mrerpo) {
this.mrerpo = mrerpo;
}
public ARServerUser getMrerpo() {
return mrerpo;
}
public void setmDataMaping(DataMaping mDataMaping) {
this.mDataMaping = mDataMaping;
}
public DataMaping getmDataMaping() {
return mDataMaping;
}
}
--------------------------------------------------------------------------------------------
package com.yjm.datamanage;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import com.bmc.arsys.api.Value;
import com.yjm.datautil.DataUtil;
public class DataMaping {
private HashMap<String, String> commHashMap;
private HashMap<Integer, Value> dHashMap;
protected DataUtil mDataUtil;
public DataMaping() {
mDataUtil = new DataUtil();
}
public HashMap<Integer, Value> ivMap(HashMap<String, String> commHashMap) {
dHashMap = new HashMap<Integer, Value>();
Set<String> mSet = commHashMap.keySet();
HashMap<String, Integer> iHashMap = mDataUtil.getmHashMap();
Iterator<String> it = mSet.iterator();
String define;
while (it.hasNext()) {
define = (String) it.next();
dHashMap.put(iHashMap.get(define), new Value(commHashMap
.get(define)));
}
return dHashMap;
}
public void setCommHashMap(HashMap<String, String> commHashMap) {
this.commHashMap = commHashMap;
}
public HashMap<String, String> getCommHashMap() {
return commHashMap;
}
public void setdHashMap(HashMap<Integer, Value> dHashMap) {
this.dHashMap = dHashMap;
}
public HashMap<Integer,Value> getdHashMap() {
return dHashMap;
}
}
----------------------------------------------------------------------
package com.yjm.datautil;
import java.util.HashMap;
public class DataUtil {
private static DataUtil mDataUtil = null;
private HashMap<String, Integer> mHashMap = null;
public static DataUtil getInstance() {
if (mDataUtil == null) {
mDataUtil = new DataUtil();
}
return mDataUtil;
}
public DataUtil() {
if (null==mHashMap) {
// 防火墙
mHashMap = new HashMap<String, Integer>();
mHashMap.put("cChr_ProcessNumberForFire", 536871135);// 流程单号
mHashMap.put("cChr_ReasonForFire", 536871136);// 申请原因描述
mHashMap.put("cChr_PeerIPAddress", 536871137);// 对端IP地址
mHashMap.put("cChr_PeerPort", 536871138);// 对端端口
mHashMap.put("cChr_IPAddress", 536871139);// 新华段IP地址
mHashMap.put("cChr_ShortPort", 536871140);// 新华短端口
mHashMap.put("dDate_CompletionDate", 536871142);// 填写日期
mHashMap.put("dDate_PlanDate", 536871144);// 计划开通日期
mHashMap.put("rRadio_TemporaryPolicy", 536871145);// 是否为临时策略
mHashMap.put("cChr_OpenTime", 536871146);// 开通时限
mHashMap.put("dDrop_PeerBusinessContacts", 536871147);// 对端业务联系人
mHashMap.put("dDrop_PeerSupportContacts", 536871148);// 对端技术支持联系人
// 服务器变更
mHashMap.put("cChr_ServerID", 536871119);// 流程单号
mHashMap.put("cChr_ReasonForServer", 536871120);// 申请原因描述
mHashMap.put("cChr_ServerModel", 536871121);// 服务器型号
mHashMap.put("cChr_CardNumber", 536871123);// 网卡数量
mHashMap.put("cChr_ServerSerialNumber", 536871124);// 服务器序列号
mHashMap.put("cChr_OperatingSystem", 536871125);// 操作系统
mHashMap.put("cChr_BusinessType", 536871126);// 业务类型
mHashMap.put("cChr_Placement", 536871127);// 放置位置
mHashMap.put("rRadio_TemporaryUseForServer", 536871128);// 是否为临时使用
mHashMap.put("dDate_PeriodUseForServer", 536871129);// 使用期限
mHashMap.put("dDrop_UserNameForServer", 536871130);// 使用人姓名
mHashMap.put("cChr_UserContactForServer", 536871131);// 使用者联系方式
mHashMap.put("cChr_UsageForServer", 536871132);// 使用者情况
mHashMap.put("rRadio_ReturnForServer", 536871133);// 是否归还
// 网络设备变更
mHashMap.put("cChr_ProcessNumber", 536871097);// 流程单号
mHashMap.put("cChr_Reason", 536871101);// 申请原因描述
mHashMap.put("dDate_CreateDate", 536871104);// 填写日期
mHashMap.put("cChr_NetworkNumber", 536871105);// 网络设备序列号
mHashMap.put("cChr_Area", 536871106);// 所在区域
mHashMap.put("cChr_DeviceName", 536871107);// 设备名称
mHashMap.put("cChr_Model", 536871108);// 设备型号
mHashMap.put("cChr_PhysicalLocation", 536871109);// 物理位置
mHashMap.put("rRadio_TemporaryUse", 536871110);// 是否为临时使用
mHashMap.put("dDate_PeriodUse", 536871112);// 使用期限
mHashMap.put("dDrop_UserName", 536871113);// 使用人姓名
mHashMap.put("cChr_UserContact", 536871114);// 使用者联系方式
mHashMap.put("cChr_Usage", 536871115);// 使用情况
mHashMap.put("rRadio_Return", 536871116);// 是否归还
mHashMap.put("dDrop_ReturnName", 536871117);// 归还人
//
mHashMap.put("Request ID", 1);// 变更单号
mHashMap.put("Status", 536871030);// 状态
mHashMap.put("Summary", 536871029);// 标题
mHashMap.put("Description", 536870919);// 内容
mHashMap.put("cChr_Category", 936870950);// 变更类型
mHashMap.put("ChangeCause", 536870923);// 变更原因
mHashMap.put("Impact", 536870925);// 影响度
mHashMap.put("Urgency", 536870926);// 紧急度
mHashMap.put("Priority", 536870927);// 优先级
mHashMap.put("ChangeType", 536870941);// 变更类型
mHashMap.put("aChr_chgManager", 536870939);// 变更经理
mHashMap.put("RequestName", 536870932);// 姓名
mHashMap.put("Summary11", 8);// 标题11
mHashMap.put("Submitter", 2);// Submitter
mHashMap.put("aChr_chgManagegroup", 536870938);// 变更经理组
mHashMap.put("Status1", 7);// 状态1
mHashMap.put("cChr_requesterID", 536870946);// 请求人ID
mHashMap.put("ModelKeyName", 601000103);// ModelKeyName
mHashMap.put("ModelKey", 601000102);// ModelKey
}
}
/*
* Code by yangjianming version 1.0
*/
public HashMap<String, Integer> getmHashMap() {
return mHashMap;
}
public void setmHashMap(HashMap<String, Integer> mHashMap) {
this.mHashMap = mHashMap;
}
}
------------------------------------------------------------------------------
package com.yjm.pojo;
import org.apache.log4j.Logger;
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
import com.bmc.arsys.api.Entry;
import com.bmc.arsys.api.Value;
public class RemedyConfigPojo {
private ARServerUser mrerpo;
private static Logger log = Logger.getLogger(RemedyConfigPojo.class);
public ARServerUser getMrerpo(){
return mrerpo;
}
public void setMrerpo(ARServerUser mrerpo) {
this.mrerpo = mrerpo;
}
private String conner;
private String connrd;
private String rer;
public String getConner() {
return conner;
}
public void setConner(String conner) {
this.conner = conner;
}
public String getConnrd() {
return connrd;
}
public void setConnrd(String connrd) {
this.connrd = connrd;
}
public String getRer() {
return rer;
}
public void setRer(String rer) {
this.rer = rer;
}
public String getRerform() {
return rerform;
}
public void setRerform(String rerform) {
this.rerform = rerform;
}
private String rerform;
Entry mEntry;
public RemedyConfigPojo() {
}
public RemedyConfigPojo(String ure, String pd, String rer, String form) {
mrerpo = new ARServerUser();
this.conner = ure;
this.connrd = pd;
this.rer = rer;
this.rerform = form;
mrerpo.setServer(rer);
mrerpo.setUser(ure);
mrerpo.setPassword(pd);
}
/*
* Code by yangjianming version 1.0
*/
public void verify() {
try {
mrerpo.verifyUser();
} catch (ARException e) {
log.info("-----------ver--u--f--------");
e.printStackTrace();
}
}
public void cle() {
mrerpo.logout();
}
/*
* SimpleM
*/
public void te(String ei, int num, String val) {
try {
mEntry = mrerpo.getEntry(rerform, ei, null);
mEntry.put(Integer.valueOf(num), new Value(val));
mrerpo.setEntry(rerform, ei, mEntry, null, 0);
} catch (ARException e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------------
package com.yjm.webapp;
import java.util.HashMap;
import org.apache.log4j.Logger;
import com.bmc.arsys.api.Value;
import com.yjm.datamanage.DataManage;
import com.yjm.pojo.RemedyConfigPojo;
public class ConnApp {
private RemedyConfigPojo mRemedyConfigPojo;
private DataManage mDataManage;
private String f;
static Logger log =Logger.getLogger(ConnApp.class);
public ConnApp(String ur,String ps,String ser,String form){
mRemedyConfigPojo=new RemedyConfigPojo(ur,ps,ser,form);
setmDataManage(new DataManage(mRemedyConfigPojo));
this.f=form;
}
public ConnApp(){
mRemedyConfigPojo=new RemedyConfigPojo("Demo","","10.1.80.47","CHG_ApplicationForm");
setmDataManage(new DataManage(mRemedyConfigPojo));
this.f="CHG_ApplicationForm";
}
public void setmRemedyConfigPojo(RemedyConfigPojo mRemedyConfigPojo) {
this.mRemedyConfigPojo = mRemedyConfigPojo;
}
public RemedyConfigPojo getmRemedyConfigPojo() {
return mRemedyConfigPojo;
}
/*
* Code by yangjianming
* version 1.0
* */
public void verfidyCon(){
log.info("-----------v--u----------");
mRemedyConfigPojo.verify();
}
public void lay(){
log.info("-----------v--l----------");
mRemedyConfigPojo.cle();
}
public void dD(String ei,int num,String val){
verfidyCon();
log.info("---------s-t-d--------------");
mRemedyConfigPojo.te(ei, num, val);
lay();
}
public void dcConnApp(HashMap<String, String> sHashmap){
dcs(mDataManage.ivParse(sHashmap));
}
public void dmConnApp(HashMap<String, String> sHashmap){
dms(mDataManage.ivParse(sHashmap),sHashmap.get("Request ID"));
}
public void dcs(HashMap<Integer, Value> mHashMap){
System.out.println(mRemedyConfigPojo.getRerform());
verfidyCon();
mDataManage.ce(mHashMap, mRemedyConfigPojo.getRerform());
lay();
}
public void dms(HashMap<Integer, Value> mHashMap,String num){
mDataManage.me(mHashMap, mRemedyConfigPojo.getRerform(),num);
}
public void setmDataManage(DataManage mDataManage) {
this.mDataManage = mDataManage;
}
public DataManage getmDataManage() {
return mDataManage;
}
public void setF(String f) {
this.f = f;
}
public String getF() {
return f;
}
}
------------------------------------------------------------------
log4j.configuration= log4j.properties
#log4j.rootCategory=INFO,CONSOLE
log4j.rootCategory=INFO,LOGINFO,CONSOLE
log4j.appender.LOGINFO=org.apache.log4j.DailyRollingFileAppender
log4j.appender.LOGINFO.File=C\:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\ncl_remedy_ws\\WEB-INF\\classes\\log\\webservice_info.log
log4j.appender.LOGINFO.Append=true
log4j.appender.LOGINFO.DatePattern='.'yyyy-MM-dd
log4j.appender.LOGINFO.Threshold=INFO
log4j.appender.LOGINFO.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGINFO.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} %m%n
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} %m%n