|
@ -143,6 +143,41 @@ public class HttpClientManager { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* desc: 发送json post 请求 |
|
|
|
|
|
* param: url,jsonStrParam |
|
|
|
|
|
* return: CallResult<String> |
|
|
|
|
|
* date: 2019/2/21 9:12 |
|
|
|
|
|
* |
|
|
|
|
|
* @author: jianjun liu |
|
|
|
|
|
*/ |
|
|
|
|
|
public Result<String> sendPostAndHeader(String url, Map<String, Object> paramsMap, Map<String,String> headerMap) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
HttpPost httppost = new HttpPost(url); |
|
|
|
|
|
httppost.setConfig(requestConfig); |
|
|
|
|
|
|
|
|
|
|
|
httppost.addHeader(HEADER_CONTENT_TYPE, HEADER_APPLICATION_FORM_URL_ENCODED); |
|
|
|
|
|
if (null != headerMap){ |
|
|
|
|
|
headerMap.forEach((k,v) -> { |
|
|
|
|
|
httppost.addHeader(k,v); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
List<NameValuePair> list = new ArrayList<NameValuePair>(); |
|
|
|
|
|
for (String key : paramsMap.keySet()) { |
|
|
|
|
|
list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key)))); |
|
|
|
|
|
} |
|
|
|
|
|
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, UTF8); |
|
|
|
|
|
httppost.setEntity(urlEncodedFormEntity); |
|
|
|
|
|
|
|
|
|
|
|
return execute(httppost, false); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("send exception", e); |
|
|
|
|
|
return new Result<String>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* desc: 发送json post 请求 |
|
|
* desc: 发送json post 请求 |
|
|
* param: url,jsonStrParam |
|
|
* param: url,jsonStrParam |
|
|