WebService实例-CRM系统提供WebService实现用户注册功能
来源:互联网 发布:网络用语ps是什么意思 编辑:程序博客网 时间:2024/05/29 14:52
<—start—>
编写crm的webservice接口,实现客户信息保存操作。在CustomerService接口中新增一个服务接口,用于添加客户注册的信息。
@Path("/customer")@POST@Consumes({ "application/xml", "application/json" })public void regist(Customer customer);
在实现类中,只需要调用dao的save方法保存以下就可。
@Overridepublic void regist(Customer customer) { System.out.println(customer); customerRepository.save(customer);}
因为save方法jpa接口中默认就有,所以不需要自定义去创建方法。
接下来就是在CustomerAction类中调用服务了。
调用webservice连接crm保存客户信息:发送json类型的数据,调用post方法将customer传递过去,客户注册就要保存到后台数据库,所以用post方法去添加。
@ParentPackage("json-default")@Namespace("/")@Controller@Scope("prototype")public class CustomerAction2 extends BaseAction<Customer> { @Action(value="customer_sendSms") public String sendSms() throws IOException{ //生成短信验证码 String randomCode = RandomStringUtils.randomNumeric(4); //将短信验证码保存到session中 ServletActionContext.getRequest().getSession().setAttribute(model.getTelephone(),randomCode); //编辑短信内容 String msg = "你好!本次获取的验证码位:"+randomCode; //调用SMS服务发送短信 //String result = SmsUtils.sendSmsByHTTP(model.getTelephone(),msg); String result = "000/XXX"; if(result.startsWith("000")){ //以"000"开头表示短信发送成功 return NONE; }else{ //发送失败,就抛出一个运行期异常 throw new RuntimeException("短信发送失败,信息码:"+result); } } //属性驱动接收页面填写的验证码 private String checkCode; public void setCheckCode(String checkCode) { this.checkCode = checkCode; } @Action(value="customer_regist",results={@Result(name="success",type="redirect",location="signup_success.html"), @Result(name="input",type="redirect",location="signup.html")}) public String regist(){ //先校验短信验证码,如果不通过就跳回登录页面 //从session中获取之前生成的短信验证码 String checkcodeSession = (String) ServletActionContext.getRequest().getAttribute(model.getTelephone()); if(checkcodeSession==null||!checkcodeSession.equals(checkCode)){ System.out.println("短信验证码错误!"); //短信验证码错误 return INPUT; } //调用webservice连接crm保存客户信息 WebClient.create("http://localhost:9002/crm_management/services/customerService/customer").type(MediaType.APPLICATION_XML) .post(model); System.out.println("客户注册成功..."); return SUCCESS; }}
<—end—>
阅读全文
0 0
- WebService实例-CRM系统提供WebService实现用户注册功能
- vtiger CRM 二次开发接口Webservice调用实例
- WebService简单功能实现
- Xfire实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java 实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- java实现webservice实例
- MyEclipse实现WebService实例
- Axis2实现webservice实例
- springboot +druid性能检测
- 实现浏览器点击后退键刷新界面
- Rancher Pipeline发布:开源、极简、强大的CI/CD
- 产品测试规范(三)
- BZOJ 3563 DZY Loves Chinese(线性基)
- WebService实例-CRM系统提供WebService实现用户注册功能
- MySQL表的约束及外键的添加
- JSTL格式化标签与函数
- 130. Surrounded Regions
- 依依东望
- ActionScript Object 2 Java Object
- bazel使用问题汇总
- 简单的图片上传功能
- C++ 知识点链接转载(持续更新)