|
@@ -19,9 +19,9 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.util.StreamUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.w3c.dom.Node;
|
|
|
import org.w3c.dom.NodeList;
|
|
@@ -102,7 +102,7 @@ public class TestController {
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/notifyMsg")
|
|
|
+ @RequestMapping(value = "/notifyMsg",method = { RequestMethod.GET, RequestMethod.POST })
|
|
|
@ApiOperation("处理服务器推送消息")
|
|
|
public String checkSign(HttpServletRequest request, HttpServletResponse response) {
|
|
|
log.info("-----------进入---------");
|
|
@@ -202,6 +202,7 @@ public class TestController {
|
|
|
}
|
|
|
// Map<String, String> decryptMap = xmlToMap(returnXml.toString());
|
|
|
Map<String, String> decryptMap = xmlToMap(returnXml.toString());
|
|
|
+ log.info("-----decryptMap------"+decryptMap);
|
|
|
// // 得到公众号传来的加密信息并解密,得到的是明文xml数据
|
|
|
// String decryptXml = WXPublicUtils.decrypt(encryptMap.get("Encrypt"));
|
|
|
// 将xml数据转换为map
|
|
@@ -231,6 +232,7 @@ public class TestController {
|
|
|
returnMap.put("CreateTime", new Date().getTime()+"");
|
|
|
returnMap.put("MsgType", "text");
|
|
|
returnMap.put("Content", "测试哈哈哈哈");
|
|
|
+ log.info("5.2...----returnMap-----"+returnMap);
|
|
|
String encryptMsg = mapToXml(returnMap);
|
|
|
return encryptMsg;
|
|
|
} else if ("unsubscribe".equals(event)) { // 取消订阅事件
|
|
@@ -244,6 +246,7 @@ public class TestController {
|
|
|
returnMap.put("CreateTime", new Date().getTime()+"");
|
|
|
returnMap.put("MsgType", "text");
|
|
|
returnMap.put("Content", "测试哈哈哈哈");
|
|
|
+ log.info("5.3...----returnMap-----"+returnMap);
|
|
|
String encryptMsg = mapToXml(returnMap);
|
|
|
return encryptMsg;
|
|
|
} else if ("LOCATION".equals(event)) { // 上报地理位置事件
|
|
@@ -257,7 +260,7 @@ public class TestController {
|
|
|
} catch (Exception e) {
|
|
|
log.error("处理微信公众号请求信息,失败", e);
|
|
|
}
|
|
|
- return "22222";
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -305,6 +308,7 @@ public class TestController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public static String mapToXml(Map<String, String> data) throws Exception {
|
|
|
+ log.info("----mapToXml-----"+data);
|
|
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
|
|
DocumentBuilder documentBuilder= documentBuilderFactory.newDocumentBuilder();
|
|
|
org.w3c.dom.Document document = documentBuilder.newDocument();
|
|
@@ -334,10 +338,13 @@ public class TestController {
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
}
|
|
|
+ log.info("----mapToXml-return-----"+output);
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|