2 xs993126 XS993126 于 2016.02.24 19:33 提问

急急急!!!银联app支付接收时接收后台商户通知识报错,求大神指教

我的代码:
*/
@Path("paymentcallback")
public class UnionpayCallbackServiceBean extends AbstractPaymentCallbackService {
private static Logger logger = LoggerFactory.getLogger(UnionpayCallbackServiceBean.class);

@Autowired
public UnionpayCallbackServiceBean(ApplicationContext appContext) {
    super(appContext);
}

@Override
@POST
@Path("unionpay")
@RequestMapping(value = "/ContentType", method = RequestMethod.POST, headers = "Content-Type=application/x-www-form-urlencoded")
public void run(@Context HttpServletRequest req, @Context HttpServletResponse resp) {
    String responseBody = "ok";
    logger.info("接受银联后台通知开始!!!");

    SDKConfig.getConfig().loadPropertiesFromSrc();

    try {
        req.setCharacterEncoding("ISO-8859-1");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    String encoding = req.getParameter(SDKConstants.param_encoding);
    // 获取银联通知服务器发送的后台通知参数
    Map<String, String> reqParam = MapParserUtils.getAllRequestParam(req);
    // Map<String, String> reqParam = SDKUtil.convertResultStringToMap(req.getQueryString());
    logger.info("BackRcvResponse接收后台通知入参:   " + reqParam);
    //String reqReserved = URLDecoder.decode(reqParam.get("signature"), "UTF-8");
    //reqParam.put("signature", reqReserved);
    //logger.info("reqReserved:   " + reqParam);

    /*Map<String, String> valideData = null;
    if (null != reqParam && !reqParam.isEmpty()) {
        Iterator<Entry<String, String>> it = reqParam.entrySet().iterator();
        valideData = new HashMap<String, String>(reqParam.size());
        while (it.hasNext()) {
            Entry<String, String> e = it.next();
            String key = (String) e.getKey();
            String value = (String) e.getValue();
            value = new String(value.getBytes("ISO-8859-1"), encoding);
            valideData.put(key, value);
        }
    }
    logger.info("valideData:   " + valideData);*/
    //重要!验证签名前不要修改reqParam中的键值对的内容,否则会验签不过
    if (!SDKUtil.validate(reqParam, encoding)) {
        logger.info("银联后台通知验证签名结果[失败].");
        UnionpayPlatformOrderInfo orderInfo = new UnionpayPlatformOrderInfo();
        orderInfo.setPayMethod(97);
        orderInfo.setOrderNo(reqParam.get("orderId"));
        orderInfo.setTradeStatus("failed");
        PayMethodEnum payMethodEnum = PayMethodEnum.getPayMethodEnum(orderInfo.getPayMethod());
        PaymentService paymentService = appContext.getBean(payMethodEnum.getTxCode(), PaymentService.class);
        paymentService.informPaymentResult(orderInfo);
        responseBody = "failed";
        //验签失败,需解决验签问题
    } else {
        logger.info("银联后台通知验证签名结果[成功].");
        //【注:为了安全验签成功才应该写商户的成功处理逻辑】交易成功,更新商户订单状态

        String orderId = reqParam.get("orderId"); //获取后台通知的数据,其他字段也可用类似方式获取
        String respCode = reqParam.get("respCode"); //获取应答码,收到后台通知了respCode的值一般是00,可以不需要根据这个应答码判断。

        logger.info("商户后台通知相关业务开始处理!!!");
        UnionpayPlatformOrderInfo orderInfo = new UnionpayPlatformOrderInfo();
        orderInfo.setPayMethod(97);
        orderInfo.setOrderNo(orderId);
        orderInfo.setTradeStatus("SUCCESS");
        orderInfo.setTransactionNo(reqParam.get("queryId"));
        orderInfo.setPaymentDatetime(new Date().toLocaleString());

        PayMethodEnum payMethodEnum = PayMethodEnum.getPayMethodEnum(orderInfo.getPayMethod());
        PaymentService paymentService = appContext.getBean(payMethodEnum.getTxCode(), PaymentService.class);
        logger.info("开始处理!!!!!!!!!!!!!!!!");
        paymentService.informPaymentResult(orderInfo);
        logger.info("商户后台通知相关业务处理完毕!!!");

        logger.info("银联接收后台通知结束");
        //返回给银联服务器http 200  状态码
        logger.info("成功打印ok!!!");
        logger.info("resp.getStatus() : " + resp.getStatus());
    }
    // 设置接口返回信息
    super.setResponseBody(resp, responseBody);
}

}

错误:
javax.ws.rs.NotSupportedException: Cannot consume content type
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:380)
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)
at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at com.alibaba.dubbo.rpc.protocol.rest.DubboHttpServer$RestHandler.handle(DubboHttpServer.java:86)
at com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet.service(DispatcherServlet.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

1个回答

caizhenying
caizhenying   2017.04.24 11:48

你好,请问解决了吗?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!