zoukankan      html  css  js  c++  java
  • WebService

    public String  queryCreditInfo(Parameter parameter, String type)
       throws Exception {
      String jsonResult = null;
      try {
       if ("person".equals(type)) {
        HttpClient http = new HttpClient();
        System.out.println(parameter.getSign("person")); //加密
        String url = "https://www.alit.cn/reportserver/rest/ylService/personReport?name="+URLEncoder.encode(parameter.getName(), "utf-8")+ "&idCard="+ parameter.getIdCard()+ "&card="+ parameter.getCard()+ "&confirmCard="+ parameter.getConfirmCard()+ "&member="+ parameter.getMember()+ "&sign="+parameter.getSign("person");
        Protocol myhttps = new Protocol("https", new MySSL(), 443);
        Protocol.registerProtocol("https", myhttps);
        GetMethod method = new GetMethod(url);
        http.executeMethod(method);
        jsonResult = method.getResponseBodyAsString();
       }else {
        throw new Exception("查询报告类型不能为空");
       } 
      } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
      return jsonResult;
     }

    //加密方法

    public String getSign(String type) throws Exception {
      if("person".equals(type)){
        this.sign = Md5.md5(this.getName() + this.getIdCard() + this.getCard()+this.getConfirmCard() + this.getMember() + this.getKey());
       return sign;
      }else if("merchant".equals(type)){
       if(null==this.getBussesCode()||"".equals(this.getBussesCode())){
        this.bussesCode = null;
       }
       if(null==this.getMid()||"".equals(this.getMid())){
        this.mid = null;
       }
       this.sign = Md5.md5(this.getName() + this.bussesCode + this.getMid()+ this.getMember() + this.getKey());
       return sign;
      }else{
       throw new Exception("sign生成错误");
      }
     }

    //MD5加密类

    public class Md5 {  

    private static final String encryModel = "MD5";  

    /**   * md5加密方法   * @param str   * @return   */    

    public static String md5(String str) throws Exception {        

      return md5(encryModel, str.getBytes("utf-8"));    

    }

    public static String md5(String algorithm, byte[] data) {        

      try {            

        MessageDigest md = MessageDigest.getInstance(algorithm);            

        md.update(data);            

        StringBuffer sb = new StringBuffer();            

        byte[] bytes = md.digest();            

        for (int i = 0; i < bytes.length; i++) {                

          int b = bytes[i] & 0xFF;                

          if (b < 0x10) {                    

            sb.append('0');                

          }                

          sb.append(Integer.toHexString(b));            

        }            

      return sb.toString();        

    } catch (Exception e) {            

    return "";        

    }    

    }     

  • 相关阅读:
    服务器Jmail配置问题
    Silverlight视频教程、资源下载。如果你觉得看图文不够形象,不够生动,那就看看视频吧。
    AspNetPager,asp.net分页的最终解决方案!
    VS2008的Web Application——net 1.1 CodeBehind 模式的回归(非编译模式)
    修复Jscript(IE浏览器脚本引擎)异常
    SQL Server中查看SQL句子执行所用的时间
    SilverLight开发系列第1步:搭建开发环境
    SilverLight开发系列第2步:使用vs2008和Blend 2.5打造Hellow World程序
    谨慎使用Paypal一类的 支付 中介公司
    一个典型的数据库操作事务死锁分析
  • 原文地址:https://www.cnblogs.com/Defry/p/4607641.html
Copyright © 2011-2022 走看看