已解决,问题原因未知,len 的值为-1导致没有返回,处理方法是吧len的判断去掉 CloseableHttpResponse response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); long len = entity.getContentLength(); if(len > -1){ String content = EntityUtils.toString(entity,"utf-8"); sb.append(content); }
小程序调用微信支付,请求统一下单接口,无返回结果中午突然就报错,这个是xml解析错误org.xml.sax.SAXParseException; Premature end of file.,返回的xml是空的导致解析错误 这是我的请求: <xml> <appid>xxx</appid> <body>商城订单</body> <device_info>WEB</device_info> <mch_id>xxx</mch_id> <nonce_str>xxx</nonce_str> <notify_url>https://xxx/xxx/CallBackController/list</notify_url> <openid>o-xxxx</openid> <out_trade_no>xxxxx</out_trade_no> <sign>xxxx</sign> <spbill_create_ip>xxx.xxx.xx.xx</spbill_create_ip> <time_expire>20210708134655</time_expire> <time_start>20210707134655</time_start> <total_fee>13000</total_fee> <trade_type>JSAPI</trade_type> </xml>
2021-07-07