也就是说,在客户端如何得到或是保存一个实体到服务器上的数据库中? 如何对于服务器上的数据库中的数据进行操作啊?
解决方案 »
- PowerDesigner 逆向工程 怎么导成CDM文件
- 跪求myeclipse下的JSP环境配制方案!!!(458分~~)
- FileInputStream 路径问题,急
- 新号,分数不多,jsecurity用过的进来
- Criteria怎样实现查询三个表,返回两个表的信息啊
- 关于中文转码的问题
- spring+hibernate3.x如何实现写入和读出oracle的blob字段?
- <jsp:include page="..."/>的参数问题。
- 我的Tomcat5.0死活都运行不了servlet,但JSP能正常运行请问大家有没有碰到过这样的情况?我的所有配置都已搞好
- ant 如何使用javac -source 1.4
- flash实现聊天远程交互 由JAVA 实现服务器 Socket实现通信
- 求高手解决删除xml文件中的内容
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.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-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="serverPasswordCallback"
class="com.friendone.base.ws.ServerPasswordCallback"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="wss4jInInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText"/>
<!-- entry key="signaturePropFile" value="..."/-->
<entry key="passwordCallbackRef">
<ref bean="serverPasswordCallback"/>
</entry>
</map>
</constructor-arg>
</bean>
<jaxws:endpoint id="userws"
implementor="#userWSImpl"
address="/UserWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
<ref bean="logInbound"/>
</jaxws:inInterceptors>
</jaxws:endpoint> <!--cxf:bus>
<cxf:inInterceptors>
<ref bean="logInbound"/-->
<!--ref bean="wss4jInInterceptor"/-->
<!--/cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
</cxf:bus--> <jaxws:endpoint id="busirecordws"
implementor="#busiRecordWSImpl"
address="/BusiRecordWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="login"
implementor="#loginImpl"
address="/LoginService" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="staticdataws"
implementor="#staticDataWSImpl"
address="/StaticDataWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="systemparamsws"
implementor="#systemParamsWSImpl"
address="/SystemParamsWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="retcodews"
implementor="#retcodeWSImpl"
address="/RetcodeWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="organizationws"
implementor="#organizationWSImpl"
address="/OrganizationWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="userrolews"
implementor="#userRoleWSImpl"
address="/UserRoleWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="sms"
implementor="#smsWSImpl"
address="/SmsWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
<ref bean="logInbound"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="selecttag"
implementor="#selectTagWSImpl"
address="/SelectTagWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
<ref bean="logInbound"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="importrecords"
implementor="#importRecordsWSImpl"
address="/ImportRecordsWS" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
<ref bean="logInbound"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
<jaxws:endpoint id="staticdata"
implementor="#staticDataServiceImpl"
address="/StaticDataService" >
<jaxws:inInterceptors>
<ref bean="wss4jInInterceptor"/>
</jaxws:inInterceptors>
</jaxws:endpoint>
</beans>客户端的后台代码@Component
public class TaskClientImpl {
//布置任务
private final Logger logger = LoggerFactory.getLogger(this.getClass());
//获取信息发布的起始日期和截止日期
public Object getInfoPubDate(HttpServletRequest request) throws Exception{
String firstdate = DateHelper.getNowTime("yyyy-MM-dd");
String seconddate = DateHelper.addDate(firstdate, 15);
DateRange dr = new DateRange();
dr.setFirstdate(firstdate);
dr.setSeconddate(seconddate);
return dr;
}
public Object getInfoByUseridAndDate(HttpServletRequest request) throws Exception{
LoginInfo login = ServiceHelper.getLoginInfo(request);
String userid=request.getParameter("userid")==null?"":request.getParameter("userid");
String date=request.getParameter("date")==null?"":request.getParameter("date");
UserTaskWS service = (UserTaskWS)ServiceHelper.getBean(request, UserTaskWS.class,"TaskMngService");
ReturnValue ret = service.getInfoByUseridAndDate(login, userid, date);
List<UserTask> list = null;
if(ReturnCode.SUCCESS.equals(ret.getRetCode())){
list = ret.getList(UserTask.class.getName());
return list;
}
return ret;
/*if(ReturnCode.SUCCESS.equals(ret.getRetCode())){
List list = ret.getContent2List(UserTask.class.getName());
return list;
}
return ret;*/
}
}重点是我标为红色的代码 这就是webservice的调用
下面是 服务端的后台相关代码import javax.jws.WebService;import com.friendone.base.domain.LoginInfo;
import com.friendone.base.domain.ReturnValue;
import com.friendone.base.utils.page.Pager;
import com.friendone.base.utils.page.Pages;
import com.friendone.oa.domain.task.CycleTask;
import com.friendone.oa.domain.task.TaskCondition;
import com.friendone.oa.domain.task.TaskInstructor;
import com.friendone.oa.domain.task.TaskReport;
import com.friendone.oa.domain.task.UserTask;@WebService
public interface UserTaskWS<T> {
//查询某人某天的任务情况
public ReturnValue<T> getInfoByUseridAndDate(LoginInfo login,String userid,String date) throws Exception;
//布置任务
public ReturnValue<T> layoutTask(LoginInfo login,UserTask task,String userids,String usernames) throws Exception;
//查询周期任务
public ReturnValue<T> queryCycleTask(LoginInfo logininfo,CycleTask task,Pages pages) throws Exception;
public ReturnValue<T> querytasksum(LoginInfo login) throws Exception;
//根据日程需要查询出该用户的所有未领取和正在执行的任务
/***
* @author gaobq
*/
public ReturnValue<T> queryTaskForAgenda(LoginInfo login,Pages pages) throws Exception;
}注意红色部分 这是接口 再看实现类import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;import javax.jws.WebService;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;@Component
@WebService
@Transactional
public class UserTaskWSImpl extends SimpleJdbcDaoSupport implements UserTaskWS { private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public ReturnValue getInfoByUseridAndDate(LoginInfo login, String userid,
String date) throws Exception {
// TODO Auto-generated method stub
final String qdate = date;
String sql = "select executer,u.progress,taskname, t.content, reporttime from tb_oa_usertask u right join tb_oa_taskreport t on u.id=t.id and u.reporttime=t.updatetime where executer=? and startdate<=? and enddate>=? and u.status<3 and substring(u.reporttime,1,10)=?";
ParameterizedRowMapper<UserTask> map = new ParameterizedRowMapper<UserTask>(){
@Override
public UserTask mapRow(ResultSet rs, int rowNum)
throws SQLException {
UserTask task = new UserTask();
//设置任务的基本信息
task.setTaskname(rs.getString("taskname"));
task.setExecuter(rs.getString("executer"));
task.setProgress(rs.getInt("progress"));
String time = rs.getString("reporttime");
if(time!=null&&qdate.substring(0,10).equals(time.substring(0,10))){
task.setReceivetime(rs.getString("content"));//设置汇报内容借用一下
}else{
task.setReceivetime("没有汇报内容");
}
task.setRe(qdate);
return task;
}
};
logger.info(sql);
ReturnValue ret=null;
try{
Object args=new Object[]{userid,date,date,date.substring(0, 10)};
List list = this.getSimpleJdbcTemplate().query(sql, map, args);
ret = new ReturnValue();
if(list.size()>0){
ret.setRetCode(ReturnCode.SUCCESS);
ret.setListToXML(list);
}else{
ret.setRetCode(ReturnCode.FAIL);
}
//ret.setContentByList(list);
}catch(Exception e){
e.printStackTrace();
}
return ret;
}
}注意红色代码