| | |
| | | |
| | | |
| | | String appid = "A1749891493E4CDDBFE4506357B1F0AB"; |
| | | String orderUrl = "http://finpt.xjcz.gov.cn/fs-service/fs-pay/uploadXml.do"; |
| | | String uploadUrl = "http://finpt.xjcz.gov.cn/fs-service/fs-pay/uploadXml.do"; |
| | | |
| | | SignatureFileVo signatureFile = new SignatureFileVo(); |
| | | signatureFile.setFileData(plain); |
| | | signatureFile.setOrderNo(orderId); |
| | | String reqdatastr = JSONObject.toJSONString(signatureFile); |
| | | |
| | | String reqdata = getBase64(signatureFile.toString()); |
| | | String mac = appid + "||" + reqdata; |
| | | mac = DigestUtils.md5Hex(mac.getBytes()); |
| | | String mac = this.getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + this.getBase64(reqdatastr)); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("appid", "A1749891493E4CDDBFE4506357B1F0AB"); |
| | | jsonObject.put("mac", mac); |
| | | jsonObject.put("reqdata", this.getBase64(reqdatastr)); |
| | | Map<String, String> header = new HashMap(); |
| | | header.put("Accept", "application/json;charset=utf-8"); |
| | | header.put("Content-Type", "application/json;charset=utf-8"); |
| | | String resultStr = HttpUtil.post(uploadUrl, jsonObject); |
| | | JSONObject result = JSONObject.parseObject(resultStr); |
| | | |
| | | params.put("appid", appid); |
| | | params.put("reqdata", reqdata); |
| | | params.put("mac", mac); |
| | | |
| | | HttpPost httpPost = new HttpPost(orderUrl); |
| | | httpPost.setEntity(assemblyFormEntity(params, "utf-8")); |
| | | HttpClient httpClient = getHttpClient(orderUrl); |
| | | HttpResultVo execute = null; |
| | | try { |
| | | execute = httpClient.execute(httpPost, getResponseHandler()); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | String stringContent = execute.getStringContent(); |
| | | ResultVo resultVo = JSONObject.parseObject(stringContent, ResultVo.class); |
| | | // String reqdata = getBase64(signatureFile.toString()); |
| | | // String mac = appid + "||" + reqdata; |
| | | // mac = DigestUtils.md5Hex(mac.getBytes()); |
| | | // |
| | | // params.put("appid", appid); |
| | | // params.put("reqdata", reqdata); |
| | | // params.put("mac", mac); |
| | | // |
| | | // HttpPost httpPost = new HttpPost(orderUrl); |
| | | // httpPost.setEntity(assemblyFormEntity(params, "utf-8")); |
| | | // HttpClient httpClient = getHttpClient(orderUrl); |
| | | // HttpResultVo execute = null; |
| | | // try { |
| | | // execute = httpClient.execute(httpPost, getResponseHandler()); |
| | | // } catch (IOException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // String stringContent = execute.getStringContent(); |
| | | ResultVo resultVo = JSONObject.parseObject(resultStr, ResultVo.class); |
| | | log.info("请求结果转为:" + resultVo); |
| | | return resultVo; |
| | | } |