| @@ -10,9 +10,17 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| @RestController | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.io.ByteArrayOutputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.nio.charset.Charset; | |||||
| import java.util.Map; | |||||
| @Controller | |||||
| @RequestMapping("/wxOpen") | @RequestMapping("/wxOpen") | ||||
| public class WechatCalllbackController extends BaseController { | public class WechatCalllbackController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @@ -20,8 +28,30 @@ public class WechatCalllbackController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| protected WxOpenService wxOpenService; | protected WxOpenService wxOpenService; | ||||
| @RequestMapping(value = "/notify", consumes = "text/xml;charset=UTF-8") | |||||
| public Object receiveTicket(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp, | |||||
| @RequestMapping(value = "/notify", method = RequestMethod.POST) | |||||
| public Object receiveTicket(HttpServletRequest request) throws IOException { | |||||
| logger.info("[" +getIpAddr() + "]接收微信请求"); | |||||
| InputStream inStream = request.getInputStream(); | |||||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||||
| byte[] buffer = new byte[1024]; | |||||
| int len = 0; | |||||
| while ((len = inStream.read(buffer)) != -1) { | |||||
| outSteam.write(buffer, 0, len); | |||||
| } | |||||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||||
| logger.info(resultxml); | |||||
| outSteam.close(); | |||||
| inStream.close(); | |||||
| Map map = request.getParameterMap(); | |||||
| logger.info(map.toString()); | |||||
| return "success"; | |||||
| } | |||||
| @RequestMapping(value = "/notify1", method = RequestMethod.POST) | |||||
| public Object receiveTicket1(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp, | |||||
| @RequestParam("nonce") String nonce, @RequestParam("signature") String signature, | @RequestParam("nonce") String nonce, @RequestParam("signature") String signature, | ||||
| @RequestParam(name = "encrypt_type", required = false) String encType, | @RequestParam(name = "encrypt_type", required = false) String encType, | ||||
| @RequestParam(name = "msg_signature", required = false) String msgSignature) { | @RequestParam(name = "msg_signature", required = false) String msgSignature) { | ||||