有没有好心人帮忙邀请一下官方技术
微信支付 沙箱环境 请求API密钥 返回【请求参数xml格式错误】请求的参数为: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <xml> <nonce_str>WSRQ7N7FFTVUG2DUSMY74C913XJK1ZNI</nonce_str> <sign>3FB43D66CFD8111E007F8641E0907C89</sign> <mch_id>1603461441</mch_id> //为安全考虑,商户ID已做了更改 </xml> 返回的结果为: <xml> <return_code><![CDATA[FAIL]]></return_code> <retmsg><![CDATA[输入请求参数xml格式错误]]></retmsg> <retcode><![CDATA[1]]></retcode> </xml> Map转xml的代码用的是官方jdk里的,如下 //沙箱环境下需先请求获取key Map testMap = new HashMap<>(); testMap.put("mch_id", mchId); testMap.put("nonce_str",getRandomString()); //生成符合规格的签名串 String stringTestSignTemp = getParamStr(testMap); //进行MD5运算,并转为大写,获得sign参数的值 String signTestValue = MD5(stringTestSignTemp.toString()).toUpperCase(); //把sign放入map中 testMap.put("sign",signTestValue); //map转义为xml格式 String requestTestParam = mapToXml(testMap); LOG.info("request sandbox API key - [parameters]:" +requestTestParam); //发送请求 String testResult = sendPostParam(sandBoxUrl, requestTestParam); LOG.info("request sandbox API key - [results]:" +testResult); //Map转xml方法 public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); documentBuilderFactory.setXIncludeAware(false); documentBuilderFactory.setExpandEntityReferences(false); return documentBuilderFactory.newDocumentBuilder(); } public static String mapToXml(Map data) throws Exception { org.w3c.dom.Document document = newDocumentBuilder().newDocument(); org.w3c.dom.Element root = document.createElement("xml"); document.appendChild(root); for (String key: data.keySet()) { String value = data.get(key); if (value == null) { value = ""; } value = value.trim(); org.w3c.dom.Element filed = document.createElement(key); filed.appendChild(document.createTextNode(value)); root.appendChild(filed); } TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); DOMSource source = new DOMSource(document); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); transformer.transform(source, result); String output = writer.getBuffer().toString(); try { writer.close(); } catch (Exception ex) { } return output; }
2020-10-30我也遇到了这问题,点击进入地址选择后又会自动退出来,并返回cancel,我调试了好久把“if(wx.chooseAddress)”这个逻辑删除了就不报错了,不是很懂为什么
wx.chooseAddress在众多iphone手机有自动取消问题?wx.chooseAddress在多款iphone手机有自动取消问题。就是说,选择地址插件的时候,自动取消。 打印是:Object {errMsg:"chooseAddress:cancel"}。 经过测试,有些iphone手机有这个问题,有的没有。列表如下: 有问题:iphone3 有问题:iphone7p 微信7.0.12 有问题:iphone11 微信7.012 无问题:iphoneX 微信7.0.12 ——这个问题,很着急,很严重。。。希望能获得什么帮助。。。
2020-07-14