有关微信支付回调notify_url的问题

wanj2015 2015-08-21 03:04:09
请教大家个问题,我做的微支付功能已经成功支付,微信那边也扣款成功,就是在调用我这边的接口来通知结果,但是会报错请大家看看是哪里的问题
回调的URL="http://XXXX:8080/wxnorn/PaySult"
我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

<servlet>
<display-name>PaySult</display-name>
<servlet-name>PaySult</servlet-name>
<servlet-class>com.servlet.PaySult</servlet-class>
<!-- 启动优先级
<load-on-startup>4</load-on-startup>-->
</servlet>
<servlet-mapping>
<servlet-name>PaySult</servlet-name>
<url-pattern>/PaySult/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
-----------------------------------------------------------------------------
/**微信回调函数
* 结果通知
* @author Administrator
*
*/
public class PaySult extends HttpServlet{
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {


System.out.println("~~~~~~~~开始~~~~~~~");
request = ServletActionContext.getRequest();
response = ServletActionContext.getResponse();
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);
}
System.out.println("~~~~~~~~~~~~~~~~付款成功~~~~~~~~~");
outSteam.close();
inStream.close();
String result = new String(outSteam.toByteArray(),"utf-8");//获取微信调用我们notify_url的返回信息
Map<Object, Object> map = XMLUtil.doXMLParse(result);
for(Object keyValue : map.keySet()){
System.out.println(keyValue+"="+map.get(keyValue));
}
if (map.get("result_code").toString().equalsIgnoreCase("SUCCESS")) {
//TODO 对数据库的操作
response.getWriter().write(XMLUtil.setXML("SUCCESS", "")); //告诉微信服务器,我收到信息了,不要在调用回调action了
System.out.println("-------------"+XMLUtil.setXML("SUCCESS", ""));
}

}
}
报错如下:
2015-8-21 14:37:15 org.apache.catalina.core.StandardWrapperValve invoke
严重: Allocate exception for servlet PaySult
java.lang.ClassNotFoundException: com.servlet.PaySult
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1094)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:808)
...全文
24094 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
q_107723600 2016-03-21
会回调的。只是。。。。我觉得时灵时不灵
回复
bossaiaboy 2015-11-04
请问下,调试回调url,需要对项目部署到公网吗???我看官网的asp.net项目demo,支付成功后,并不会回调呀
回复
ninuxGithub 2015-09-17
同样的问题啊?, 可能是返回的时候 response.getWriter().write(XMLUtil.setXML("SUCCESS", "")); 有问题 微信的服务器一直重复的发送询问
回复
java.lang.ClassNotFoundException: com.servlet.PaySult 这个类没找到啊,是不是你servlt配置哪里的问题
回复
Defonds 2015-08-22
看官方给的 demo 啊
回复
wanj2015 2015-08-21
回调函数优化了一下,本地测试通过了 /**微信回调函数 * 结果通知 * @author Administrator * */ public class PaySult extends HttpServlet{ private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("----接收微信发来的消息---"); // 获取收到的报文 BufferedReader reader = request.getReader(); String line = ""; StringBuffer inputString = new StringBuffer(); try{ while ((line = reader.readLine()) != null) { inputString.append(line); } request.getReader().close(); System.out.println("----接收到的报文---"+inputString.toString()); Map<Object, Object> map = XMLUtil.doXMLParse(inputString.toString()); for(Object keyValue : map.keySet()){ System.out.println(keyValue+"="+map.get(keyValue)); } if (map.get("result_code").toString().equalsIgnoreCase("SUCCESS")) { //TODO 对数据库的操作 response.getWriter().write(XMLUtil.setXML("SUCCESS", "")); //告诉微信服务器,我收到信息了,不要在调用回调action了 System.out.println("-------------"+XMLUtil.setXML("SUCCESS", "")); } }catch(Exception e){ e.printStackTrace(); } } }
回复
wanj2015 2015-08-21
找到原因了<servlet-class>com.servlet.PaySult</servlet-class>写的有问题,service写成servlet了 我的回调函数写的好像还是有问题,请大侠们再帮我看看
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-08-21 03:04
社区公告
暂无公告