日期:2014-05-17  浏览次数:21088 次

Hessian实现C#语言开发winforms前端+sshj2ee后台服务(一、服务器端)

大家好,最近实现一个项目需要用到Hessian,麻烦用过Hessian的朋友能帮我看看为什么测试服务调不出服务器端的实体类

首先是客户端,创建实体Bean

?

public class PosInfo implements java.io.Serializable {


	private static final long serialVersionUID = 4791943343138808983L;

	private String posid;
	private String posname;
	private String lmodifydate;

	public String getPosid() {
		return posid;
	}

	public void setPosid(String posid) {
		this.posid = posid;
	}

	public String getPosname() {
		return posname;
	}

	public void setPosname(String posname) {
		this.posname = posname;
	}

	public String getLmodifydate() {
		return lmodifydate;
	}

	public void setLmodifydate(String lmodifydate) {
		this.lmodifydate = lmodifydate;
	}

}

?

?

接下来创建Hessian服务的接口

?

?

public interface IPosService {

	public void savePosition(PosVO vo);

	public void updatePosition(PosVO vo);

	public PosInfo queryPositionById(String posId);

	public void deletePosition(String posId);

	public List queryPositions();

	public String test(String s);

	public List find(String arg0);

}

?

接下来是实现了接口的服务类

?

public class PosServiceImpl implements IPosService {

	private static final Log log = LogFactory.getLog(PosServiceImpl.class);
	// private BaseDAO dao;
	//		
	//	
	// public BaseDAO getDao() {
	// return dao;
	// }
	//	
	// public void setDao(BaseDAO dao) {
	// this.dao = dao;
	// }

	// BeanFactory factory = new ClassPathXmlApplicationContext(
	// "classpath:applicationContext.xml");
	// PosDAO dao = (PosDAO) factory.getBean("posDAO");

	//	
	// ApplicationContext context = new ClassPathXmlApplicationContext(
	// "classpath:application-position.xml");
	// PosDAO dao = (PosDAO) context.getBean("posDAO");
	//	
	private PosDAO dao;

	public PosDAO getDao() {
		return dao;
	}

	public void setDao(PosDAO dao) {
		this.dao = dao;
	}

	private JdbcTemplate jdbcTemplate;

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public List find(String arg0) {
		List list = dao.find(arg0);
		return list;
	}

	public void savePosition(PosVO vo) {

		log.info("add new instance");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");

		PosInfo pos = new PosInfo();
		pos.setPosname(vo.getPosname());
		pos.setLmodifydate(sdf.format(new Date()).toString());
		log.info("now begin save");

		dao.save(pos);
		log.info("add success !");
	}

	public void updatePosition(PosVO vo) {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		PosInfo pos = this.queryPositionById(vo.getPosid());

		pos.setPosname(vo.getPosname());

		pos.setLmodifydate(sdf.format(new Date()).toString());

		dao.update(pos);
	}

	public PosInfo queryPositionById(String posId) {
		return (PosInfo) dao.get(PosInfo.class, posId);
	}

	public void deletePosition(String posId) {
		PosInfo pos = this.queryPositionById(posId);
		
		dao.delete(pos);
	}

	public List queryPositions() {
		
		List poses = dao.find("from PosInfo po order by po.lmodifydate desc");

		return poses;
	}

	public String test(String s) {
		log.info("===========进入service层");
		return dao.test(s);
		
	}

}

?

?

还有service层引用的DAO层

?

public clas