dev --- 3.8.0.A版本, openProject引用 ; formao-live --- 3.7.0.B 版本, formallProject引用
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 消息机制未实现,下面为通知回调中设置的代码部分
  2. ```
  3. @RestController
  4. @RequestMapping("notify")
  5. public class NotifyController extends WechatThridBaseController {
  6. @Autowired
  7. protected WxOpenServiceDemo wxOpenService;
  8. @RequestMapping("receive_ticket")
  9. public Object receiveTicket(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp,
  10. @RequestParam("nonce") String nonce, @RequestParam("signature") String signature,
  11. @RequestParam(name = "encrypt_type", required = false) String encType,
  12. @RequestParam(name = "msg_signature", required = false) String msgSignature) {
  13. this.logger.info(
  14. "\n接收微信请求:[signature=[{}], encType=[{}], msgSignature=[{}],"
  15. + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
  16. signature, encType, msgSignature, timestamp, nonce, requestBody);
  17. if (!StringUtils.equalsIgnoreCase("aes", encType) || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) {
  18. throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
  19. }
  20. // aes加密的消息
  21. WxOpenXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedXml(requestBody, wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature);
  22. this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
  23. String out = null;
  24. try {
  25. out = wxOpenService.getWxOpenComponentService().route(inMessage);
  26. } catch (WxErrorException e) {
  27. throw new ResponseException(ErrorCodeEnum.ERROR, e);
  28. }
  29. this.logger.debug("\n组装回复信息:{}", out);
  30. return out;
  31. }
  32. @RequestMapping("{appId}/callback")
  33. public Object callback(@RequestBody(required = false)String requestBody,
  34. @PathVariable ("appId") String appId,
  35. @RequestParam("signature") String signature,
  36. @RequestParam("timestamp") String timestamp,
  37. @RequestParam("nonce") String nonce,
  38. @RequestParam("openid") String openid,
  39. @RequestParam("encrypt_type") String encType,
  40. @RequestParam("msg_signature") String msgSignature) {
  41. this.logger.info(
  42. "\n接收微信请求:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}],"
  43. + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
  44. appId, openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
  45. logger.info("query:"+getHttpServletRequest().getQueryString()+"\nbody:"+requestBody);
  46. if (!StringUtils.equalsIgnoreCase("aes", encType) || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) {
  47. throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
  48. }
  49. String out = "";
  50. // aes加密的消息
  51. WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(requestBody, wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature);
  52. this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
  53. //wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId);
  54. return out;
  55. }
  56. }
  57. ```