中午突然就报错,这个是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>
已解决,问题原因未知,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); }
Premature end of file 是说,在SAXParser在解析stream流的时候,挂了,请检查检查你家程序吧