commit
291e19c17f
@ -129,10 +129,11 @@ public class WeixinRequestExecutor {
|
|||||||
if (logger.isEnabled(InternalLogLevel.DEBUG)) {
|
if (logger.isEnabled(InternalLogLevel.DEBUG)) {
|
||||||
logger.debug("weixin request >> " + request.getMethod() + " "
|
logger.debug("weixin request >> " + request.getMethod() + " "
|
||||||
+ request.getURI().toString());
|
+ request.getURI().toString());
|
||||||
|
printHttpRequest(request,InternalLogLevel.DEBUG);
|
||||||
}
|
}
|
||||||
HttpResponse httpResponse = httpClient.execute(request);
|
HttpResponse httpResponse = httpClient.execute(request);
|
||||||
WeixinResponse response = new WeixinResponse(httpResponse);
|
WeixinResponse response = new WeixinResponse(httpResponse);
|
||||||
handleResponse(response);
|
handleResponse(request,response);
|
||||||
return response;
|
return response;
|
||||||
} catch (HttpClientException e) {
|
} catch (HttpClientException e) {
|
||||||
throw new WeixinException(e);
|
throw new WeixinException(e);
|
||||||
@ -164,7 +165,7 @@ public class WeixinRequestExecutor {
|
|||||||
* 微信请求响应
|
* 微信请求响应
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
protected void handleResponse(WeixinResponse response)
|
protected void handleResponse(HttpRequest request,WeixinResponse response)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
boolean hasStreamMimeType = hasStreamMimeType(response);
|
boolean hasStreamMimeType = hasStreamMimeType(response);
|
||||||
if (logger.isEnabled(InternalLogLevel.DEBUG)) {
|
if (logger.isEnabled(InternalLogLevel.DEBUG)) {
|
||||||
@ -181,6 +182,7 @@ public class WeixinRequestExecutor {
|
|||||||
ApiResult result = response.getAsResult();
|
ApiResult result = response.getAsResult();
|
||||||
if (!SUCCESS_CODE.contains(String.format(",%s,", result.getReturnCode()
|
if (!SUCCESS_CODE.contains(String.format(",%s,", result.getReturnCode()
|
||||||
.toLowerCase()))) {
|
.toLowerCase()))) {
|
||||||
|
printHttpRequest(request,InternalLogLevel.WARN);
|
||||||
throw new WeixinException(result.getReturnCode(),
|
throw new WeixinException(result.getReturnCode(),
|
||||||
result.getReturnMsg());
|
result.getReturnMsg());
|
||||||
}
|
}
|
||||||
@ -190,6 +192,7 @@ public class WeixinRequestExecutor {
|
|||||||
XmlResult.class, response);
|
XmlResult.class, response);
|
||||||
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
||||||
.getResultCode().toLowerCase()))) {
|
.getResultCode().toLowerCase()))) {
|
||||||
|
printHttpRequest(request,InternalLogLevel.WARN);
|
||||||
throw new WeixinException(xmlResult.getErrCode(),
|
throw new WeixinException(xmlResult.getErrCode(),
|
||||||
xmlResult.getErrCodeDes());
|
xmlResult.getErrCodeDes());
|
||||||
}
|
}
|
||||||
@ -199,6 +202,18 @@ public class WeixinRequestExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void printHttpRequest(HttpRequest request,InternalLogLevel level){
|
||||||
|
if(request.getEntity() instanceof StringEntity){
|
||||||
|
if(level.equals(InternalLogLevel.DEBUG)) {
|
||||||
|
logger.debug("weixin request body >> " + ((StringEntity) request.getEntity()).getContentString());
|
||||||
|
}else if(level.equals(InternalLogLevel.INFO)){
|
||||||
|
logger.info("weixin request body >> " + ((StringEntity) request.getEntity()).getContentString());
|
||||||
|
}else if(level.equals(InternalLogLevel.WARN)){
|
||||||
|
logger.warn("weixin request body >> " + ((StringEntity) request.getEntity()).getContentString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public HttpClient getExecuteClient() {
|
public HttpClient getExecuteClient() {
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,4 +70,12 @@ public class MemCardCustomField {
|
|||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTips() {
|
||||||
|
return tips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTips(String tips) {
|
||||||
|
this.tips = tips;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user