JAVA微信支付多次回调方法解决方案
@WebServlet("/ActionServlet")
public class PayWxOrderingReqCBS extends HttpServlet {
public PayWxOrderingReqCBS() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String msg = "success";
response.setContentType("text/xml");
System.out.print("微信支付回调数据开始");
String inputLine;
String notityXml = "";
String resXml = "";
try {
while ((inputLine = request.getReader().readLine()) != null) {
notityXml += inputLine;
}
request.getReader().close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("接收到的报文:" + notityXml);
System.out.println("微信支付回调数据结束");
System.out.println("告知服务端订单情况");
String b = Xml2JsonUtil.xml2JSON(notityXml);
System.out.println("=======================>"+b);
try {
JSONObject c = new JSONObject(b);
String d = c.get("xml").toString();
JSONObject e = new JSONObject(d);
String f = e.get("return_code").toString();
if (f.contains("SUCCESS")) {
/** 告知订单状态,修改订单状态 */
具体业务
}
} catch (JSONException e) {
e.printStackTrace();
} catch (SwordBaseCheckedException e) {
e.printStackTrace();
}
resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>"
+ "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
BufferedOutputStream out = new BufferedOutputStream(
response.getOutputStream());
out.write(resXml.getBytes());
out.flush();
out.close();
response.getWriter().println(msg);
}
最新文章
- 重走java---Step 1
- nyoj814_又见拦截导弹_DP
- Juniper SRX防火墙-NAT学习笔记!
- Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 离线+线段树
- scrollerView 轮番图
- Oracle安装时忘记解锁scott用户的解决方案
- verilog 双向IO实现
- web从入门开始(6)-----框架
- IDisposeable,Close
- chorme调试Paused in debugger问题解决
- jQuery监听事件经典例子
- SpringBoot入门教程(四)MyBatis generator 注解方式和xml方式
- springboot情操陶冶-jmx解析
- Linux 动态加载共享库
- 【分享】谈CSS3中display属性的flex布局
- 如何使用tensorboard查看tensorflow graph****.pb文件的模型结构
- Linux sleep 语句以及循环 测试负载
- openMP多线程编程
- CRM WEB UI 01 BOL向导创建的搜索
- JAVA框架 SpringMVC RequestMapping讲解