CXF在项目中的真实运用--WS服务编写

转载自:http://blog.csdn.net/jiangtongcn/article/details/8093184


我的项目是一个医疗用品公司的网站,其中的诊所数据、工单数据、工单图片数据来自客户的另个自己CS系统。客户需要每天定时上传这些数据到我的服务器。考虑使用WebService作为解决方案.

   1、处于了团队分工合作考虑,我的整个解决方案由多个项目构成:

 2、SY WS就是CXF WebService项目,这个WS比较简单:

项目结构:

各个包说明如下:

com.defshare.sy.ws:WS接口包

com.defshare.sy.ws.config:WS配置包

com.defshare.sy.ws.impl:WS实现类包

com.defshare.sy.ws.po:WS的VO类包

com.defshare.sy.ws.test:WS测试包

ws.properties:存放WS所有接口访问的安全账户和密码以及文件上传后的存放路径

只有一个接口,代码如下:

 

  1. package com.defshare.sy.ws;  
  2.   
  3. import javax.jws.WebMethod;  
  4. import javax.jws.WebParam;  
  5. import javax.jws.WebService;  
  6.   
  7. import com.defshare.sy.ws.po.Clinique;  
  8. import com.defshare.sy.ws.po.ToothSpec;  
  9. import com.defshare.sy.ws.po.WorkList;  
  10. import com.defshare.sy.ws.po.WorkListPicFile;  
  11.   
  12. @WebService(targetNamespace="http://www.springframework.org/schema/beans")  
  13. public interface ISYWebService {  
  14.   
  15.     /** 
  16.      * <pre> 
  17.      * 上传工单[工单中包含牙齿规格],同时记录工单上传历史            
  18.      * </pre> 
  19.      * @param workLists 要上传工单所组成的数组 
  20.      * @return 上传结果 
  21.      */  
  22.     @WebMethod  
  23.     public int upLoadWorkList(@WebParam String userName,@WebParam String password,@WebParam WorkList[] workLists);  
  24.       
  25.       
  26.     /** 
  27.      * 上传诊所信息,同时记录上传历史 
  28.      * @param cliniques 要上传诊所所组成的数组 
  29.      * @return 上传结果 
  30.      */  
  31.     public int upLoadClinique(@WebParam String userName,@WebParam String password,@WebParam Clinique[] cliniques);  
  32.       
  33.     /** 
  34.      * 上传工单图片文件,如果该图片文件对应的工单编号在系统中不存在则当前文件上传失败 
  35.      * @param file 要上传的工单图片文件 
  36.      * @return 上传结果 
  37.      */  
  38.     @WebMethod  
  39.     public int upLoadWorkListPic(@WebParam String userName,@WebParam String password,@WebParam WorkListPicFile file);  
  40.       
  41.     /** 
  42.      * 更新工单,工单编号不能存在则更新失败 
  43.      * @param workList 包含更新后工单信息的工单对象 
  44.      * @return 更新结果 
  45.      */  
  46.     @WebMethod  
  47.     public int updateWorkList(@WebParam String userName,@WebParam String password,@WebParam WorkList workList);  
  48.       
  49.     /** 
  50.      * 更新牙齿规格的工序 
  51.      * @param toothSpecId 牙齿规格编号 
  52.      * @param gx 新的工序 
  53.      * @return 
  54.      */  
  55.     @WebMethod  
  56.     public int updateToothSpecGX(@WebParam String toothSpecId,@WebParam String gx);  
  57.       
  58.           
  59.     /** 
  60.      * 更新诊所信息,诊所编号不存在则更新失败 
  61.      * @param cliniques 包含更新后诊所信息的工单对象 
  62.      * @return 更新结果 
  63.      */  
  64.     @WebMethod  
  65.     public int updateClinique(@WebParam String userName,@WebParam String password,@WebParam Clinique cliniques);  
  66.       
  67.     /** 
  68.      * 删除工单,删除工单要一并删除工单对应的图片 
  69.      * @param workListId 要删除工单的编号 
  70.      * @return 删除结果 
  71.      */  
  72.     @WebMethod  
  73.     public int removeWorkList(@WebParam String userName,@WebParam String password,@WebParam String workListId);  
  74.       
  75.       
  76.       
  77.       
  78.       
  79.     /** 
  80.      * <h3>成功</h3> 
  81.      * <p>SUCCESS = 0</p> 
  82.      */  
  83.     public static final int SUCCESS = 0;  
  84.       
  85.       
  86.       
  87.     /** 
  88.      * <h3>工单编号为空</h3> 
  89.      * <p>WORKLIST_ID_IS_EMPTY = 1</p> 
  90.      */  
  91.     public static final int WORKLIST_ID_IS_EMPTY = 1;  
  92.       
  93.     /** 
  94.      * <h3>诊所编号为空</h3> 
  95.      * <p>CLINIQUE_ID_IS_EMPTY = 2</p> 
  96.      */  
  97.     public static final int CLINIQUE_ID_IS_EMPTY = 2;  
  98.       
  99.     /** 
  100.      * <h3>没有文件信息上传</h3> 
  101.      * <p>NO_FILEINFO_UPLOAD = 3</p> 
  102.      */  
  103.     public static final int NO_FILEINFO_UPLOAD = 3;  
  104.       
  105.     /** 
  106.      * <h3>没有工单信息可以上传</h3> 
  107.      * <p> NO_WORKLIST_UPLOAD = 4</p> 
  108.      */  
  109.     public static final int NO_WORKLIST_UPLOAD = 4;  
  110.       
  111.     /** 
  112.      * <h3>没有工单图片文件可以上传</h3> 
  113.      * <p> NO_WORKLIST_PIC_UPLOAD = 5</p> 
  114.      */  
  115.     public static final int NO_WORKLIST_PIC_UPLOAD = 5;  
  116.       
  117.     /** 
  118.      * <h3>没有诊所信息可以上传</h3> 
  119.      * <p>NO_CLINIQUE_UPLOAD = 6</p> 
  120.      */  
  121.     public static final int NO_CLINIQUE_UPLOAD = 6;  
  122.       
  123.     /** 
  124.      * <h3>没有工单可以更新</h3> 
  125.      * <p>NO_WORKLIST_UPDATE = 7</p> 
  126.      */  
  127.     public static final int NO_WORKLIST_UPDATE = 7;  
  128.       
  129.     /** 
  130.      * <h3>没有诊所信息可以更新</h3> 
  131.      * <p>NO_CLINIQUE_UPDATE = 8</p> 
  132.      */  
  133.     public static final int NO_CLINIQUE_UPDATE = 8;  
  134.       
  135.     /** 
  136.      * <h3>不安全的调用</h3> 
  137.      * <p>INSECURE_CALL = 9</p> 
  138.      */  
  139.     public static final int INSECURE_CALL = 9;  
  140.       
  141.     /** 
  142.      * <h3>不存在的工单[上传工单图片时检查]</h3> 
  143.      * <p>NO_EXSITS_WORKLIST = 10</p> 
  144.      */  
  145.     public static final int NO_EXSITS_WORKLIST = 10;  
  146.       
  147.     /** 
  148.      * <h3>输入输出异常</h3> 
  149.      * <p>IO_EXCEPTION = 11</p> 
  150.      */  
  151.     public static final int IO_EXCEPTION = 11;  
  152.     /** 
  153.      * <h3>录入数据失败[存在重复数据]</h3> 
  154.      * <p>IO_EXCEPTION = 12</p> 
  155.      */  
  156.     public static final int IO_REPEAT = 12;  
  157.       
  158.     /** 
  159.      * 应用程序异常 
  160.      */  
  161.     public static final int APPLICATION_EXCEPTION = 13;  
  162.       
  163.     /** 
  164.      * 数据库异常 
  165.      */  
  166.     public static final int SQLEXCEPTION = 14;  
  167.     /** 
  168.      * <h3>规格编号为空</h3> 
  169.      * <p>TOOTHSPEC_ID_IS_EMPTY = 15</p> 
  170.      */  
  171.     public static final int TOOTHSPEC_ID_IS_EMPTY = 15;  
  172.       
  173. }  


3、实现类如下:

  1. package com.defshare.sy.ws.impl;  
  2.   
  3. import java.io.File;  
  4. import java.io.IOException;  
  5. import java.io.OutputStream;  
  6. import java.sql.Timestamp;  
  7. import java.util.List;  
  8. import java.util.UUID;  
  9.   
  10. import javax.jws.WebParam;  
  11. import javax.jws.WebService;  
  12. import javax.servlet.ServletContext;  
  13.   
  14. import org.apache.commons.io.FileUtils;  
  15. import org.apache.commons.io.IOUtils;  
  16. import org.apache.commons.lang.StringUtils;  
  17. import org.apache.log4j.Logger;  
  18. import org.aspectj.lang.annotation.AfterThrowing;  
  19. import org.hibernate.HibernateException;  
  20. import org.hibernate.Session;  
  21. import org.hibernate.criterion.Criterion;  
  22. import org.hibernate.criterion.ProjectionList;  
  23. import org.hibernate.criterion.Projections;  
  24. import org.hibernate.criterion.Restrictions;  
  25. import org.springframework.web.context.ServletContextAware;  
  26.   
  27. import com.defshare.foundation.dao.IHibernateCallback;  
  28. import com.defshare.foundation.global.DateUtil;  
  29. import com.defshare.foundation.global.ExceptionUtil;  
  30. import com.defshare.foundation.pubs.Md5Encrypt;  
  31. import com.defshare.sy.biz.impl.ServiceTemplate;  
  32. import com.defshare.sy.po.SystemLog;  
  33. import com.defshare.sy.po.ToothSpec;  
  34. import com.defshare.sy.po.WorkListHistory;  
  35. import com.defshare.sy.ws.ISYWebService;  
  36. import com.defshare.sy.ws.po.Clinique;  
  37. import com.defshare.sy.ws.po.WorkList;  
  38. import com.defshare.sy.ws.po.WorkListPicFile;  
  39.   
  40. //@Service("syWebService")  
  41. @WebService(targetNamespace = "http://www.springframework.org/schema/beans")  
  42. public class SYWebService implements ISYWebService, ServletContextAware {  
  43.   
  44.     Logger LOG = Logger.getLogger(SYWebService.class);  
  45.   
  46.     /** 
  47.      * 删除工单 
  48.      *  
  49.      * <pre> 
  50.      *  1.查询出工单关联的图片名称:xxx.jpg,xxx2.jpg,xxx3.jpg 
  51.      *  2.删除工单关联的牙齿规格数据 session.delete(arg0) 
  52.      *  3.删除工单数据    session.delete(arg0) 
  53.      *  4.循环删除管理的图片  
  54.      *  5.以上步骤2、3、4必须运行在一个事务里面 
  55.      * </pre> 
  56.      */  
  57.   
  58.     @Override  
  59.     public int removeWorkList(@WebParam String userName,  
  60.             @WebParam String password, final String workListId) {  
  61.         // 判断登陆信息是否有效  
  62.         if (!isSecure(userName, password))  
  63.             return INSECURE_CALL;  
  64.         // 判断工单id是否有效  
  65.         if (StringUtils.isBlank(workListId))  
  66.             return WORKLIST_ID_IS_EMPTY;  
  67.   
  68.         return (Integer)serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  69.   
  70.             @SuppressWarnings("unchecked")  
  71.             @Override  
  72.             public Object doInHibernate(Session session) {  
  73.                 // 删除工单  
  74.                 LOG.info(session.isOpen() ? "Hibernate Session 是有效的"  
  75.                         : "Hibernate session是无效的");  
  76.                 try {  
  77.                     ProjectionList plist = Projections.projectionList();  
  78.                     plist.add(Projections.property("pics"));  
  79.                     plist.add(Projections.property("gdbh"));  
  80.                     // 查询工单图片  
  81.                     Object[] wl = (Object[]) session.createCriteria(  
  82.                             com.defshare.sy.po.WorkList.class).setProjection(  
  83.                             plist).add(Restrictions.eq("gdbh", workListId))  
  84.                             .uniqueResult();  
  85.                     if (wl == null && wl.length <= 0)  
  86.                         return NO_EXSITS_WORKLIST;  
  87.   
  88.                     LOG  
  89.                             .info("-------------------------------------------------------------------------------");  
  90.                     String pics = null;  
  91.                     String[] picses = null;  
  92.                     if (wl[0] != null) {  
  93.                         pics = wl[0].toString();  
  94.                         picses = pics.split(",");  
  95.                     }  
  96.   
  97.                     LOG.info("-----------图片名称-------------" + pics);  
  98.   
  99.                     // 查询牙齿规格  
  100.                     List<ToothSpec> toothlist = (List<ToothSpec>) session  
  101.                             .createCriteria(ToothSpec.class).add(  
  102.                                     Restrictions.eq("gdbh", workListId)).list();  
  103.                     // 循环删除牙齿规格  
  104.                     if (toothlist != null && toothlist.size() > 0) {  
  105.                         for (ToothSpec toothSpec : toothlist) {  
  106.                             session.delete(toothSpec);  
  107.                             LOG.info("删除牙齿规格成功");  
  108.                         }  
  109.                     }  
  110.                     // 删除工单  
  111.                     com.defshare.sy.po.WorkList worklist = new com.defshare.sy.po.WorkList();  
  112.                     worklist.setGdbh(workListId);  
  113.                     session.delete(worklist);  
  114.                     LOG.info("删除工单成功");  
  115.   
  116.                     // LOG.info("===========================" + getSavepath());  
  117.                     // File file = new File(getSavepath());  
  118.                     // String path = file.getAbsolutePath();  
  119.                     // System.out.println("---------" + path);  
  120.                     // // 循环删除本地图片 --------------------(本地测试)worklist  
  121.                     // if (picses != null && picses.length > 0) {  
  122.                     // for (String ps : picses) {  
  123.                     // File f = new File(path + "/" + ps);  
  124.                     // f.delete();  
  125.                     // LOG.info("每次本地删除文件成功");  
  126.                     // }  
  127.                     // }  
  128.   
  129.                     // 循环删除本地图片 --------------------(服务器)  
  130.                     if (picses != null && picses.length > 0) {  
  131.                         for (String ps : picses) {  
  132.                             File f = new File(servletContext.getRealPath("/")  
  133.                                     + "/" + getSavepath() + "/" + ps);  
  134.                             f.delete();  
  135.                         }  
  136.                     }  
  137.                 } catch (HibernateException e) {  
  138.                     return NO_EXSITS_WORKLIST;  
  139.                 }  
  140.                 return SUCCESS;  
  141.             }  
  142.         });  
  143.           
  144.     }  
  145.   
  146.     /** 
  147.      * 上传诊所信息 
  148.      */  
  149.     @Override  
  150.     public int upLoadClinique(@WebParam String userName,  
  151.             @WebParam String password, final Clinique[] cliniques) {  
  152.         if (!isSecure(userName, password))  
  153.             return INSECURE_CALL;  
  154.         if (null == cliniques || 0 == cliniques.length)  
  155.             return NO_CLINIQUE_UPLOAD;  
  156.   
  157.         return (Integer)serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  158.   
  159.             private static final long serialVersionUID = -1708351120071544240L;  
  160.   
  161.             @Override  
  162.             public Object doInHibernate(Session session) {  
  163.                 for (Clinique clinique : cliniques) {  
  164.                     if (StringUtils.isBlank(clinique.getZsid()))  
  165.                         return CLINIQUE_ID_IS_EMPTY;  
  166.                     com.defshare.sy.po.Clinique cli = new com.defshare.sy.po.Clinique();  
  167.                     cli.setDq(clinique.getDq());  
  168.                     cli.setZsid(clinique.getZsid());  
  169.                     cli.setDqbh(clinique.getDqbh());  
  170.                     cli.setDxts(clinique.getDxts());  
  171.                     cli.setLxdh(clinique.getLxdh());  
  172.                     cli.setYsxm(clinique.getYsxm());  
  173.                     cli.setYwjl(clinique.getYwjl());  
  174.                     cli.setYwy(clinique.getYwy());  
  175.                     cli.setZsdz(clinique.getZsdz());  
  176.                     cli.setZsjx(clinique.getZsjx());  
  177.                     cli.setZsmc(clinique.getZsmc());  
  178.                     if(clinique.getZsmm()==null || "".equals(clinique.getZsmm())){  
  179.                         clinique.setZsmm("0000");  
  180.                     }  
  181.                     cli.setZsmm(new Md5Encrypt().getMD5ofStr(clinique.getZsmm()));//MD5后再存入数据库  
  182.                     try {  
  183.                         session.save(cli);  
  184.                     } catch (Exception e) {  
  185.                         return IO_REPEAT;  
  186.                     }  
  187.                     WorkListHistory workList = new WorkListHistory();  
  188.                     workList.setKind("2");  
  189.                     workList.setReceiveTime(new Timestamp(System  
  190.                             .currentTimeMillis()));  
  191.                     workList.setBh(cli.getZsid());  
  192.                     workList.setWorkListHistoryId(UUID.randomUUID().toString());  
  193.                     session.save(workList);  
  194.                 }  
  195.                 return SUCCESS;  
  196.             }  
  197.         });  
  198.           
  199.     }  
  200.   
  201.     /** 
  202.      * 上传工单 
  203.      */  
  204.     @Override  
  205.     public int upLoadWorkList(@WebParam String userName,  
  206.             @WebParam String password, final WorkList[] workLists) {  
  207.         if (null == workLists || 0 == workLists.length)  
  208.             return NO_WORKLIST_UPLOAD;  
  209.         if (!isSecure(userName, password))  
  210.             return INSECURE_CALL;  
  211.   
  212.         return (Integer) serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  213.   
  214.             private static final long serialVersionUID = -3808681177275551002L;  
  215.   
  216.             @Override  
  217.             public Object doInHibernate(Session session) {  
  218.   
  219.                 for (WorkList workList : workLists) {  
  220.                     LOG.info(workList.getGdbh());  
  221.                     if (StringUtils.isBlank(workList.getGdbh()))  
  222.                         return WORKLIST_ID_IS_EMPTY;  
  223.                       
  224.                     com.defshare.sy.po.WorkList wo = new com.defshare.sy.po.WorkList();  
  225.                     wo.setBrxm(workList.getBrxm());  
  226.                     wo.setCjr(workList.getCjr());  
  227.                     wo.setCjrq(Timestamp.valueOf(workList.getCjrq()));  
  228.                     wo.setFggdbh(workList.getFggdbh());  
  229.                     wo.setFgyy(workList.getFgyy());  
  230.                     wo.setGdbh(workList.getGdbh());  
  231.                     wo.setJjrq(Timestamp.valueOf(workList.getJjrq()));  
  232.                     wo.setJzrq(Timestamp.valueOf(workList.getJzrq()));  
  233.                     wo.setLuz(workList.getLuz());  
  234.                     wo.setPics(workList.getPics());  
  235.                     wo.setSsdq(workList.getSsdq());  
  236.                     wo.setYsxm(workList.getYsxm());  
  237.                     wo.setYwy(workList.getYwy());  
  238.                     wo.setZsid(workList.getZsid());  
  239.   
  240.                     session.save(wo);  
  241.                     if (workList.getToothSpecs()!= null) {  
  242.                         LOG.info("------------jin---------");  
  243.                         for (com.defshare.sy.ws.po.ToothSpec tt : workList  
  244.                                 .getToothSpecs()) {  
  245.                             if(tt!=null){  
  246.                             ToothSpec ts  = new ToothSpec();  
  247.                             ts.setToothSpecId(tt.getToothSpecId());  
  248.                             ts.setAddsl(tt.getAddsl());  
  249.                             ts.setDx(tt.getDx());  
  250.                             ts.setGdbh(wo.getGdbh());  
  251.                             ts.setGx(tt.getGx());  
  252.                             ts.setHbhid(tt.getHbhid());  
  253.                             ts.setJg(tt.getJg());  
  254.                             ts.setSl(tt.getSl());  
  255.                             ts.setYclx(tt.getYclx());  
  256.                             ts.setYs(tt.getYs());  
  257.                             ts.setYw(tt.getYw());  
  258.                             ts.setZl(tt.getZl());  
  259.                             session.save(ts);  
  260.                         }}  
  261.                     }  
  262.                     LOG.info("------------没进---------");  
  263.                     WorkListHistory work = new WorkListHistory();  
  264.                     work.setKind("0");  
  265.                     work.setReceiveTime(new Timestamp(System  
  266.                             .currentTimeMillis()));  
  267.                     work.setBh(workList.getGdbh());  
  268.                     work.setWorkListHistoryId(UUID.randomUUID().toString());  
  269.                     session.save(work);  
  270.   
  271.                 }  
  272.                 return SUCCESS;  
  273.             }  
  274.   
  275.         });  
  276.     }  
  277.   
  278.     /** 
  279.      * 上传工单图片文件 
  280.      */  
  281.     @Override  
  282.     public int upLoadWorkListPic(@WebParam String userName,  
  283.             @WebParam String password, final WorkListPicFile file) {  
  284.         LOG.info("-----------------------------------------------------");  
  285.         LOG.info("开始执行上传工单图片");  
  286.   
  287.         if (!isSecure(userName, password))  
  288.             return INSECURE_CALL;  
  289.         if (StringUtils.isBlank(file.getWorkListId()))  
  290.             return WORKLIST_ID_IS_EMPTY;  
  291.   
  292.         if (file.getPosition() == 0) {  
  293.             LOG.info("首次上传文件块,检查是否存在该图片关联的工单[" + file.getWorkListId() + "]");  
  294.             // 如果是首次上传则检查工单编号对应的工单在系统中是否存在  
  295.             Object result = serviceTemplate.getCommonDao().execute(  
  296.                     new IHibernateCallback() {  
  297.   
  298.                         @Override  
  299.                         public Object doInHibernate(Session session) {  
  300.                             LOG  
  301.                                     .info(session.isOpen() ? "Hibernate Session 是有效的"  
  302.                                             : "Hibernate session是无效的");  
  303.                             return session.createCriteria(  
  304.                                     com.defshare.sy.po.WorkList.class)  
  305.                                     .setProjection(Projections.rowCount()).add(  
  306.                                             Restrictions.eq("gdbh", file  
  307.                                                     .getWorkListId()))  
  308.                                     .uniqueResult();  
  309.   
  310.                         }  
  311.                     });  
  312.   
  313.             LOG.info("检查结果,存在[" + result + "]条");  
  314.             if (result == null || Integer.valueOf(result.toString()) != 1) {  
  315.                 return NO_EXSITS_WORKLIST;  
  316.             }  
  317.         }  
  318.   
  319.         // 执行上传  
  320.         LOG.info("执行上传文件块[" + file.getBytes().length + "\t"  
  321.                 + file.getPosition() + "/" + file.getFileSize() + "]");  
  322.         OutputStream os = null;  
  323.   
  324.         try {  
  325.             File f = new File(servletContext.getRealPath("/") + "/"  
  326.                     + getSavepath() + "/" + file.getServerFile());  
  327.             LOG.info("服务器保存文件路径:" + f.getAbsolutePath());  
  328.   
  329.             if (file.getPosition() != 0) {  
  330.                 os = FileUtils.openOutputStream(f, true);  
  331.             } else {  
  332.                 os = FileUtils.openOutputStream(f, false);  
  333.             }  
  334.             os.write(file.getBytes());  
  335.         } catch (IOException e) {  
  336.             return IO_EXCEPTION;  
  337.         } finally {  
  338.             if (os != null)  
  339.                 try {  
  340.                     os.close();  
  341.                 } catch (IOException e) {  
  342.                     e.printStackTrace();  
  343.                 }  
  344.             IOUtils.closeQuietly(os);  
  345.         }  
  346.         LOG.info("上传文件块完成");  
  347.   
  348.         // 如果是最后一次上传则修改工单  
  349.         if (file.getPosition() + file.getBytes().length == file.getFileSize()) {  
  350.             LOG.info("最后一次上传文件数据块,上传后修改工单的图片字段");  
  351.             com.defshare.sy.po.WorkList workList = serviceTemplate.findById(  
  352.                     com.defshare.sy.po.WorkList.class, file.getWorkListId());  
  353.             String pics = workList.getPics();  
  354.             pics = pics == null ? "" : pics;  
  355.             pics = pics.equals("") ? file.getServerFile() : pics + ","  
  356.                     + file.getServerFile();  
  357.             workList.setPics(pics);  
  358.         }  
  359.   
  360.         LOG.info("执行本次上传工单图片完成\n");  
  361.         return SUCCESS;  
  362.     }  
  363.   
  364.     /** 
  365.      * 更新诊所信息 
  366.      */  
  367.     @Override  
  368.     public int updateClinique(@WebParam String userName,  
  369.             @WebParam String password, final Clinique clinique) {  
  370.   
  371.         LOG.info("-----------------------------------------------------");  
  372.         LOG.info("----------------开始执行更新---------------------");  
  373.         if (null == clinique)  
  374.             return NO_CLINIQUE_UPDATE;  
  375.         if (StringUtils.isBlank(clinique.getZsid()))  
  376.             return CLINIQUE_ID_IS_EMPTY;  
  377.         if (!isSecure(userName, password))  
  378.             return INSECURE_CALL;  
  379.         LOG  
  380.                 .info(serviceTemplate.getCommonDao() == null ? "serviceTemplate.getCommonDao()无效"  
  381.                         : "serviceTemplate.getCommonDao()有效");  
  382.         LOG.info("-----------------------------------------------------");  
  383.         LOG.info("----------------正在执行更新---------------------");  
  384.         return (Integer)serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  385.             @Override  
  386.             public Object doInHibernate(Session session) {  
  387.                 LOG.info(session.isOpen() ? "Hibernate Session 是有效的"  
  388.                         : "Hibernate session是无效的");  
  389.                 com.defshare.sy.po.Clinique cqe = (com.defshare.sy.po.Clinique) session  
  390.                         .get(com.defshare.sy.po.Clinique.class, clinique  
  391.                                 .getZsid());  
  392.                 if(null==cqe)  
  393.                     return NO_CLINIQUE_UPDATE;  
  394.                 LOG.info("***********" + cqe.getDq());  
  395.                 if (!StringUtils.isBlank(clinique.getDq()))  
  396.                     cqe.setDq(clinique.getDq());  
  397.                 if (!StringUtils.isBlank(clinique.getDqbh()))  
  398.                     cqe.setDqbh(clinique.getDqbh());  
  399.                 if (!StringUtils.isBlank(clinique.getLxdh()))  
  400.                     cqe.setLxdh(clinique.getLxdh());  
  401.                 if (!StringUtils.isBlank(clinique.getLxdh()))  
  402.                     cqe.setLxdh(clinique.getLxdh());  
  403.                 if (!StringUtils.isBlank(clinique.getYwjl()))  
  404.                     cqe.setYwjl(clinique.getYwjl());  
  405.                 if (!StringUtils.isBlank(clinique.getYwy()))  
  406.                     cqe.setYwy(clinique.getYwy());  
  407.                 if (!StringUtils.isBlank(clinique.getZsdz()))  
  408.                     cqe.setZsdz(clinique.getZsdz());  
  409.                 if (!StringUtils.isBlank(clinique.getZsjx()))  
  410.                     cqe.setZsjx(clinique.getZsjx());  
  411.                 if (!StringUtils.isBlank(clinique.getZsmc()))  
  412.                     cqe.setZsmc(clinique.getZsmc());  
  413.                 if (!StringUtils.isBlank(clinique.getZsmm()))  
  414.                     cqe.setZsmm(new Md5Encrypt().getMD5ofStr(clinique.getZsmm()));  
  415.                 if (clinique.getDxts() != null  
  416.                         && !clinique.getDxts().equals(""))  
  417.                     cqe.setDxts(clinique.getDxts());  
  418.                 LOG  
  419.                         .info("-----------------------------------------------------");  
  420.                 LOG.info("----------------更新成功---------------------");  
  421.                 return SUCCESS;  
  422.             }  
  423.         });  
  424.           
  425.     }  
  426.   
  427.     /** 
  428.      * 更新工单 
  429.      */  
  430.     @Override  
  431.     public int updateWorkList(@WebParam final String userName,  
  432.             @WebParam final String password, final WorkList workList) {  
  433.         if (!isSecure(userName, password))  
  434.             return INSECURE_CALL;  
  435.         if (null == workList)  
  436.             return NO_WORKLIST_UPDATE;  
  437.         if (StringUtils.isBlank(workList.getGdbh()))  
  438.             return WORKLIST_ID_IS_EMPTY;  
  439.   
  440.         return (Integer) serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  441.   
  442.             private static final long serialVersionUID = -5913043706463089942L;  
  443.   
  444.             @Override  
  445.             public Object doInHibernate(Session session) {  
  446.                 LOG.info(session.isOpen() ? "Hibernate Session 是有效的"  
  447.                         : "Hibernate session是无效的");  
  448.                 com.defshare.sy.po.WorkList _workList = (com.defshare.sy.po.WorkList) session  
  449.                         .get(com.defshare.sy.po.WorkList.class, workList  
  450.                                 .getGdbh());  
  451.                 if (_workList == null)  
  452.                     return NO_WORKLIST_UPDATE;  
  453.                 if (!StringUtils.isBlank(workList.getFggdbh()))  
  454.                     _workList.setFggdbh(workList.getFggdbh());  
  455.                 if (!StringUtils.isBlank(workList.getZsid()))  
  456.                     _workList.setZsid(workList.getZsid());  
  457.                 if (!StringUtils.isBlank(workList.getYsxm()))  
  458.                     _workList.setYsxm(workList.getYsxm());  
  459.                 if (!StringUtils.isBlank(workList.getBrxm()))  
  460.                     _workList.setBrxm(workList.getBrxm());  
  461.                 if (!StringUtils.isBlank(workList.getYwy()))  
  462.                     _workList.setYwy(workList.getYwy());  
  463.                 if (!StringUtils.isBlank(workList.getSsdq()))  
  464.                     _workList.setSsdq(workList.getSsdq());  
  465.                 if (!StringUtils.isBlank(workList.getFgyy()))  
  466.                     _workList.setFgyy(workList.getFgyy());  
  467.                 if (!StringUtils.isBlank(workList.getJjrq()))  
  468.                     _workList.setJjrq(Timestamp.valueOf(workList.getJjrq()));  
  469.                 if (!StringUtils.isBlank(workList.getCjrq()))  
  470.                     _workList.setCjrq(Timestamp.valueOf(workList.getCjrq()));  
  471.                 if (!StringUtils.isBlank(workList.getJzrq()))  
  472.                     _workList.setJzrq(Timestamp.valueOf(workList.getJzrq()));  
  473.                 if (!StringUtils.isBlank(workList.getXgrq()))  
  474.                     _workList.setXgrq(Timestamp.valueOf(workList.getXgrq()));  
  475.                 if (!StringUtils.isBlank(workList.getXgcs()))  
  476.                     _workList.setXgcs(Short.valueOf(workList.getXgcs()));  
  477.                 if (!StringUtils.isBlank(workList.getLuz()))  
  478.                     _workList.setLuz(workList.getLuz());  
  479.                 if (!StringUtils.isBlank(workList.getCjr()))  
  480.                     _workList.setCjr(workList.getCjr());  
  481.                 if (workList.getToothSpecs() != null) {  
  482.                     for (com.defshare.sy.ws.po.ToothSpec tt : workList  
  483.                             .getToothSpecs()) {  
  484.                         if(tt!=null){  
  485.                         List<ToothSpec> spec = session.createCriteria(  
  486.                                 ToothSpec.class).add(  
  487.                                 Restrictions.eq("gdbh", tt.getGdbh())).list();  
  488.                         ToothSpec ts = null;  
  489.                         LOG.info("ToothSpec查询出的规格:" + spec.size());  
  490.                         if (spec != null) {  
  491.                             for (ToothSpec toothSpec : spec) {  
  492.                                 LOG.info("ToothSpec查询出的工单编号:"  
  493.                                         + toothSpec.getGdbh());  
  494.                                 session.delete(toothSpec);  
  495.                             }  
  496.                         }  
  497.                         ts = new ToothSpec();  
  498.                         ts.setToothSpecId(tt.getToothSpecId());  
  499.                         ts.setAddsl(tt.getAddsl());  
  500.                         ts.setDx(tt.getDx());  
  501.                         ts.setGdbh(tt.getGdbh());  
  502.                         ts.setGx(tt.getGx());  
  503.                         ts.setHbhid(tt.getHbhid());  
  504.                         ts.setJg(tt.getJg());  
  505.                         ts.setSl(tt.getSl());  
  506.                         ts.setYclx(tt.getYclx());  
  507.                         ts.setYs(tt.getYs());  
  508.                         ts.setYw(tt.getYw());  
  509.                         ts.setZl(tt.getZl());  
  510.                         session.save(ts);  
  511.                     }  
  512.                         }  
  513.                 }  
  514.                 return SUCCESS;  
  515.   
  516.             }  
  517.         });  
  518.   
  519.       
  520.     }  
  521.       
  522.     /** 
  523.      * 更新牙齿规格的工序 
  524.      * @param toothSpecId 牙齿规格编号 
  525.      * @param gx 新的工序 
  526.      * @return 
  527.      */  
  528.     @Override  
  529.     public int updateToothSpecGX(final String toothSpecId, final String gx) {  
  530.         // TODO Auto-generated method stub  
  531.         LOG.info("ToothSpec规格编号:" + toothSpecId);  
  532.         LOG.info("ToothSpec工序:" + gx);  
  533.         if(StringUtils.isBlank(toothSpecId))  
  534.             return TOOTHSPEC_ID_IS_EMPTY;  
  535.         return (Integer)serviceTemplate.getCommonDao().execute(new IHibernateCallback() {  
  536.             @Override  
  537.             public Object doInHibernate(Session session) {  
  538.                 LOG.info("ToothSpec规格编号:" + toothSpecId);  
  539.                 LOG.info("ToothSpec工序:" + gx);  
  540.                 ToothSpec spec=(ToothSpec) session.createCriteria(ToothSpec.class).add(Restrictions.eq("toothSpecId", toothSpecId)).uniqueResult();  
  541.                 LOG.info("ToothSpec查询出的规格:" +spec.getGx());  
  542.                 if(!StringUtils.isBlank(gx))  
  543.                     spec.setGx(gx);  
  544.                 return SUCCESS;  
  545.             }  
  546.         });  
  547.           
  548.     }  
  549.   
  550.     // @Resource(name = "serviceTemplate")  
  551.     private ServiceTemplate serviceTemplate;  
  552.   
  553.     public ServiceTemplate getServiceTemplate() {  
  554.         return serviceTemplate;  
  555.     }  
  556.   
  557.     public void setServiceTemplate(ServiceTemplate serviceTemplate) {  
  558.         this.serviceTemplate = serviceTemplate;  
  559.     }  
  560.   
  561.     /** 
  562.      * 调用是否安全,每个WebService方法应该调用此方法 
  563.      *  
  564.      * @param userName 
  565.      * @param password 
  566.      * @return 
  567.      */  
  568.     private Boolean isSecure(String userName, String password) {  
  569.         if (StringUtils.isBlank(userName) || StringUtils.isBlank(password)) {  
  570.             return false;  
  571.         }  
  572.         return userName.equals(wsUserName) && password.equals(wsPassword);  
  573.     }  
  574.   
  575.     private String wsUserName;  
  576.     private String wsPassword;  
  577.   
  578.     public String getWsUserName() {  
  579.         return wsUserName;  
  580.     }  
  581.   
  582.     public void setWsUserName(String wsUserName) {  
  583.         this.wsUserName = wsUserName;  
  584.     }  
  585.   
  586.     public String getWsPassword() {  
  587.         return wsPassword;  
  588.     }  
  589.   
  590.     public void setWsPassword(String wsPassword) {  
  591.         this.wsPassword = wsPassword;  
  592.     }  
  593.   
  594.     private String savepath = "worklistupfiles";  
  595.   
  596.     public String getSavepath() {  
  597.         return savepath;  
  598.     }  
  599.   
  600.     public void setSavepath(String savepath) {  
  601.         this.savepath = savepath;  
  602.     }  
  603.   
  604.     private ServletContext servletContext;  
  605.   
  606.     public void setServletContext(ServletContext servletContext) {  
  607.         this.servletContext = servletContext;  
  608.     }  
  609.   
  610.       
  611.   
  612. }  

4、CXF配置文件如下:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:jaxws="http://cxf.apache.org/jaxws"  
  5.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  8.            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  9.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
  10.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
  11.            http://cxf.apache.org/jaxws   
  12.            http://cxf.apache.org/schemas/jaxws.xsd"  default-lazy-init="true" default-dependency-check="none">  
  13.   
  14.       
  15.   
  16.     <!--会向cxf jar包去找  -->  
  17.     <import resource="classpath:META-INF/cxf/cxf.xml" />  
  18.     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />  
  19.     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
  20.       
  21.     <!-- 以下Bean的状态可以修改为通过注解实现装配-->  
  22.     <bean id="syWebService" class="com.defshare.sy.ws.impl.SYWebService">  
  23.         <property name="savepath" value="${ws.upfiles}"></property>  
  24.         <property name="serviceTemplate" ref="serviceTemplate"/>  
  25.         <property name="wsUserName" value="${ws.username}"></property>  
  26.         <property name="wsPassword" value="${ws.password}"></property>  
  27.     </bean>  
  28.        
  29.       
  30.     <jaxws:endpoint id="syWS" implementor="#syWebService" address="/SYWebService" endpointName="SYWebService" serviceName="SYWebService">  
  31.         <jaxws:inInterceptors>  
  32.             <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>  
  33.         </jaxws:inInterceptors>  
  34.         <jaxws:outInterceptors>  
  35.             <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>  
  36.         </jaxws:outInterceptors>  
  37.     </jaxws:endpoint>  
  38. </beans>  


 

5、关于WS的VO类的说明:

     VO类的属性成员完全根据WS的客户端需要决定,不一定和项目的PO类属性相同。

     此项目中CXF和Spring、Hibernate集成,开发中曾经反了一个荒唐错误就是“在WS项目中使用VO作Hibernate查询类,导致查询不来系统有没有错误警告,折腾许久”。想在想来可笑。(总结一下:当你遇到一个极近明显而又找不到原因的错误,小心可能只是你的粗心大意造成)

6、这个项目由于和Spring集成,因此方法中凡是涉及数据库部分自然也用到了容器事务。这个事务的配置我是在另一个项目中(SY Core)完成的,这个SY Core项目是我这个项目的Spring配置文件,内容如下:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:jaxws="http://cxf.apache.org/jaxws"  
  5.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  8.            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  9.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
  10.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
  11.            http://cxf.apache.org/jaxws   
  12.            http://cxf.apache.org/schemas/jaxws.xsd" default-lazy-init="true" default-dependency-check="none">  
  13.   
  14.     <bean  
  15.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  16.         <property name="locations">  
  17.             <list>  
  18.                 <value>classpath:jdbc.properties</value>  
  19.                 <value>classpath:ws.properties</value>  
  20.             </list>  
  21.         </property>             
  22.           
  23.     </bean>  
  24.   
  25.     <!-- 扫描类路径下被注解的组件,这些组件将被自动注册为Spring Bean-->  
  26.     <context:component-scan  
  27.         base-package="com.defshare.foundation.dao,com.defshare.sy.biz.impl,com.defshare.sy.ws.impl,com.defshare.sy.web.action" />  
  28.           
  29.     <!--  配置数据源 -->  
  30.     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  
  31.         destroy-method="close">  
  32.         <property name="driverClass">  
  33.             <value>${jdbc.driverClassName}</value>  
  34.         </property>  
  35.         <property name="jdbcUrl">  
  36.             <value>${jdbc.url}</value>  
  37.         </property>  
  38.         <property name="user">  
  39.             <value>${jdbc.username}</value>  
  40.         </property>  
  41.         <property name="password">  
  42.             <value>${jdbc.password}</value>  
  43.         </property>  
  44.         <!--初始化时获取0个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->  
  45.         <property name="initialPoolSize">  
  46.             <value>0</value>  
  47.         </property>  
  48.         <property name="minPoolSize">  
  49.             <value>1</value>  
  50.         </property>  
  51.         <!--连接池中保留的最大连接数。Default: 15 -->   
  52.         <property name="maxPoolSize">  
  53.             <value>15</value>  
  54.         </property>  
  55.           
  56.         <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->  
  57.         <property name="acquireIncrement">  
  58.             <value>1</value>  
  59.         </property>  
  60.         <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->  
  61.         <property name="acquireRetryAttempts">  
  62.             <value>3</value>  
  63.         </property>  
  64.         <!--两次连接中间隔时间,单位毫秒。Default: 1000 -->   
  65.         <property name="acquireRetryDelay">  
  66.             <value>1000</value>  
  67.         </property>  
  68.         <!--连接关闭时默认将所有未提交的操作回滚。Default: false -->  
  69.         <property name="autoCommitOnClose">  
  70.             <value>false</value>  
  71.         </property>   
  72.         <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->  
  73.         <property name="maxIdleTime">  
  74.             <value>1800</value>  
  75.         </property>  
  76.         <!--当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出   
  77.             SQLException,如设为0则无限期等待。单位毫秒。Default: 0   
  78.         -->   
  79.         <property name="checkoutTimeout">  
  80.             <value>30000</value>  
  81.         </property>  
  82.           
  83.         <!--每600秒检查所有连接池中的空闲连接。Default: 0 -->   
  84.         <property name="idleConnectionTestPeriod">  
  85.             <value>600</value>  
  86.         </property>  
  87.           
  88.         <!--c3p0将建一张名为C3P0TEST的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么   
  89.             属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试   
  90.             使用。Default: null  
  91.         -->  
  92.         <property name="automaticTestTable">  
  93.             <value>C3P0TEST</value>  
  94.         </property>  
  95.         <!--获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效   
  96.             保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试   
  97.             获取连接失败后该数据源将申明已断开并永久关闭。Default: false  
  98.         -->   
  99.         <property name="breakAfterAcquireFailure">  
  100.             <value>false</value>  
  101.         </property>   
  102.     </bean>  
  103.      <!--  
  104.     <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"  
  105.         lazy-init="true">  
  106.     </bean>  
  107.     -->  
  108.       
  109.     <!-- 
  110.         Spring针对Hibernate提供的标准本地会话工厂Bean子类,支持JDK1.5以上元数据映射,这个类需要Hibernate3.2以上版本 
  111.     -->  
  112.     <bean id="sessionFactory"  
  113.         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
  114.         <!--  
  115.         <property name="lobHandler">  
  116.             <ref bean="lobHandler" />  
  117.         </property>  
  118.         -->  
  119.         <property name="dataSource" ref="dataSource" />  
  120.         <property name="hibernateProperties">  
  121.             <props>  
  122.                 <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
  123.                 <prop key="hibernate.show_sql">true</prop>  
  124.                 <prop key="hibernate.format_sql">true</prop>  
  125.             </props>  
  126.         </property>  
  127.         <property name="configLocation">  
  128.             <value>classpath:com/defshare/sy/config/hibernate.cfg.xml</value>  
  129.         </property>  
  130.         <property name="packagesToScan" value="com.defshare.sy.po"></property>  
  131.           
  132.         <!-- 存放特殊的查询语句  
  133.         <property name="mappingResources">  
  134.             <list>  
  135.                 <value>com/defshare/sy/config/hibernate/ReportQuery.hbm.xml</value>  
  136.             </list>  
  137.         </property>  
  138.          -->  
  139.     </bean>  
  140.   
  141.     <!-- 
  142.         Spring整合Hibernate提供的Hibernate模板,可以简化Hibernate操作,同时整合Hibenate操作到事务 
  143.     -->  
  144.     <bean name="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">  
  145.         <property name="sessionFactory" ref="sessionFactory"></property>  
  146.     </bean>  
  147.   
  148.     <!-- 事务管理器 -->  
  149.     <bean id="transactionManager"  
  150.         class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  151.         <property name="sessionFactory" ref="sessionFactory"></property>  
  152.     </bean>  
  153.   
  154.     <!-- 事务通知 -->  
  155.     <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  156.         <!-- 配置事务传递属性 -->  
  157.         <tx:attributes>  
  158.             <tx:method name="get*" propagation="REQUIRED" read-only="true" />  
  159.             <tx:method name="find*" propagation="REQUIRED" read-only="true" />  
  160.             <tx:method name="add*" propagation="REQUIRED" />  
  161.             <tx:method name="create*" propagation="REQUIRED" />  
  162.             <tx:method name="save*" propagation="REQUIRED" />  
  163.             <tx:method name="delete*" propagation="REQUIRED" />  
  164.             <tx:method name="update*" propagation="REQUIRED" />  
  165.             <tx:method name="log*" propagation="REQUIRES_NEW"  
  166.                 rollback-for="Exception"/>  
  167.             <tx:method name="*" propagation="REQUIRED" />  
  168.         </tx:attributes>  
  169.     </tx:advice>  
  170.   
  171.     <!-- 事务切面 -->  
  172.     <aop:config>  
  173.         <!--切入点 -->  
  174.         <aop:pointcut id="myPointCutA"  
  175.             expression="execution(* com.defshare.sy.biz.impl.*.*(..))" />  
  176.         <aop:pointcut expression="execution(* com.defshare.sy.ws.impl.*.*(..))" id="myPointCutB"/>  
  177.           
  178.         <!-- 将切入点和通知组合在一起 -->  
  179.         <aop:advisor advice-ref="txAdvice" pointcut-ref="myPointCutA" />  
  180.         <aop:advisor advice-ref="txAdvice" pointcut-ref="myPointCutB"/>  
  181.     </aop:config>  
  182.   
  183.     <!-- 日志工具   
  184.     <bean id="logUtil" class="com.defshare.sy.log.LogUtil"></bean>-->  
  185.   
  186.     <!-- 日志切面   
  187.     <aop:config>  
  188.         <aop:aspect ref="logUtil">  
  189.             <aop:pointcut expression="execution(* com.defshare.sy.biz.impl.*.*(..))"  
  190.                 id="doLog1" />  
  191.             <aop:around pointcut-ref="doLog1" method="doLog" />  
  192.         </aop:aspect>  
  193.     </aop:config>-->  
  194. </beans>  


注意其中的:

<context:component-scan
  base-package="com.defshare.foundation.dao,com.defshare.sy.biz.impl,com.defshare.sy.ws.impl,com.defshare.sy.web.action" />

<!--切入点 -->
  <aop:pointcut id="myPointCutA"
   expression="execution(* com.defshare.sy.biz.impl.*.*(..))" />
  <aop:pointcut expression="execution(* com.defshare.sy.ws.impl.*.*(..))" id="myPointCutB"/>

就是对WS中的方法的事务配置。

当初这个地方忘记配置出现的问题是WS的方法不能完成数据库的写操作(又是折腾许久:))。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值